Support parallel bundle imports in libraries#9156
Merged
Merged
Conversation
devongovett
commented
Jul 26, 2023
| for (let b of this.bundleGraph.getReferencedBundles(this.bundle)) { | ||
| let entry = b.getMainEntry(); | ||
| let symbols = new Map(); | ||
| if (entry && !this.isAsyncBundle && entry.type === 'js') { |
Member
Author
There was a problem hiding this comment.
for now async bundles in libraries are still referenced with parcelRequire. Changing that would require additional changes to the runtimes, but we could fix it eventually.
Benchmark ResultsKitchen Sink ✅
Timings
Cold Bundles
Cached BundlesNo bundle changes detected. React HackerNews ✅
Timings
Cold Bundles
Cached Bundles
AtlasKit Editor ✅
Timings
Cold Bundles
Cached Bundles
Three.js ✅
Timings
Cold BundlesNo bundle changes detected. Cached BundlesNo bundle changes detected. |
AGawrys
reviewed
Jul 26, 2023
| */ | ||
| let bundleGroupRootAsset = nullthrows(bundleGroup.mainEntryAsset); | ||
| if ( | ||
| parentAsset.type !== childAsset.type && |
AGawrys
approved these changes
Aug 1, 2023
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The scope hoisting packager makes some assumptions about how to access code in other bundles that don't hold in library builds. One of these is that it tries to use
parcelRequireto access dependencies in other bundles rather than usingimportorrequire. This PR keeps track of assets in referenced bundles and generates code to access them via the appropriate module system instead.Right now this is only possible with a custom plugin that makes dependencies parallel. There was also a small bug in the bundler preventing that from working correctly (it used to merge them all into a single bundle like type changes). Eventually we might have a separate bundler for libraries that outputs a single asset per bundle, and the packager changes in this PR should also help with that.