-
-
Notifications
You must be signed in to change notification settings - Fork 8.8k
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
Respect "exports" field in "package.json" #9509
Comments
We can add this a experiment in webpack 5. |
@sokra yes, it is good candidate to be included in |
This issue had no activity for at least three months. It's subject to automatic issue closing if there is no activity in the next 15 days. |
Bump |
In addition to More details on this feature: nodejs/modules#306 |
The |
@mgol Don't worry, we will implement that for webpack@5 |
Is this in the beta yet? I would like to test it if so. |
No, but in roadmap, it will be implemented to stable version |
Someone mind fixing the typo in the title, "filed" -> "field", so that this may appear more easily in search results? |
Done |
An important note here: once the More info at https://nodejs.org/api/esm.html#esm_package_exports:
This is a breaking change so please remember to include this restriction in Webpack 5.0.0 or it might have to wait until version 6! |
We also need to decide: what happens with the Tbh I'm not really decided yet. I think we can ignore/deprecate it as long as we support the "exports": {
"node": "./node-impl.js",
"browser": "./browser-impl.js"
} |
@mgol Actually that isn't completely true (I had some confusion with that aspect of Node ESM). The Node.js docs need better documentation in this area (cc @MylesBorins). As an example, the following "exports": {
".": "./dist/index.js",
"./": "./dist/"
}, does allow you to import from any sub path of the EDIT: For more info see nodejs/node#14970. Near the bottom of that issue I was confused, then Myles pointed out that In particular, this comment describes the actual behavior that should be documented, as well as shows an example of modifying a package's "base path" or "root path". What Myles said was only true in Node 13.1+. Prior to that, setting any value in the |
I will take a look on this |
If nodejs/node#32869 lands, this likely should include support for |
Are there any plans to support it in Webpack 4? |
No, only webpack v5 |
I've met an issue that my npm package ( how to let webpack4.x recognize exports fileds? Also I can't import through specific path(node_modules path) like |
|
I've run into an issue with this feature. Need to use |
I fully agree with @ConnorLanglois. This MUST be something overridable. If I want to use an internal API, then this is my good right to do, and I understand the consequences (that it can break or be removed at any time). It's not up to webpack to decide that I can't. FWIW, I'm trying to import |
In cases where you want to ignore the exports while package maintainers do updates, one option I am trying right now is to set the webpack config option |
Feature request
What is the expected behavior?
It would be nice if
webpack
respects"exports"
filed defined inpackage.json
and follow a new resolution strategy.What is motivation or use case for adding/changing the behavior?
This feature is just landed in
node@12.7.0
(seeproposal-pkg-exports
).How should this be implemented in your opinion?
Read
"exports"
filed and createresolve.alias
map internally (ie ifresolve.useExports = true
is turned on) using proposed resolution strategy.Allow to specify
resolve.mainFields = ['exports']
and check for this reserved keyword. If it is found then apply proposed resolution strategy.Are you willing to work on this yourself?
no
The text was updated successfully, but these errors were encountered: