-
-
Notifications
You must be signed in to change notification settings - Fork 8.7k
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 exportsFields and conditionNames options #10953
Conversation
For maintainers only:
|
remove extra layer, use concatenated key instead
- byDependency option - create resolver per dependency category
Thank you for your pull request! The most important CI builds succeeded, we’ll review the pull request soon. |
Thanks I hope it's fine... |
I've created an issue to document this in webpack/webpack.js.org. |
So, I’ve got a module that uses the export map in order to support Since compilers do not yet support export maps I’m still using the top level I’m wondering if this is going to break my current setup or not. Does the top level To be clear, I’m fine with changing my configuration in order to upgrade, I’m using this early enough that I don’t think breaking me here is a reason to hold up this PR, I’m just trying to figure out what the change might need to be and what the rules are for which fields win. |
@mikeal i would expect that for max compat, you'd want to include both a toplevel "browser" field as well as a "browser" condition for each relevant entry point, and that they'd agree such that it didn't matter which one "won". I would expect regardless, that the top level "browser" field would be a final transformation applied to the final "exports" resolution, and that they should thus be transparently compatible. |
From Node.js docs. So for Many developers start to use |
@mikeal I had a similar issue and this is what I ended up with:
The different builds:
How environments behave:
This was the result of a longer discussion in uuidjs/uuid#462 if you are interested. |
What kind of change does this PR introduce?
closes #9509
exports field feature support
Did you add tests for your changes?
Yes
Does this PR introduce a breaking change?
No
What needs to be documented once your changes are merged?
Webpack now supports exports field entrypoint.
Regarding to conditional exports webpack core supports the following conditions:
import
orimport()
require()
options.target
is node or electron environmentoptions.target
is electron environmentoptions.target
is web environmentoptions.target === "webworker"
options.mode === "development"
Added some parameters to
options.resolve
option:options.resolve.conditionNames
a list of exports field condition names, default list described above in "conditional exports" sectionoptions.resolve.exportsFields
a list of exports fields in description files, default is["exports"]
options.resolve.byDependency
extra resolve options per dependency category. Typical categories are "commonjs", "amd", "esm".This option allows to define specific resolving to each dependency category, e.g. disallow extensions for
esm
: