Closed leo-buneev closed 4 years ago
Thanks for raising this, the default value of honorPackage
was set to maintain backward compatibility so projects started with older version of this plugin continues to work after upgrading the plugin.
Ah, fair enough.
Then you can close this issue (not surer if it's better to close it or leave it open) - if somebody else will have problems, they will stumble upon this issue and see the solution.
For the record, to have default webpack resolution behavior, you need to set honorPackage: ['browser', 'module', 'main']
Webpack allows to customize "resolve.mainFields" for package.json - https://webpack.js.org/configuration/resolve/#resolvemainfields
Adding this plugin overrides
resolve.mainFields
with it'shonorPackage
, which is['main']
by default.In my case I was building app for browser, but needed to include
node-fetch
. In it's package.json it hasmain
pointing to node.js version, andbrowser
pointing to browser version.Directory-named-webpack-plugin makes webpack prioritize
main
overbrowser
in this case, which is wrong.It is easy to fix it with correct
honorPackage
setting, but think it would be good ifhonorPackage
defaulted towebpack.config.mainFields