-
-
Notifications
You must be signed in to change notification settings - Fork 2.3k
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
Parcel 2: mainFields ordering leads to duplicated dependencies in bundle #4879
Comments
You have probably seen the comment in the sourcecode? parcel/packages/resolvers/default/src/DefaultResolver.js Lines 20 to 21 in afc2c9e
|
@mischnic right, that's what I'm referring to when I say that the current behavior is to choose |
bump |
@devongovett @mischnic maybe we should discuss this now that transformation is faster? Should probably back it up with performance metrics. |
🐛 bug report
When running
parcel serve
, by default themainFields
order (unexpectedly) appears to be:This ordering can lead to broken builds when importing standalone esm modules from packages that also include
main
andmodule
entries. For example, thethree
package definesmain
entry as "/build/three.js" andmodule
entry as "/build/three.module.js", whereas the standalone modules in "three/examples/jsm/**/*" import from`three.module.js".So when the
main
entry is prioritized overmodule
, both entries (one bundled and the other unbundled) end up being included in the same application. These duplicated dependencies can cause subtle and very hard to track down problems due to (for example) duplicate singleton instances being referenced (each with their own state) in different places as if they were the same instance. I would expect that onlybuild/three.module.js
is included.More so, due to an inconsistency in behavior related to the
scopeHoist
option betweenparcel serve
andparcel build
, this problem only occurs when runningparcel serve
.When running
parcel build
, thescopeHoist
option is enabled which changes themainFields
order to the (more reasonable/expected):I would expect to have
module
preferred overmain
in all cases (by default), which would enable nested esm imports in threejs to work consistently.The text was updated successfully, but these errors were encountered: