Honor "browser" field?
Conrad2134 opened this issue · 3 comments
When honorPackage
is true, this plugin honors the main
field in the package.json before anything else.
Should this plugin be enhanced to respect the browser
field, as well?
Since Webpack is configured to target the "browser" field first by default (when running with target: "web"
, it makes sense that browser
would be honored, as well. I recently ran into an issue with Webpack HMR with this. For the "inherits" package that SockJS uses, it lists inherits/inherits.js
under main
and inherits/inherits_browser.js
under browser
. Since I'm running my bundle in the browser, I need the file from the browser
field.
Edit:
Also, not mentioned above, but it should also respect the order of the Webpack resolve.mainFields
array - we wouldn't want it grabbing main
first if Webpack is asking for browser
first.
Yeah, makes sense. I'll try to get this fixed asap.
I made some changes to support supplying an array of main fields as the value of honorPackage
option.
Was thinking to get resolve.mainFields
of current Webpack compilation so it aligns with Webpack's behaviour, but didn't find a way to do that, didn't have much time last several days. So fallback to allow it to be specified. Will look into it further when have more time. If you have some ideas and hints about that, that'd be great.
Thanks for taking care of that, @shaketbaby!