You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When building an ES6 module, Emscripten automatically adds:
exportdefaultmyModuleInitFunction;
to the resulting JS file. "The problem" with that is that we (the sqlite project) have to, due in part to #18071, overwrite the module init function object with a modified one. We do this via --extern-post-js and then want to do:
exportdefaultourModifiedInitFunction;
but it's illegal to do "export default" twice in the same module.
Our current workaround is this bit of hackery in our makefile after compiling sqlite3.mjs:
@if [ esm = $(1) ]; then \
echo "Fragile workaround for an Emscripten annoyance. See emcc.flags.sqlite3.esm."; \
sed -i -e '0,/^export default/{/^export default/d}' $@ || exit $$?; \
if ! grep -q '^export default' $@; then \
echo "Cannot find export default." 1>&2; \
exit 1; \
fi; \
fi
i.e. we delete the first "export default" line, leaving ours intact. That's horribly fragile.
Sidebar: the auto-injected "export default" line does not include a newline after it, which causes --extern-post-js to be appended starting on that same line, which requires a separate kludge on our side to account for.
What would be really useful is a way to tell emcc to not add the "export default" line automatically. When building an .mjs file it automatically does so even if -sEXPORT_ES6=0 is used. An alternative implementation would be to not add that line when -sEXPORT_ES6=0, but whether or not that would have other side effects is a question i cannot answer.
The text was updated successfully, but these errors were encountered:
When building an ES6 module, Emscripten automatically adds:
to the resulting JS file. "The problem" with that is that we (the sqlite project) have to, due in part to #18071, overwrite the module init function object with a modified one. We do this via
--extern-post-js
and then want to do:but it's illegal to do "export default" twice in the same module.
Our current workaround is this bit of hackery in our makefile after compiling
sqlite3.mjs
:i.e. we delete the first "export default" line, leaving ours intact. That's horribly fragile.
Sidebar: the auto-injected "export default" line does not include a newline after it, which causes
--extern-post-js
to be appended starting on that same line, which requires a separate kludge on our side to account for.What would be really useful is a way to tell emcc to not add the "export default" line automatically. When building an
.mjs
file it automatically does so even if-sEXPORT_ES6=0
is used. An alternative implementation would be to not add that line when-sEXPORT_ES6=0
, but whether or not that would have other side effects is a question i cannot answer.The text was updated successfully, but these errors were encountered: