-
-
Notifications
You must be signed in to change notification settings - Fork 670
Add package exports fallback for the CLI, dist files, etc. #1527
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
Conversation
Maybe a test suite which tries to import/resolve the subpackages/named exports under different conditions (node versions, type=commonjs, type=module, using TS, using different bundlers, ...) could be useful. Sorry, if https://github.com/AssemblyScript/assemblyscript/tree/master/tests/packages already includes thoses. |
I agree that having actual tests would be best, yeah. Needs to somehow install the package before it's published then, via a |
Also note that 0.17.0 breaks with node <=12 anyhow (14 entered LTS just recently) due to making the ES module the default, with |
Turns out that node 12 has some sort of experimental support with a warning:
and does not understand the
with the fallback triggering for node >=14, and being otherwise ignored. Raises the question whether we should rather intentionally break with node 12, so users upgrade to a version of node that we can guarantee will work for at least a while. |
For completeness, node 10 breaks on |
Merging this for now since I expect most problems to be solved by it, but I also have an external test package now that I can first verify with and perhaps make a test of eventually. |
Test package: https://github.com/dcodeIO/assemblyscript-esm-test/runs/1326736751
TL;DR: Node >=^12 works with the new stuff, 11 works with legacy require, and less than 11 fails due to |
So it works with node 14 and 15 just fine? I'm okay with that. |
With the fallback, legacy cases like
including others we haven't though of yet are covered by always resolving
./* -> ./*.js
. Fixes #1522At some point we'll most likely want to break this, either to pull packages out of the main packages or make nicer entry points like just
/loader
, but this gives us sufficient backwards compatibility (on node >= 15, need to check 14) for now so is good to do :)Edit: According to the node 14 docs, the fallback should work there as well.