fix: support modern package exports syntax #5996
Closed
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.
What is the current behavior?
Currently, you cannot use packages that use modern module resolution based on subpath-exports in your Stencil Project1.
This is caused by the hard coding of Node10 for moduleResolution in Stencil.
GitHub Issue Number: #4229 (mitigation, not 💯 fix)
What is the new behavior?
Replace Node10 with Bundler. While it's not a "trivial" change, the impact for the end-user should be minimal (see Breaking change section)
Documentation
N.A.
Does this introduce a breaking change?
I ran some 'health-check' (running stencil compiler with & without my changes on packages that use various ways of defining sub-packages), and all projects that worked without my changes worked with it as well, without changes.
Moreover, from the TypeScript reference documentation, I reckon it is safe to say that Bundler is akin to a "superset" of Node10:
https://www.typescriptlang.org/docs/handbook/modules/reference.html#bundler
https://www.typescriptlang.org/docs/handbook/modules/reference.html#node10-formerly-known-as-node
Testing
In addition to the existing test (
npm test
), I ran some san-check. We have a package that we are migrating from 'hackish subpackages' (using subdirectory and package.json in them) to subpath exports in a major version, I used this package as an example and did the following tests:To validate, check the linked repo (pay attention to the branch),
npm i ; npm start
I'm not necessarily expecting this to be an 'LGTM & merge' but more a base to discuss how to improve Stencil so that it's not a blocker for good practices adoption (pure incompatibility with modern package practice is quite a sore point tbh), which is paramount IMHO for developer-oriented products.
Footnotes
https://nodejs.org/api/packages.html#subpath-exports ↩