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

Deduplicate imports in hoist transformer #8954

Merged
merged 2 commits into from
Apr 21, 2023
Merged

Conversation

mischnic
Copy link
Member

Previously,

import "./b.js";
import "./b.js";
import "./b.js";
import { v1 } from "./b.js";
import { v2 } from "./b.js";
import { v3 } from "./b.js";

export var result = v1 + v2 + v3;

would be transformed to

import "05d3ea58fa452475:./b.js:esm";
import "05d3ea58fa452475:./b.js:esm"; // unneeded
import "05d3ea58fa452475:./b.js:esm"; // unneeded
import "05d3ea58fa452475:./b.js:esm"; // unneeded
import "05d3ea58fa452475:./b.js:esm"; // unneeded
import "05d3ea58fa452475:./b.js:esm"; // unneeded
var $05d3ea58fa452475$export$aaf36426b5008f7a = (0, $05d3ea58fa452475$import$3e6e1c8e3d0d0b77$11cb33cb3c138832) + (0,
$05d3ea58fa452475$import$3e6e1c8e3d0d0b77$8815aa1d021a7d50) + (0, $05d3ea58fa452475$import$3e6e1c8e3d0d0b77$815b03eba529a08e);

which got packaged into

parcelRequire.register("v1jxS", function(module, exports) {
$parcel$export(module.exports, "result", () => $05d3ea58fa452475$export$aaf36426b5008f7a);

var $hiPYL = parcelRequire("hiPYL");
var $hiPYL = parcelRequire("hiPYL");
var $hiPYL = parcelRequire("hiPYL");
var $hiPYL = parcelRequire("hiPYL");
var $hiPYL = parcelRequire("hiPYL");
var $hiPYL = parcelRequire("hiPYL");
var $05d3ea58fa452475$export$aaf36426b5008f7a = (0, $hiPYL.v1) + (0, $hiPYL.v2) + (0, $hiPYL.v3);
});

Now the transformer doesn't insert these hoisted import "05d3ea58fa452475:./b.js:esm"; declarations multiple times anymore.

@parcel-benchmark
Copy link

Benchmark Results

Kitchen Sink ✅

Timings

Description Time Difference
Cold 1.41s -17.00ms
Cached 313.00ms -5.00ms

Cold Bundles

Bundle Size Difference Time Difference
dist/legacy/index.b8ae99ba.css 94.00b +0.00b 216.00ms -11.00ms 🚀
dist/modern/index.31cedca9.css 94.00b +0.00b 216.00ms -11.00ms 🚀

Cached Bundles

Bundle Size Difference Time Difference
dist/modern/parcel.7cdb0fad.webp 102.94kb +0.00b 212.00ms -12.00ms 🚀
dist/legacy/index.7d75205b.js 1.63kb +0.00b 342.00ms -26.00ms 🚀
dist/legacy/index.d20f91ee.js 1.19kb +0.00b 342.00ms -27.00ms 🚀
dist/modern/index.1ee30fe4.js 1.12kb +0.00b 342.00ms -28.00ms 🚀
dist/legacy/index.html 826.00b +0.00b 383.00ms -37.00ms 🚀
dist/modern/index.html 749.00b +0.00b 383.00ms -35.00ms 🚀
dist/legacy/index.b8ae99ba.css 94.00b +0.00b 220.00ms -12.00ms 🚀
dist/modern/index.31cedca9.css 94.00b +0.00b 220.00ms -11.00ms

React HackerNews ✅

Timings

Description Time Difference
Cold 6.85s -18.00ms
Cached 422.00ms -19.00ms

Cold Bundles

No bundle changes detected.

Cached Bundles

No bundle changes detected.

AtlasKit Editor ✅

Timings

Description Time Difference
Cold 1.01m -1.29s
Cached 1.98s +52.00ms

Cold Bundles

Bundle Size Difference Time Difference
dist/index.9f855f80.js 3.83mb -1.05kb 🚀 14.62s -377.00ms
dist/pdfRenderer.4f3765de.js 1.11mb +0.00b 10.68s -706.00ms 🚀
dist/editorView.19055bae.js 622.48kb -143.00b 🚀 11.78s -360.00ms
dist/refractor.c460668c.js 601.81kb +0.00b 9.98s -638.00ms 🚀
dist/media-viewer.bd165005.js 542.15kb -210.00b 🚀 7.13s -400.00ms 🚀
dist/popup.8679a203.js 329.78kb -325.00b 🚀 9.98s -640.00ms 🚀
dist/ConfigPanelFieldsLoader.f06a6b36.js 312.08kb -39.00b 🚀 7.13s -400.00ms 🚀
dist/EmojiPickerComponent.a25bd8e7.js 196.67kb -156.00b 🚀 9.97s -587.00ms 🚀
dist/card.501ecffa.js 143.52kb -117.00b 🚀 7.13s -400.00ms 🚀
dist/ConfigPanelFieldsLoader.e1ae433f.js 83.45kb -63.00b 🚀 7.13s -400.00ms 🚀
dist/mobile-upload.f055fc7f.js 66.66kb -26.00b 🚀 4.62s -4.00ms
dist/ElementBrowser.3bcad544.js 65.85kb +0.00b 7.13s -400.00ms 🚀
dist/esm.6df2a542.js 64.51kb -26.00b 🚀 9.98s -639.00ms 🚀
dist/archive.b919f1ad.js 61.47kb -13.00b 🚀 9.98s +2.45s ⚠️
dist/esm.945b66be.js 60.94kb -26.00b 🚀 7.13s -400.00ms 🚀
dist/component-lazy.60375b05.js 60.45kb -26.00b 🚀 5.28s -144.00ms
dist/component.e578d640.js 58.27kb -13.00b 🚀 4.60s -20.00ms
dist/esm.bd488cd8.js 40.24kb -13.00b 🚀 9.97s -643.00ms 🚀
dist/Modal.4be3b837.js 28.46kb -13.00b 🚀 4.61s +9.00ms
dist/smartMediaEditor.8713e5a6.js 22.24kb -13.00b 🚀 9.97s -643.00ms 🚀
dist/esm.a10f92b5.js 21.06kb -13.00b 🚀 9.97s -644.00ms 🚀
dist/ConfigPanelFieldsLoader.ef739802.js 16.14kb +0.00b 7.13s -401.00ms 🚀
dist/ui.2de0ef21.js 14.88kb +0.00b 7.13s -400.00ms 🚀
dist/ConfigPanelFieldsLoader.c68d84ab.js 14.25kb +0.00b 7.13s -400.00ms 🚀
dist/dropzone.4b8113c9.js 14.00kb +0.00b 9.98s -639.00ms 🚀
dist/pdfRenderer.187ba54d.js 12.21kb +0.00b 7.13s -400.00ms 🚀
dist/dropzone.ae8c8d79.js 11.95kb +0.00b 9.98s -639.00ms 🚀
dist/Toolbar.7fda8a1b.js 9.30kb -26.00b 🚀 9.97s -643.00ms 🚀
dist/clipboard.ef3ddc39.js 8.22kb +0.00b 9.98s -639.00ms 🚀
dist/mobile-upload.136dd5cb.js 8.08kb +0.00b 7.13s -400.00ms 🚀
dist/mobile-upload.0bdb676c.js 8.08kb +0.00b 7.13s -402.00ms 🚀
dist/mobile-upload.31f0e326.js 8.08kb +0.00b 9.97s -644.00ms 🚀
dist/browser.0a7fd453.js 7.48kb +0.00b 9.98s -641.00ms 🚀
dist/index.b2eab848.js 7.32kb +0.00b 9.97s -643.00ms 🚀
dist/index.b16227d6.css 4.08kb +0.00b 9.98s -645.00ms 🚀
dist/media-viewer-analytics-error-boundary.e6109a6a.js 3.46kb +0.00b 9.98s +2.45s ⚠️
dist/media-picker-analytics-error-boundary.627962a5.js 3.46kb +0.00b 9.98s -640.00ms 🚀
dist/media-card-analytics-error-boundary.ec5ff8ee.js 3.45kb +0.00b 9.98s -638.00ms 🚀
dist/ru.896915b9.js 2.94kb +0.00b 7.13s +992.00ms ⚠️
dist/uk.48c97550.js 2.89kb +0.00b 7.13s -400.00ms 🚀
dist/codeViewerRenderer.915ef6b3.js 2.84kb +0.00b 9.98s +2.45s ⚠️
dist/th.31044730.js 2.73kb +0.00b 7.13s -400.00ms 🚀
dist/ResourcedEmojiComponent.04d67e5e.js 2.69kb -13.00b 🚀 5.28s -141.00ms
dist/pl.5f36d63e.js 2.38kb +0.00b 5.28s -855.00ms 🚀
dist/vi.d8dcb67a.js 2.22kb +0.00b 7.13s -400.00ms 🚀
dist/pt_BR.eccfad73.js 2.19kb +0.00b 5.28s -855.00ms 🚀
dist/tr.46f26598.js 2.16kb +0.00b 7.13s -400.00ms 🚀
dist/sv.13d93533.js 2.10kb +0.00b 7.13s -400.00ms 🚀
dist/nb.b300dd3e.js 2.09kb +0.00b 5.28s -855.00ms 🚀
dist/nl.3999ea58.js 2.07kb +0.00b 5.28s -855.00ms 🚀
dist/zh_TW.afaf6222.js 1.98kb +0.00b 7.13s -400.00ms 🚀
dist/zh.fcdc32bb.js 1.96kb +0.00b 7.13s -400.00ms 🚀
dist/workerHasher.ef49a7fc.js 1.72kb +0.00b 7.13s -400.00ms 🚀
dist/workerHasher.9d5fe27b.js 1.72kb +0.00b 7.13s -400.00ms 🚀
dist/workerHasher.13de9709.js 1.72kb +0.00b 9.98s -639.00ms 🚀
dist/workerHasher.99c37306.js 1.72kb +0.00b 9.97s -643.00ms 🚀
dist/workerHasher.c5ba46bc.js 1.72kb +0.00b 9.97s -643.00ms 🚀
dist/heading5.023a8f1f.js 1.36kb +0.00b 5.28s +427.00ms ⚠️
dist/sk.101f1705.js 786.00b +0.00b 7.13s -400.00ms 🚀
dist/pt_PT.402f9c4e.js 765.00b +0.00b 5.28s -855.00ms 🚀
dist/simpleHasher.f1f58b0a.js 687.00b +0.00b 7.13s -400.00ms 🚀
dist/simpleHasher.09f4d713.js 687.00b +0.00b 7.13s -400.00ms 🚀
dist/simpleHasher.a19114f9.js 687.00b +0.00b 9.98s -639.00ms 🚀
dist/simpleHasher.023b58fa.js 687.00b +0.00b 9.97s -643.00ms 🚀
dist/simpleHasher.97222d8a.js 687.00b +0.00b 9.97s -643.00ms 🚀
dist/ro.a6eff34a.js 612.00b +0.00b 7.13s +991.00ms ⚠️
dist/index.html 240.00b +0.00b 10.01s +5.47s ⚠️

Cached Bundles

Bundle Size Difference Time Difference
dist/index.9f855f80.js 3.83mb -1.05kb 🚀 14.62s -77.00ms
dist/pdfRenderer.4f3765de.js 1.11mb +0.00b 11.39s +583.00ms ⚠️
dist/editorView.19055bae.js 622.48kb -143.00b 🚀 11.89s +335.00ms
dist/media-viewer.bd165005.js 542.15kb -210.00b 🚀 9.89s +1.66s ⚠️
dist/popup.8679a203.js 329.78kb -325.00b 🚀 9.92s +436.00ms
dist/ConfigPanelFieldsLoader.f06a6b36.js 312.08kb -39.00b 🚀 7.13s +32.00ms
dist/EmojiPickerComponent.a25bd8e7.js 196.67kb -156.00b 🚀 9.93s +1.70s ⚠️
dist/card.501ecffa.js 143.52kb -117.00b 🚀 9.86s +2.77s ⚠️
dist/ConfigPanelFieldsLoader.e1ae433f.js 83.45kb -63.00b 🚀 7.13s +31.00ms
dist/mobile-upload.f055fc7f.js 66.66kb -26.00b 🚀 4.56s +35.00ms
dist/esm.6df2a542.js 64.51kb -26.00b 🚀 9.92s +436.00ms
dist/archive.b919f1ad.js 61.47kb -13.00b 🚀 9.93s +430.00ms
dist/esm.945b66be.js 60.94kb -26.00b 🚀 7.12s +35.00ms
dist/component-lazy.60375b05.js 60.45kb -26.00b 🚀 5.35s +65.00ms
dist/component.e578d640.js 58.27kb -13.00b 🚀 4.53s -2.00ms
dist/esm.bd488cd8.js 40.24kb -13.00b 🚀 9.92s +422.00ms
dist/Modal.4be3b837.js 28.46kb -13.00b 🚀 4.53s +12.00ms
dist/smartMediaEditor.8713e5a6.js 22.24kb -13.00b 🚀 9.92s +424.00ms
dist/esm.a10f92b5.js 21.06kb -13.00b 🚀 9.92s +424.00ms
dist/pdfRenderer.187ba54d.js 12.21kb +0.00b 9.93s +2.83s ⚠️
dist/Toolbar.7fda8a1b.js 9.30kb -26.00b 🚀 9.93s +437.00ms
dist/ResourcedEmojiComponent.04d67e5e.js 2.69kb -13.00b 🚀 5.35s +62.00ms
dist/pt_BR.eccfad73.js 2.19kb +0.00b 6.66s +1.38s ⚠️
dist/heading3.9ad47cbe.js 1.48kb +0.00b 5.31s +564.00ms ⚠️
dist/heading4.05995ed9.js 1.25kb +0.00b 5.31s +563.00ms ⚠️
dist/pt_PT.402f9c4e.js 765.00b +0.00b 6.66s +1.38s ⚠️

Three.js ✅

Timings

Description Time Difference
Cold 4.83s -8.00ms
Cached 254.00ms -0.00ms

Cold Bundles

No bundle changes detected.

Cached Bundles

No bundle changes detected.

Click here to view a detailed benchmark overview.

@mischnic mischnic merged commit e38fcf7 into v2 Apr 21, 2023
@mischnic mischnic deleted the hoist-deduplicate-imports branch April 21, 2023 07:37
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.

3 participants