-
-
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
Inlining shared, small modules can yield non-standard behavior #4302
Comments
The second script tag would have to import that shared module from the first script tag (a mechanism for that exists already). But sharing local variables between the script tags is still something we wouldn't support (what do you think?) (How I think we could implement it)I think taking all the script tags as one bundlegroup and each script tag as a bundle would automatically cause that behavior. Currently we completely ignore that fact that these bundles are actually related (so two script tags behave just like two worker calls - which is quite a simplification).
Here (that plugin handles all the chunking): https://github.com/parcel-bundler/parcel/blob/v2/packages/bundlers/default/src/DefaultBundler.js#L10 |
The reason I bring this up is because it would behave differently with 2 It feels unexpected (and undesirable) to me that behavior would change because I ran parcel. |
I agree that running Parcel shouldn't change the behaviour of the code. |
Should be fixed by #4786. Parcel will now deduplicate common modules between multiple script tags. |
🐛 bug report
If you have 2
<script>
tags that share a dependency, that dependency will get chunked out if it is above a certain size (is this size threshold documented somewhere?).However, this can yield non-standard behavior compared to using normal ES modules. For example, exporting an object, all importers will get a reference to the same object. So one function change the object, other importers should see those changes.
🎛 Configuration (.babelrc, package.json, cli command)
Please see repro repo
🤔 Expected Behavior
obj.js
should land in its own chunk.😯 Current Behavior
obj.js
is inlined into bothcomponent-1.js
andcomponent-2.js
.💁 Possible Solution
See “Expected Behavior”.
🔦 Context
E.g: A module exporting a global config object that gets augmented by other modules.
💻 Code Sample
Please see repro repo
🌍 Your Environment
The text was updated successfully, but these errors were encountered: