-
-
Notifications
You must be signed in to change notification settings - Fork 175
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: create a bundled build of wasm #1088
Conversation
Another useful build is the Would you accept another build of this nature? It would require the change in #1088 (comment); but the result is a 2.5M bundle (as opposed to 11M with the |
set(WASM_BUNDLE_LINK_FLAGS | ||
-s SINGLE_FILE | ||
--embed-file ${WASM_PRELOAD_DIR}@swipl) | ||
join_list(WASM_BUNDLE_LINK_FLAGS_STRING " " ${WASM_BUNDLE_LINK_FLAGS} " " ${WASM_SHARED_LINK_FLAGS}) | ||
add_executable(swipl-bundle ${SWIPL_SRC}) | ||
set_target_properties(swipl-bundle PROPERTIES | ||
LINK_FLAGS "${WASM_BUNDLE_LINK_FLAGS_STRING}") | ||
target_link_libraries(swipl-bundle libswipl) | ||
add_dependencies(swipl-bundle wasm_preload) | ||
set_property(TARGET swipl-bundle PROPERTY LINK_DEPENDS | ||
${POSTJS} ${PREJS}) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
set(WASM_BUNDLE_LINK_FLAGS | |
-s SINGLE_FILE | |
--embed-file ${WASM_PRELOAD_DIR}@swipl) | |
join_list(WASM_BUNDLE_LINK_FLAGS_STRING " " ${WASM_BUNDLE_LINK_FLAGS} " " ${WASM_SHARED_LINK_FLAGS}) | |
add_executable(swipl-bundle ${SWIPL_SRC}) | |
set_target_properties(swipl-bundle PROPERTIES | |
LINK_FLAGS "${WASM_BUNDLE_LINK_FLAGS_STRING}") | |
target_link_libraries(swipl-bundle libswipl) | |
add_dependencies(swipl-bundle wasm_preload) | |
set_property(TARGET swipl-bundle PROPERTY LINK_DEPENDS | |
${POSTJS} ${PREJS}) | |
set(WASM_BUNDLE_EMBEDDED_LINK_FLAGS | |
-s SINGLE_FILE | |
--embed-file ${WASM_PRELOAD_DIR}@swipl) | |
set(WASM_BUNDLE_LINK_FLAGS | |
-s SINGLE_FILE) | |
join_list(WASM_BUNDLE_LINK_FLAGS_STRING " " ${WASM_BUNDLE_LINK_FLAGS} " " ${WASM_SHARED_LINK_FLAGS}) | |
join_list(WASM_BUNDLE_EMBEDDED_LINK_FLAGS_STRING " " ${WASM_BUNDLE_EMBEDDED_LINK_FLAGS} " " ${WASM_SHARED_LINK_FLAGS}) | |
add_executable(swipl-bundle ${SWIPL_SRC}) | |
set_target_properties(swipl-bundle PROPERTIES | |
LINK_FLAGS "${WASM_BUNDLE_LINK_FLAGS_STRING}") | |
target_link_libraries(swipl-bundle libswipl) | |
add_dependencies(swipl-bundle wasm_preload) | |
set_property(TARGET swipl-bundle PROPERTY LINK_DEPENDS | |
${POSTJS} ${PREJS}) | |
add_executable(swipl-bundle-embedded ${SWIPL_SRC}) | |
set_target_properties(swipl-bundle-embedded PROPERTIES | |
LINK_FLAGS "${WASM_BUNDLE_EMBEDDED_LINK_FLAGS_STRING}") | |
target_link_libraries(swipl-bundle-embedded libswipl) | |
add_dependencies(swipl-bundle-embedded wasm_preload) | |
set_property(TARGET swipl-bundle-embedded PROPERTY LINK_DEPENDS | |
${POSTJS} ${PREJS}) | |
@JanWielemaker - This is ready for review |
Hope to take care of this shortly. I've a bit of a backlog on issues though 😢 |
The bundle builds fine, but trying to use it in shell.html results in
What does this change to how it is supposed to be used? |
It should be able to be left undefined and in those cases just do nothing. I'm unsure why this is a new error - I don't think it would be caused by the new configuration file. In particular I did not get any errors of the sorts when using the output of this build file on commit b089616 (i.e. the commit that npm-swipl-wasm is using in the DockerFile). Have you made any changes to any other code since then that may be the culprit? |
I tried having a quick look at this diff but could not identify anything that might be the cause on first parse. |
I've tried (unsucessfully) to reproduce this error on this branch of
For me the website appears to run without problem In addition, I've tested these changes on the latest version of swipl-devel in the same branch. The However if I add a new test it(`[${name}] ` + "should be able to preload files and generate images", async () => {
const eye = await eyePlString();
const Module = await SWIPL({
arguments: ['-q', '-f', 'eye.pl'],
preRun: (Module) => Module.FS.writeFile('eye.pl', eye) });
queryOnce(Module, 'main', ['--image', 'eye.pvm']);
assert.strictEqual(Module.FS.readFile('eye.pvm').length > 500, true);
}); then it fails with 1) SWI-Prolog WebAssembly on Node.js
[node] should be able to preload files and generate images:
TypeError: Module.preRun.push is not a function
at loadPackage (dist/swipl/swipl.js:9:6290)
at /home/jesse/Documents/github/npm-swipl-wasm/dist/swipl/swipl.js:9:6308
at /home/jesse/Documents/github/npm-swipl-wasm/dist/swipl/swipl.js:9:30567
at module.exports (dist/swipl-node.js:8:10)
at Context.<anonymous> (tests/node.js:83:30)
at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
2) SWI-Prolog WebAssembly on Node.js
[web] should be able to preload files and generate images:
TypeError: Module.preRun.push is not a function
at loadPackage (dist/swipl/swipl-web.js:9:6290)
at /home/jesse/Documents/github/npm-swipl-wasm/dist/swipl/swipl-web.js:9:6308
at /home/jesse/Documents/github/npm-swipl-wasm/dist/swipl/swipl-web.js:9:30567
at Context.<anonymous> (tests/node.js:83:30)
at process.processTicksAndRejections (node:internal/process/task_queues:95:5) but this test runs fine on the bundled build. NOTE These errors come from Lines 128 to 130 in 4a83822
NOTE: These errors also occur with the original CMAKE file on commit b089616 NOTE: #1103 Resolves this error |
Resolves the issue observed in SWI-Prolog#1088 (comment)
Resolves the issue observed in #1088 (comment)
Resolves the issue observed in SWI-Prolog/swipl-devel#1088 (comment)
Follows up on the discussion SWI-Prolog/npm-swipl-wasm#8 to produce a
swipl-bundle.js
build which inlines the.wasm
and.data
files.