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

Respect Babel's addExternalDependency #7820

Merged
merged 9 commits into from Mar 26, 2023
Merged

Conversation

mischnic
Copy link
Member

@mischnic mischnic commented Mar 12, 2022

↪️ Pull Request

babel/babel#14065

Just forward api.addExternalDependency(f) to asset.invalidateOnFileChange(f)

@height
Copy link

height bot commented Mar 12, 2022

Link Height tasks by mentioning a task ID in the pull request title or commit messages, or description and comments with the keyword link (e.g. "Link T-123").

💡Tip: You can also use "Close T-X" to automatically close a task when the pull request is merged.

@parcel-benchmark
Copy link

parcel-benchmark commented Mar 12, 2022

Benchmark Results

Kitchen Sink ✅

Timings

Description Time Difference
Cold 1.43s -4.00ms
Cached 368.00ms +62.00ms ⚠️

Cold Bundles

No bundle changes detected.

Cached Bundles

Bundle Size Difference Time Difference
dist/legacy/index.7d75205b.js 1.63kb +0.00b 371.00ms +20.00ms ⚠️
dist/legacy/index.d20f91ee.js 1.19kb +0.00b 372.00ms +21.00ms ⚠️
dist/modern/index.1ee30fe4.js 1.12kb +0.00b 371.00ms +21.00ms ⚠️

React HackerNews ✅

Timings

Description Time Difference
Cold 6.82s -69.00ms
Cached 387.00ms -32.00ms 🚀

Cold Bundles

Bundle Size Difference Time Difference
dist/index.js 463.02kb +0.00b 997.00ms -80.00ms 🚀

Cached Bundles

No bundle changes detected.

AtlasKit Editor ✅

Timings

Description Time Difference
Cold 1.01m +224.00ms
Cached 2.17s +272.00ms ⚠️

Cold Bundles

Bundle Size Difference Time Difference
dist/media-viewer.bd165005.js 542.15kb +0.00b 7.40s -2.21s 🚀
dist/archive.503fa405.js 61.48kb +0.00b 7.40s -2.07s 🚀
dist/esm.945b66be.js 60.94kb +0.00b 7.39s -2.08s 🚀
dist/pdfRenderer.187ba54d.js 12.21kb +0.00b 7.39s -2.08s 🚀
dist/mobile-upload.0bdb676c.js 8.08kb +0.00b 7.39s -2.08s 🚀
dist/media-viewer-analytics-error-boundary.e6109a6a.js 3.46kb +0.00b 7.40s -2.07s 🚀
dist/ru.896915b9.js 2.94kb +0.00b 5.20s -1.03s 🚀
dist/codeViewerRenderer.915ef6b3.js 2.84kb +0.00b 7.39s -2.08s 🚀
dist/pl.5f36d63e.js 2.38kb +0.00b 5.20s -1.03s 🚀
dist/ja.5653161c.js 2.22kb +0.00b 5.20s -1.03s 🚀
dist/pt_BR.eccfad73.js 2.19kb +0.00b 5.20s -1.03s 🚀
dist/ko.2cf2bbda.js 2.11kb +0.00b 5.20s -1.03s 🚀
dist/nb.b300dd3e.js 2.09kb +0.00b 5.20s -1.03s 🚀
dist/nl.3999ea58.js 2.07kb +0.00b 5.20s -1.03s 🚀
dist/workerHasher.9d5fe27b.js 1.72kb +0.00b 7.40s -2.07s 🚀
dist/sk.101f1705.js 786.00b +0.00b 5.20s -1.03s 🚀
dist/pt_PT.402f9c4e.js 765.00b +0.00b 5.20s -1.03s 🚀
dist/simpleHasher.09f4d713.js 687.00b +0.00b 7.40s -2.07s 🚀
dist/ro.a6eff34a.js 612.00b +0.00b 5.20s -1.03s 🚀

Cached Bundles

Bundle Size Difference Time Difference
dist/index.0976f9cb.js 3.83mb +0.00b 17.16s +2.72s ⚠️
dist/pdfRenderer.4f3765de.js 1.11mb +0.00b 13.09s +2.32s ⚠️
dist/editorView.19055bae.js 622.48kb +0.00b 14.08s +2.28s ⚠️
dist/refractor.c460668c.js 601.81kb +0.00b 11.77s +2.27s ⚠️
dist/media-viewer.bd165005.js 542.15kb +0.00b 11.78s +4.60s ⚠️
dist/popup.2cbde099.js 329.78kb +0.00b 11.78s +2.27s ⚠️
dist/ConfigPanelFieldsLoader.f06a6b36.js 312.08kb +0.00b 8.42s +1.24s ⚠️
dist/EmojiPickerComponent.a25bd8e7.js 196.67kb +0.00b 11.78s +2.32s ⚠️
dist/card.501ecffa.js 143.52kb +0.00b 8.42s +1.24s ⚠️
dist/ConfigPanelFieldsLoader.e1ae433f.js 83.45kb +0.00b 8.42s +1.24s ⚠️
dist/mobile-upload.f055fc7f.js 66.66kb +0.00b 5.43s +949.00ms ⚠️
dist/ElementBrowser.3bcad544.js 65.85kb +0.00b 8.42s +1.24s ⚠️
dist/esm.6df2a542.js 64.51kb +0.00b 11.78s +2.27s ⚠️
dist/archive.503fa405.js 61.48kb +0.00b 11.77s +2.27s ⚠️
dist/esm.945b66be.js 60.94kb +0.00b 8.42s +1.24s ⚠️
dist/component-lazy.60375b05.js 60.45kb +0.00b 6.33s +1.04s ⚠️
dist/component.e578d640.js 58.27kb +0.00b 5.45s +969.00ms ⚠️
dist/DatePicker.3a60f244.js 48.38kb +0.00b 6.33s +1.04s ⚠️
dist/esm.bd488cd8.js 40.24kb +0.00b 11.77s +2.27s ⚠️
dist/Modal.4be3b837.js 28.46kb +0.00b 5.42s +960.00ms ⚠️
dist/DatePicker.b0a4d8f4.js 25.21kb +0.00b 6.33s +1.04s ⚠️
dist/smartMediaEditor.8713e5a6.js 22.24kb +0.00b 11.77s +2.27s ⚠️
dist/esm.a10f92b5.js 21.06kb +0.00b 11.77s +2.27s ⚠️
dist/component.1c22aee9.js 18.81kb +0.00b 5.44s +973.00ms ⚠️
dist/js.324be058.js 17.34kb +0.00b 5.42s +960.00ms ⚠️
dist/ConfigPanelFieldsLoader.ef739802.js 16.14kb +0.00b 8.42s +1.24s ⚠️
dist/ui.2de0ef21.js 14.88kb +0.00b 8.42s +1.24s ⚠️
dist/ConfigPanelFieldsLoader.c68d84ab.js 14.25kb +0.00b 8.42s +1.24s ⚠️
dist/dropzone.4b8113c9.js 14.00kb +0.00b 11.78s +2.27s ⚠️
dist/pdfRenderer.187ba54d.js 12.21kb +0.00b 8.42s +1.24s ⚠️
dist/dropzone.ae8c8d79.js 11.95kb +0.00b 11.78s +2.27s ⚠️
dist/Toolbar.7fda8a1b.js 9.30kb +0.00b 11.77s +2.27s ⚠️
dist/clipboard.ef3ddc39.js 8.22kb +0.00b 11.78s +2.27s ⚠️
dist/mobile-upload.93995326.js 8.08kb +0.00b 5.42s +961.00ms ⚠️
dist/mobile-upload.136dd5cb.js 8.08kb +0.00b 8.42s +1.24s ⚠️
dist/mobile-upload.0bdb676c.js 8.08kb +0.00b 8.42s +1.24s ⚠️
dist/mobile-upload.31f0e326.js 8.08kb +0.00b 11.77s +2.27s ⚠️
dist/browser.0a7fd453.js 7.48kb +0.00b 11.78s +2.27s ⚠️
dist/index.6d0e3617.js 7.32kb +0.00b 11.92s +2.42s ⚠️
dist/index.b16227d6.css 4.08kb +0.00b 11.92s +2.42s ⚠️
dist/Modal.4d03aeec.js 3.79kb +0.00b 5.42s +959.00ms ⚠️
dist/media-viewer-analytics-error-boundary.e6109a6a.js 3.46kb +0.00b 11.78s +2.27s ⚠️
dist/media-picker-analytics-error-boundary.627962a5.js 3.46kb +0.00b 11.78s +2.27s ⚠️
dist/media-card-analytics-error-boundary.ec5ff8ee.js 3.45kb +0.00b 11.77s +2.27s ⚠️
dist/component.9a535981.js 3.42kb +0.00b 5.42s +961.00ms ⚠️
dist/png-chunks-extract.c54842d7.js 3.19kb +0.00b 5.42s +962.00ms ⚠️
dist/ru.896915b9.js 2.94kb +0.00b 8.42s +1.24s ⚠️
dist/uk.48c97550.js 2.89kb +0.00b 8.42s +1.24s ⚠️
dist/codeViewerRenderer.915ef6b3.js 2.84kb +0.00b 11.78s +2.27s ⚠️
dist/th.31044730.js 2.73kb +0.00b 8.42s +1.24s ⚠️
dist/ResourcedEmojiComponent.04d67e5e.js 2.69kb +0.00b 6.33s +1.04s ⚠️
dist/pl.5f36d63e.js 2.38kb +0.00b 6.33s +1.04s ⚠️
dist/cs.971d1d60.js 2.36kb +0.00b 6.33s +1.04s ⚠️
dist/de.6efbb375.js 2.30kb +0.00b 6.33s +1.04s ⚠️
dist/fr.af2c92ae.js 2.25kb +0.00b 6.33s +1.04s ⚠️
dist/es.23f0c164.js 2.25kb +0.00b 6.33s +1.04s ⚠️
dist/hu.8323f36b.js 2.23kb +0.00b 6.33s +1.04s ⚠️
dist/fi.7ed4b1b5.js 2.22kb +0.00b 6.34s +1.04s ⚠️
dist/ja.5653161c.js 2.22kb +0.00b 6.33s +1.04s ⚠️
dist/vi.d8dcb67a.js 2.22kb +0.00b 8.42s +1.24s ⚠️
dist/pt_BR.eccfad73.js 2.19kb +0.00b 6.34s +1.04s ⚠️
dist/tr.46f26598.js 2.16kb +0.00b 8.42s +1.24s ⚠️
dist/ko.2cf2bbda.js 2.11kb +0.00b 6.33s +1.04s ⚠️
dist/sv.13d93533.js 2.10kb +0.00b 8.42s +1.24s ⚠️
dist/it.601d375a.js 2.10kb +0.00b 6.33s +1.04s ⚠️
dist/nb.b300dd3e.js 2.09kb +0.00b 6.33s +1.04s ⚠️
dist/date.7b2f9581.js 2.07kb +0.00b 5.74s +1.05s ⚠️
dist/da.21385cf2.js 2.07kb +0.00b 6.33s +1.04s ⚠️
dist/nl.3999ea58.js 2.07kb +0.00b 6.33s +1.04s ⚠️
dist/images.46c877f3.js 2.03kb +0.00b 5.74s +1.05s ⚠️
dist/zh_TW.afaf6222.js 1.98kb +0.00b 8.42s +1.24s ⚠️
dist/zh.fcdc32bb.js 1.96kb +0.00b 8.42s +1.24s ⚠️
dist/feedback.fd1f6260.js 1.89kb +0.00b 6.33s +1.04s ⚠️
dist/status.6f638b3d.js 1.80kb +0.00b 5.74s +1.05s ⚠️
dist/workerHasher.be59eb41.js 1.72kb +0.00b 5.42s +961.00ms ⚠️
dist/workerHasher.ef49a7fc.js 1.72kb +0.00b 8.42s +1.24s ⚠️
dist/workerHasher.9d5fe27b.js 1.72kb +0.00b 8.42s +1.24s ⚠️
dist/workerHasher.13de9709.js 1.72kb +0.00b 11.78s +2.27s ⚠️
dist/workerHasher.99c37306.js 1.72kb +0.00b 11.77s +2.27s ⚠️
dist/workerHasher.c5ba46bc.js 1.72kb +0.00b 11.77s +2.27s ⚠️
dist/code.ef3dfa9c.js 1.69kb +0.00b 5.74s +1.05s ⚠️
dist/list-number.35bc7f17.js 1.60kb +0.00b 5.74s +1.05s ⚠️
dist/heading6.974f167d.js 1.49kb +0.00b 6.33s +1.04s ⚠️
dist/16.87c743d1.js 1.48kb +0.00b 5.44s +966.00ms ⚠️
dist/heading3.9ad47cbe.js 1.48kb +0.00b 5.74s +1.05s ⚠️
dist/16.dd50aef4.js 1.41kb +0.00b 5.44s +973.00ms ⚠️
dist/link.542e87bf.js 1.41kb +0.00b 5.74s +1.05s ⚠️
dist/emoji.79757e2c.js 1.38kb +0.00b 5.74s +1.05s ⚠️
dist/heading5.023a8f1f.js 1.36kb +0.00b 6.33s +1.04s ⚠️
dist/expand.801fc3a0.js 1.31kb +0.00b 6.33s +1.04s ⚠️
dist/heading2.bffcdf12.js 1.30kb +0.00b 5.74s +1.05s ⚠️
dist/heading4.05995ed9.js 1.25kb +0.00b 5.74s +1.05s ⚠️
dist/mention.adafe481.js 1.21kb +0.00b 5.74s +1.05s ⚠️
dist/layout.40f6b132.js 1.17kb +0.00b 5.74s +1.05s ⚠️
dist/divider.616b37d8.js 1.17kb +0.00b 5.74s +1.05s ⚠️
dist/action.361730a6.js 1.15kb +0.00b 5.74s +1.05s ⚠️
dist/heading1.495af5dc.js 1.14kb +0.00b 5.74s +1.05s ⚠️
dist/16.9e7cc0d9.js 1.13kb +0.00b 5.44s +966.00ms ⚠️
dist/list.c5ad55b6.js 1.11kb +0.00b 5.74s +1.05s ⚠️
dist/quote.235ab420.js 1.11kb +0.00b 5.74s +1.05s ⚠️
dist/decision.36a0b771.js 1.10kb +0.00b 5.74s +1.05s ⚠️
dist/16.8d078bd1.js 1.08kb +0.00b 5.43s +961.00ms ⚠️
dist/16.bb53313d.js 1.08kb +0.00b 5.44s +966.00ms ⚠️
dist/panel-warning.7e72ad42.js 1.07kb +0.00b 5.74s +1.05s ⚠️
dist/16.88e24f19.js 1.06kb +0.00b 5.42s +960.00ms ⚠️
dist/16.0d8c3c9e.js 1.06kb +0.00b 5.74s +1.05s ⚠️
dist/table.389f0908.js 1.05kb +0.00b 5.74s +1.05s ⚠️
dist/16.db9c75f1.js 1.03kb +0.00b 5.45s +969.00ms ⚠️
dist/panel.7cee1972.js 1017.00b +0.00b 5.74s +1.05s ⚠️
dist/panel-error.e46252ff.js 994.00b +0.00b 5.74s +1.05s ⚠️
dist/16.c0880b62.js 992.00b +0.00b 5.44s +965.00ms ⚠️
dist/16.99296be0.js 964.00b +0.00b 5.45s +969.00ms ⚠️
dist/16.c16ee42d.js 957.00b +0.00b 5.43s +961.00ms ⚠️
dist/16.dcf139e7.js 951.00b +0.00b 5.74s +1.05s ⚠️
dist/panel-success.dbd2515b.js 935.00b +0.00b 5.74s +1.05s ⚠️
dist/panel-note.b6c94ff5.js 925.00b +0.00b 5.74s +1.05s ⚠️
dist/16.26c3d518.js 912.00b +0.00b 5.44s +965.00ms ⚠️
dist/16.f76b9cae.js 906.00b +0.00b 5.44s +973.00ms ⚠️
dist/16.fb327623.js 906.00b +0.00b 5.44s +966.00ms ⚠️
dist/16.f2056258.js 905.00b +0.00b 5.44s +965.00ms ⚠️
dist/16.4e7dec68.js 904.00b +0.00b 5.43s +960.00ms ⚠️
dist/16.400116d9.js 903.00b +0.00b 5.43s +961.00ms ⚠️
dist/16.f6395317.js 876.00b +0.00b 5.74s +1.05s ⚠️
dist/16.24326b68.js 855.00b +0.00b 5.43s +961.00ms ⚠️
dist/16.0285f4b2.js 827.00b +0.00b 5.44s +968.00ms ⚠️
dist/sk.101f1705.js 786.00b +0.00b 8.42s +1.24s ⚠️
dist/pt_PT.402f9c4e.js 765.00b +0.00b 6.34s +1.04s ⚠️
dist/et.69382942.js 763.00b +0.00b 6.33s +1.04s ⚠️
dist/simpleHasher.395b29e6.js 687.00b +0.00b 5.42s +960.00ms ⚠️
dist/simpleHasher.f1f58b0a.js 687.00b +0.00b 8.42s +1.24s ⚠️
dist/simpleHasher.09f4d713.js 687.00b +0.00b 8.42s +1.24s ⚠️
dist/simpleHasher.a19114f9.js 687.00b +0.00b 11.78s +2.27s ⚠️
dist/simpleHasher.023b58fa.js 687.00b +0.00b 11.77s +2.27s ⚠️
dist/simpleHasher.97222d8a.js 687.00b +0.00b 11.77s +2.27s ⚠️
dist/is.5b945719.js 625.00b +0.00b 6.33s +1.04s ⚠️
dist/ro.a6eff34a.js 612.00b +0.00b 8.42s +1.24s ⚠️
dist/en_GB.61f7112a.js 602.00b +0.00b 6.33s +1.04s ⚠️
dist/en.41261459.js 599.00b +0.00b 6.33s +1.04s ⚠️
dist/index.html 240.00b +0.00b 11.98s +2.43s ⚠️

Three.js ✅

Timings

Description Time Difference
Cold 4.92s -165.00ms
Cached 275.00ms +8.00ms

Cold Bundles

Bundle Size Difference Time Difference
dist/Three.js 572.22kb +0.00b 953.00ms -50.00ms 🚀

Cached Bundles

No bundle changes detected.

Click here to view a detailed benchmark overview.

@mischnic mischnic force-pushed the babel-addExternalDependency branch from 010943c to 02a800d Compare April 11, 2022 19:22
@mischnic mischnic force-pushed the babel-addExternalDependency branch from 02a800d to c841f43 Compare June 19, 2022 09:14
@mischnic mischnic marked this pull request as ready for review June 19, 2022 11:57
@mischnic
Copy link
Member Author

mischnic commented Jun 19, 2022

Actually, it looks like the file path isn't necessarily absolute. Babel CLI's watcher first resolves the each dependency https://github.com/babel/babel/blob/7d63d2f8337065a000d80da3282fba91f10fc6c2/packages/babel-cli/src/babel/watcher.ts#L74-L76

babel-loader doesn't appear to use this information at all

I'm not even sure how Parcel's invalidateOnFileChange behaves in that case.

@mischnic
Copy link
Member Author

mischnic commented Jun 19, 2022

Turns out it's not even necessarily a file:

@babel/core does not resolve external dependencies: they can be any string you want. This makes it possible, for example, to also store URLs or pointers to a virtual fs (as long as the caller knows how to handle them).

-> babel/babel#14727

@@ -82,6 +82,11 @@ export default async function babel7(
remapAstLocations(babelCore.types, res.ast, map);
}
}
if (res.externalDependencies) {
for (let f of res.externalDependencies) {
asset.invalidateOnFileChange(f);
Copy link
Member Author

Choose a reason for hiding this comment

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

And I guess Babel also doesn't differentiate between onFileChange and onFileCreate, so we'd have to do both (or check if the file exists)

@devongovett
Copy link
Member

What do we want to do with this one?

@mischnic
Copy link
Member Author

mischnic commented Nov 2, 2022

It's still somehow "undefined behaviour" to pass non-absolute paths (be it relative or "virtual") to addExternalDependency. So maybe we should just add a warning in that case, and see what reports we get (and how the feature is used)

EDIT: done

@mischnic
Copy link
Member Author

Also, what should we do about #7820 (comment) ?

@mischnic mischnic force-pushed the babel-addExternalDependency branch from ea6526b to 372d431 Compare March 26, 2023 09:39
@mischnic mischnic requested review from devongovett and removed request for wbinnssmith March 26, 2023 15:50
@devongovett devongovett merged commit f65889e into v2 Mar 26, 2023
9 of 16 checks passed
@devongovett devongovett deleted the babel-addExternalDependency branch March 26, 2023 19:26
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