Build modularized JS toolkit with support for -s EXPORT_ES6
#3174
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Related to #3168.
Recently there was some progress in emscripten to support ECMAScript modules and emscripten-core/emscripten#11792 was implemented in emscripten-core/emscripten#17915. This means that since
em++
v3.1.27 we can use theEXPORT_ES6
flag to generate an ESM build of the emscripten module instead of a CommonJS module (that can be imported with ESM).Is there anything I can add to force usage of em++ v3.1.27?
I did some tests an even without 3bca155 everything did work just fine in my project. But adding
mjs
as file extension will probably be the safer method to ensure the verovio-module will be used with ESM. For other usage you can still useverovio-toolkit-wasm.js
with CommonJS due to the UMD format.Probably this won't fix all cases when using verovio with bundlers (see this comment emscripten-core/emscripten#11792 (comment)) but it should still improve ESM support.