-
-
Notifications
You must be signed in to change notification settings - Fork 2.3k
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
Add support for import subpath patterns #7840
Comments
For more information, webpack achieves this using their enhanced-resolve package. The issue for adding the |
Really this feature request should be for supporting the entire |
Also esbuild and rollup support import subpath patterns as well |
Will be fixed by #8807 in the next release |
Well, it is not. (^2.9.1)
|
Please note that exports/imports support is currently opt-in to avoid breaking changes. To enable it, add the following to your project root package.json: {
"@parcel/resolver-default": {
"packageExports": true
}
} See the docs for more details: https://parceljs.org/features/dependency-resolution/#package-exports |
Thanks, and apologies, I only found this issue when searching for informations about this. |
🙋 feature request
Add support for import subpath patterns for framework agnostic aliasing
🤔 Expected Behavior
With the following in package.json:
I should be able to import like the following:
😯 Current Behavior
Parcel already supports glob aliases to achieve the same thing. However import subpath patterns are a standard supported natively in node.
💁 Possible Solution
Implement code in dependency resolution to support
imports
in package.json. One part of the spec that helps is thatimports
entries MUST start with # in order to work. If an import starts with '#' then Parcel should check package.json for theimports
section before resolving with it's own alias configuration. Webpack uses this same method, or rather it only will resolve '#' imports with package.json.🔦 Context
While parcel aliasing is useful it's specific to Parcel. Jest, express, other bundlers, typescript all need their own specific configuration to support the same code. Webpack, express, build scripts, and top level jest imports all already support import subpath patterns. Jest mocking is waiting on a third party dependency to get support for mocking apis as well. It would be nice if typescript/vs code supported it as well, but as more packages implement the standard it puts more pressure on other packages to adopt.
Even in its current state I can at least get framework agnostic support for Parcel AND for node.js backend/scripts just like I can with Webpack.
The text was updated successfully, but these errors were encountered: