Make loader ESM by default, with UMD fallback #1513
Merged
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.
The loader cannot be easily used on the web currently without either bundling or exports-shimming it, so this PR refactors it to an ES module by default with an UMD fallback. The package is set up in a way that either
require
ing (from CommonJS) orimport
ing (from ESM) the loader should work in recent node.js, and where that's not applicable for some reason one mayrequire("@assemblyscript/loader/umd")
as a fallback.Should not break backwards compatibility under recent node.js, but will break usage under older node.js and on the web (to the better, esp. on the web), e.g. will require updating the editor on our website by removing the exports-shim.
Unlike #1313 this does not do any silly
.mjs
or.cjs
stuff (turned out to break CDNs, i.e. not understanding what a .cjs's content type is) and does not refactor anything else but the loader, which is the most important for now.