Skip to content
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

Support parallel bundle imports in libraries #9156

Merged
merged 2 commits into from
Aug 1, 2023
Merged

Conversation

devongovett
Copy link
Member

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 parcelRequire to access dependencies in other bundles rather than using import or require. 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.

for (let b of this.bundleGraph.getReferencedBundles(this.bundle)) {
let entry = b.getMainEntry();
let symbols = new Map();
if (entry && !this.isAsyncBundle && entry.type === 'js') {
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@parcel-benchmark
Copy link

parcel-benchmark commented Jul 26, 2023

Benchmark Results

Kitchen Sink ✅

Timings

Description Time Difference
Cold 1.67s +12.00ms
Cached 284.00ms -24.00ms 🚀

Cold Bundles

Bundle Size Difference Time Difference
dist/legacy/index.7d75205b.js 1.63kb +0.00b 379.00ms -36.00ms 🚀
dist/legacy/index.d20f91ee.js 1.19kb +0.00b 377.00ms -38.00ms 🚀
dist/modern/index.1ee30fe4.js 1.12kb +0.00b 377.00ms -38.00ms 🚀

Cached Bundles

No bundle changes detected.

React HackerNews ✅

Timings

Description Time Difference
Cold 4.62s -9.00ms
Cached 444.00ms +13.00ms

Cold Bundles

Bundle Size Difference Time Difference
dist/index.js 460.80kb +0.00b 1.13s -67.00ms 🚀
dist/PermalinkedComment.b41e2791.js 4.07kb +0.00b 393.00ms -20.00ms 🚀

Cached Bundles

Bundle Size Difference Time Difference
dist/PermalinkedComment.b41e2791.js 4.07kb +0.00b 475.00ms +92.00ms ⚠️
dist/UserProfile.2a2fa310.js 1.51kb +0.00b 474.00ms +91.00ms ⚠️
dist/NotFound.13a965e5.js 399.00b +0.00b 474.00ms +91.00ms ⚠️
dist/logo.8dd07848.png 244.00b +0.00b 401.00ms +89.00ms ⚠️

AtlasKit Editor ✅

Timings

Description Time Difference
Cold 42.74s -1.17s
Cached 2.60s +133.00ms ⚠️

Cold Bundles

Bundle Size Difference Time Difference
dist/index.a15370a3.js 3.79mb +2.22kb ⚠️ 19.43s -639.00ms
dist/media-viewer.6b8adda1.js 537.45kb +155.00b ⚠️ 13.77s +3.07s ⚠️
dist/popup.c282bed0.js 324.59kb +13.00b ⚠️ 13.78s -319.00ms
dist/ConfigPanelFieldsLoader.54b2cecc.js 306.94kb +377.00b ⚠️ 9.70s -1.01s 🚀
dist/EmojiPickerComponent.1a5571cb.js 189.81kb +69.00b ⚠️ 13.78s -254.00ms
dist/card.583a1f18.js 140.31kb +69.00b ⚠️ 9.70s -1.00s 🚀
dist/esm.1c9ef78b.js 63.49kb +26.00b ⚠️ 13.78s -320.00ms
dist/ElementBrowser.8e866a0e.js 62.33kb +0.00b 9.70s -1.01s 🚀
dist/archive.a2217524.js 60.29kb +0.00b 13.78s +3.08s ⚠️
dist/esm.1a044825.js 59.85kb +69.00b ⚠️ 9.70s -1.01s 🚀
dist/component.57c841e4.js 57.99kb -91.00b 🚀 6.19s -279.00ms
dist/DatePicker.9c23032b.js 47.98kb +0.00b 7.15s -458.00ms 🚀
dist/esm.3fa8c7de.js 39.56kb +69.00b ⚠️ 13.78s -320.00ms
dist/DatePicker.a3ad9fca.js 25.15kb +0.00b 7.15s -458.00ms 🚀
dist/ConfigPanelFieldsLoader.3cdf42ed.js 15.95kb +0.00b 9.70s -1.00s 🚀
dist/ui.f919792f.js 14.62kb +0.00b 9.70s -1.01s 🚀
dist/ConfigPanelFieldsLoader.0c1e88b7.js 13.78kb +0.00b 9.70s -1.01s 🚀
dist/pdfRenderer.187ba54d.js 12.21kb +0.00b 9.70s -1.00s 🚀
dist/mobile-upload.41e1ddfc.js 7.99kb +0.00b 9.70s -1.01s 🚀
dist/mobile-upload.f2b8a53f.js 7.99kb +0.00b 9.70s -1.01s 🚀
dist/uk.48c97550.js 2.89kb +0.00b 9.70s -1.00s 🚀
dist/codeViewerRenderer.f99075be.js 2.74kb +0.00b 13.77s +3.08s ⚠️
dist/th.31044730.js 2.73kb +0.00b 9.70s -1.00s 🚀
dist/ResourcedEmojiComponent.1ec35575.js 2.60kb +0.00b 7.15s -458.00ms 🚀
dist/pl.5f36d63e.js 2.38kb +0.00b 7.15s -458.00ms 🚀
dist/cs.971d1d60.js 2.36kb +0.00b 7.15s -458.00ms 🚀
dist/de.6efbb375.js 2.30kb +0.00b 7.15s -459.00ms 🚀
dist/fr.af2c92ae.js 2.25kb +0.00b 7.15s -458.00ms 🚀
dist/es.23f0c164.js 2.25kb +0.00b 7.15s -459.00ms 🚀
dist/hu.8323f36b.js 2.23kb +0.00b 7.15s -457.00ms 🚀
dist/fi.7ed4b1b5.js 2.22kb +0.00b 7.15s -458.00ms 🚀
dist/ja.5653161c.js 2.22kb +0.00b 7.15s -457.00ms 🚀
dist/vi.d8dcb67a.js 2.22kb +0.00b 9.70s -1.00s 🚀
dist/pt_BR.eccfad73.js 2.19kb +0.00b 7.15s -459.00ms 🚀
dist/tr.46f26598.js 2.16kb +0.00b 9.70s -1.00s 🚀
dist/ko.2cf2bbda.js 2.11kb +0.00b 7.15s -457.00ms 🚀
dist/sv.13d93533.js 2.10kb +0.00b 9.70s -1.00s 🚀
dist/it.601d375a.js 2.10kb +0.00b 7.15s -457.00ms 🚀
dist/nb.b300dd3e.js 2.09kb +0.00b 7.15s -458.00ms 🚀
dist/date.7b2f9581.js 2.07kb +0.00b 6.47s -353.00ms 🚀
dist/da.21385cf2.js 2.07kb +0.00b 7.15s -458.00ms 🚀
dist/nl.3999ea58.js 2.07kb +0.00b 7.15s -458.00ms 🚀
dist/images.46c877f3.js 2.03kb +0.00b 6.47s -353.00ms 🚀
dist/zh_TW.afaf6222.js 1.98kb +0.00b 9.70s -1.00s 🚀
dist/zh.fcdc32bb.js 1.96kb +0.00b 9.70s -1.00s 🚀
dist/feedback.fd1f6260.js 1.89kb +0.00b 7.15s -459.00ms 🚀
dist/status.6f638b3d.js 1.80kb +0.00b 6.47s -354.00ms 🚀
dist/code.ef3dfa9c.js 1.69kb +0.00b 6.47s -353.00ms 🚀
dist/workerHasher.4b89e1de.js 1.69kb +0.00b 9.70s -1.01s 🚀
dist/workerHasher.06536d4e.js 1.69kb +0.00b 9.70s -1.01s 🚀
dist/list-number.35bc7f17.js 1.60kb +0.00b 6.47s -353.00ms 🚀
dist/heading6.974f167d.js 1.49kb +0.00b 7.15s -459.00ms 🚀
dist/heading3.9ad47cbe.js 1.48kb +0.00b 6.47s -361.00ms 🚀
dist/link.542e87bf.js 1.41kb +0.00b 6.47s -354.00ms 🚀
dist/emoji.79757e2c.js 1.38kb +0.00b 6.47s -353.00ms 🚀
dist/heading5.023a8f1f.js 1.36kb +0.00b 7.15s -458.00ms 🚀
dist/expand.801fc3a0.js 1.31kb +0.00b 7.15s -459.00ms 🚀
dist/heading2.bffcdf12.js 1.30kb +0.00b 6.47s -361.00ms 🚀
dist/heading4.05995ed9.js 1.25kb +0.00b 6.47s -362.00ms 🚀
dist/mention.adafe481.js 1.21kb +0.00b 6.47s -353.00ms 🚀
dist/layout.40f6b132.js 1.17kb +0.00b 6.47s -354.00ms 🚀
dist/divider.616b37d8.js 1.17kb +0.00b 6.47s -353.00ms 🚀
dist/action.361730a6.js 1.15kb +0.00b 6.47s -353.00ms 🚀
dist/heading1.495af5dc.js 1.14kb +0.00b 6.47s -354.00ms 🚀
dist/list.c5ad55b6.js 1.11kb +0.00b 6.47s -353.00ms 🚀
dist/quote.235ab420.js 1.11kb +0.00b 6.47s -353.00ms 🚀
dist/decision.36a0b771.js 1.10kb +0.00b 6.47s -353.00ms 🚀
dist/panel-warning.7e72ad42.js 1.07kb +0.00b 6.47s -353.00ms 🚀
dist/16.0d8c3c9e.js 1.06kb +0.00b 6.47s -354.00ms 🚀
dist/table.389f0908.js 1.05kb +0.00b 6.47s -354.00ms 🚀
dist/panel.7cee1972.js 1017.00b +0.00b 6.47s -352.00ms 🚀
dist/panel-error.e46252ff.js 994.00b +0.00b 6.47s -353.00ms 🚀
dist/16.dcf139e7.js 951.00b +0.00b 6.47s -354.00ms 🚀
dist/panel-success.dbd2515b.js 935.00b +0.00b 6.47s -353.00ms 🚀
dist/panel-note.b6c94ff5.js 925.00b +0.00b 6.47s -353.00ms 🚀
dist/16.f6395317.js 876.00b +0.00b 6.47s -353.00ms 🚀
dist/sk.101f1705.js 786.00b +0.00b 9.70s -1.00s 🚀
dist/pt_PT.402f9c4e.js 765.00b +0.00b 7.15s -458.00ms 🚀
dist/et.69382942.js 763.00b +0.00b 7.15s -459.00ms 🚀
dist/simpleHasher.8b7def87.js 719.00b +0.00b 9.70s -1.01s 🚀
dist/simpleHasher.38195df7.js 719.00b +0.00b 9.70s -1.01s 🚀
dist/is.5b945719.js 625.00b +0.00b 7.15s -457.00ms 🚀
dist/ro.a6eff34a.js 612.00b +0.00b 9.70s +2.08s ⚠️
dist/en_GB.61f7112a.js 602.00b +0.00b 7.15s -459.00ms 🚀
dist/en.41261459.js 599.00b +0.00b 7.15s -458.00ms 🚀
dist/index.html 240.00b +0.00b 13.83s +7.00s ⚠️

Cached Bundles

Bundle Size Difference Time Difference
dist/index.a15370a3.js 3.79mb +2.22kb ⚠️ 19.53s +326.00ms
dist/media-viewer.6b8adda1.js 537.45kb +155.00b ⚠️ 13.38s +3.68s ⚠️
dist/popup.c282bed0.js 324.59kb +13.00b ⚠️ 13.38s +18.00ms
dist/ConfigPanelFieldsLoader.54b2cecc.js 306.94kb +377.00b ⚠️ 9.37s -331.00ms
dist/EmojiPickerComponent.1a5571cb.js 189.81kb +69.00b ⚠️ 13.35s -0.00ms
dist/card.583a1f18.js 140.31kb +69.00b ⚠️ 12.27s +2.57s ⚠️
dist/esm.1c9ef78b.js 63.49kb +26.00b ⚠️ 13.38s +18.00ms
dist/archive.a2217524.js 60.29kb +0.00b 13.38s +3.68s ⚠️
dist/esm.1a044825.js 59.85kb +69.00b ⚠️ 12.28s +2.57s ⚠️
dist/component-lazy.1b33c14d.js 59.63kb +0.00b 6.16s -758.00ms 🚀
dist/component.57c841e4.js 57.99kb -91.00b 🚀 5.80s -72.00ms
dist/esm.3fa8c7de.js 39.56kb +69.00b ⚠️ 13.38s +18.00ms
dist/pdfRenderer.187ba54d.js 12.21kb +0.00b 13.14s +3.44s ⚠️
dist/mobile-upload.f2b8a53f.js 7.99kb +0.00b 12.28s +2.57s ⚠️
dist/media-viewer-analytics-error-boundary.c1511b0d.js 3.32kb +0.00b 13.38s +3.68s ⚠️
dist/ru.896915b9.js 2.94kb +0.00b 9.36s +2.44s ⚠️
dist/codeViewerRenderer.f99075be.js 2.74kb +0.00b 13.14s +3.44s ⚠️
dist/pl.5f36d63e.js 2.38kb +0.00b 8.01s +1.09s ⚠️
dist/ja.5653161c.js 2.22kb +0.00b 8.01s +1.09s ⚠️
dist/pt_BR.eccfad73.js 2.19kb +0.00b 8.01s +1.09s ⚠️
dist/ko.2cf2bbda.js 2.11kb +0.00b 8.01s +1.09s ⚠️
dist/nb.b300dd3e.js 2.09kb +0.00b 8.01s +1.09s ⚠️
dist/nl.3999ea58.js 2.07kb +0.00b 8.01s +1.09s ⚠️
dist/workerHasher.06536d4e.js 1.69kb +0.00b 12.28s +2.57s ⚠️
dist/heading5.023a8f1f.js 1.36kb +0.00b 6.87s +708.00ms ⚠️
dist/pt_PT.402f9c4e.js 765.00b +0.00b 8.01s +1.09s ⚠️
dist/simpleHasher.38195df7.js 719.00b +0.00b 12.28s +2.57s ⚠️
dist/ro.a6eff34a.js 612.00b +0.00b 8.01s +1.09s ⚠️
dist/index.html 240.00b +0.00b 13.44s +7.54s ⚠️

Three.js ✅

Timings

Description Time Difference
Cold 3.54s +6.00ms
Cached 355.00ms -11.00ms

Cold Bundles

No bundle changes detected.

Cached Bundles

No bundle changes detected.

Click here to view a detailed benchmark overview.

@@ -505,6 +505,7 @@ function createIdealGraph(
*/
let bundleGroupRootAsset = nullthrows(bundleGroup.mainEntryAsset);
if (
parentAsset.type !== childAsset.type &&
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

@devongovett devongovett merged commit 4b83234 into v2 Aug 1, 2023
14 of 16 checks passed
@devongovett devongovett deleted the library-parallel-deps branch August 1, 2023 17:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants