Description
Do you want to request a feature or report a bug?
bug
What is the current behavior?
Webpack prioritizes the browser
field in a package.json, over the module
field (if both are passed)
See:
webpack/lib/WebpackOptionsDefaulter.js
Lines 108 to 113 in 978e9f9
If the current behavior is a bug, please provide the steps to reproduce.
Created two gists, a module and a consumer. They are available here:
- module: https://gist.github.com/jshcrowthe/acea97f8b18e81c0a797137b8a38f1e4
- consumer: https://gist.github.com/jshcrowthe/64ec07274e4ac966b3e116078c586dfa
Repro Steps:
git clone https://gist.github.com/jshcrowthe/64ec07274e4ac966b3e116078c586dfa
cd 64ec07274e4ac966b3e116078c586dfa
npm install
npm start
- Open browser and navigate to webpack-dev-server URL
- Observe console logs, should look something like the following:
What is the expected behavior?
Webpack should prioritize the pkg.module
field over pkg.browser
. Browserify also relies on the pkg.browser
but does not have support for ES Modules. Seeing as webpack is able to more intelligently parse the ES Module bundles, it should prioritize that bundle if available.
NOTE: I am aware that you can change the resolve.mainFields
to modify this however you'd like. I'm suggesting that the default behavior should be changed
If this is a feature request, what is motivation or use case for changing the behavior?
n/a
Please mention other relevant information such as the browser version, Node.js version, webpack version and Operating System.
- Webpack: 3.5.6
- Node.js: 8.4.0
- NPM: 5.4.1
- Yarn: 1.0.1
- OS: macOS 10.12.6