When a package.json contains both "exports" and "browser" fields, which one wins in Webpack 5? #12435
Replies: 4 comments 9 replies
-
Can you provide example? |
Beta Was this translation helpful? Give feedback.
-
For example if I
Will Webpack resolve the import to |
Beta Was this translation helpful? Give feedback.
-
Okay. Then if we have (real example from
Then |
Beta Was this translation helpful? Give feedback.
-
Now let's say we
It would be an error because |
Beta Was this translation helpful? Give feedback.
-
The docs say
Which seems to suggest that the
"browser"
field would be ignored if"exports"
is present, but it seems like Webpack 5 with default config is still resolving with the"browser"
field in some experimentation I did on theyaml
package. If this is unintended behavior I could try to fully verify this and create an issue.It would be good to explicitly document whether
"exports"
or"browser"
in the docs for both fields. It's starting to get really complicated to guess the resolution behavior.Beta Was this translation helpful? Give feedback.
All reactions