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

Default interop missing when importing a CommonJS module #7991

Merged
merged 21 commits into from Jul 2, 2022

Conversation

thebriando
Copy link
Member

@thebriando thebriando commented Apr 21, 2022

↪️ Pull Request

There's a case where we don't add a default interop for a cjs module in getSymbolResolution

This causes an error at runtime since it tries to call default which would be undefined in this case

const $52957b70ba2776b8$export$6a5cdcad01c973fa = (parcelRequire("kJcLp")).default.foo; // <-- missing default interop
                                                                                   ^

TypeError: Cannot read property 'foo' of undefined

💻 Examples

Repl

🚨 Test instructions

✔️ PR Todo

  • Added/updated unit tests for this change
  • Filled out test instructions (In case there aren't any unit tests)
  • Included links to related issues/PRs
  • @lettertwo to add related test case with description

@parcel-benchmark
Copy link

parcel-benchmark commented Apr 22, 2022

Benchmark Results

Kitchen Sink ✅

Timings

Description Time Difference
Cold 1.73s +46.00ms
Cached 445.00ms +78.00ms ⚠️

Cold Bundles

Bundle Size Difference Time Difference
dist/legacy/parcel.7cdb0fad.webp 102.94kb +0.00b 83.00ms -180.00ms 🚀
dist/legacy/parcel.7cdb0fad.webp 102.94kb +0.00b 84.00ms -180.00ms 🚀
dist/modern/parcel.7cdb0fad.webp 102.94kb +0.00b 84.00ms -179.00ms 🚀
dist/legacy/index.2c76ad23.js 1.66kb +0.00b 448.00ms -40.00ms 🚀
dist/legacy/index.8aaa89c9.js 1.20kb +0.00b 448.00ms -40.00ms 🚀
dist/modern/index.6be20f01.js 1.13kb +0.00b 447.00ms -40.00ms 🚀
dist/legacy/index.html 826.00b +0.00b 583.00ms -48.00ms 🚀
dist/modern/index.html 749.00b +0.00b 582.00ms -49.00ms 🚀
dist/legacy/index.b8ae99ba.css 94.00b +0.00b 252.00ms -17.00ms 🚀
dist/modern/index.31cedca9.css 94.00b +0.00b 251.00ms -19.00ms 🚀

Cached Bundles

Bundle Size Difference Time Difference
dist/legacy/parcel.7cdb0fad.webp 102.94kb +0.00b 245.00ms -19.00ms 🚀
dist/legacy/parcel.7cdb0fad.webp 102.94kb +0.00b 246.00ms -19.00ms 🚀
dist/modern/parcel.7cdb0fad.webp 102.94kb +0.00b 246.00ms -18.00ms 🚀
dist/legacy/index.2c76ad23.js 1.66kb +0.00b 460.00ms -31.00ms 🚀
dist/legacy/index.8aaa89c9.js 1.20kb +0.00b 460.00ms -32.00ms 🚀
dist/modern/index.6be20f01.js 1.13kb +0.00b 460.00ms -32.00ms 🚀
dist/legacy/index.b8ae99ba.css 94.00b +0.00b 251.00ms -26.00ms 🚀
dist/modern/index.31cedca9.css 94.00b +0.00b 252.00ms -25.00ms 🚀

React HackerNews ✅

Timings

Description Time Difference
Cold 10.12s -61.00ms
Cached 437.00ms -70.00ms 🚀

Cold Bundles

No bundle changes detected.

Cached Bundles

No bundle changes detected.

AtlasKit Editor ✅

Timings

Description Time Difference
Cold 1.82m -4.15s
Cached 2.94s -138.00ms

Cold Bundles

Bundle Size Difference Time Difference
dist/index.c416ece2.js 3.33mb +0.00b 33.46s -3.63s 🚀
dist/popup.2cc0d9cd.js 314.51kb +0.00b 42.45s -3.91s 🚀
dist/ConfigPanelFieldsLoader.06470302.js 287.98kb +0.00b 37.09s -3.63s 🚀
dist/EmojiPickerComponent.9d8e543c.js 187.29kb +0.00b 33.48s -3.65s 🚀
dist/mobile-upload.b893855e.js 68.22kb +0.00b 33.46s -3.65s 🚀
dist/esm.d33c658d.js 65.60kb +0.00b 42.45s -3.91s 🚀
dist/esm.c7dc1640.js 61.96kb +0.00b 1.33m +33.70s ⚠️
dist/ElementBrowser.3a733953.js 57.29kb +0.00b 38.44s -3.55s 🚀
dist/DatePicker.c3dfe370.js 46.98kb +0.00b 37.09s -3.63s 🚀
dist/component.ea2c474a.js 38.70kb +0.00b 38.44s -3.55s 🚀
dist/DatePicker.63d5864f.js 26.86kb +0.00b 37.09s -3.63s 🚀
dist/component-lazy.01028ffb.js 20.54kb +0.00b 38.44s -3.55s 🚀
dist/ConfigPanelFieldsLoader.dd206ecf.js 16.35kb +0.00b 38.44s -3.55s 🚀
dist/ui.8102caad.js 14.07kb +0.00b 38.44s -3.55s 🚀
dist/dropzone.fedc3def.js 13.82kb +0.00b 42.45s -3.91s 🚀
dist/pdfRenderer.d23553db.js 12.17kb +0.00b 42.45s -3.92s 🚀
dist/mobile-upload.bf388fdf.js 8.10kb +0.00b 33.46s -3.62s 🚀
dist/dropzone.f93d7dd9.js 7.36kb +0.00b 42.45s -3.91s 🚀
dist/component-lazy.a40a67db.js 6.85kb +0.00b 38.44s -3.55s 🚀
dist/EmojiPickerComponent.16132f88.js 5.54kb +0.00b 33.46s -3.65s 🚀
dist/media-viewer.7ba2bb8e.js 4.36kb +0.00b 42.45s -3.92s 🚀
dist/clipboard.eb5719cd.js 3.60kb +0.00b 42.45s -3.92s 🚀
dist/ru.fdb600e7.js 2.94kb +0.00b 38.44s -3.55s 🚀
dist/uk.aeae0dd4.js 2.91kb +0.00b 38.44s -3.55s 🚀
dist/browser.72e17e1d.js 2.86kb +0.00b 42.45s -3.92s 🚀
dist/th.bcd8fad5.js 2.75kb +0.00b 38.44s -3.55s 🚀
dist/card.8e8152fc.js 2.71kb +0.00b 42.45s -3.92s 🚀
dist/ResourcedEmojiComponent.bef36b85.js 2.68kb +0.00b 33.46s -3.65s 🚀
dist/media-viewer-analytics-error-boundary.8669c765.js 2.39kb +0.00b 42.45s -3.92s 🚀
dist/pl.4643976c.js 2.37kb +0.00b 37.09s -3.63s 🚀
dist/cs.08737142.js 2.28kb +0.00b 37.09s -3.63s 🚀
dist/de.c2e79abd.js 2.26kb +0.00b 37.09s -3.63s 🚀
dist/es.983af340.js 2.24kb +0.00b 37.09s -3.63s 🚀
dist/ja.b56014f3.js 2.24kb +0.00b 37.09s -3.63s 🚀
dist/fr.aaa4d0bf.js 2.20kb +0.00b 37.09s -3.63s 🚀
dist/pt_BR.6c08dcf7.js 2.17kb +0.00b 37.09s -3.64s 🚀
dist/hu.3d2e30a0.js 2.17kb +0.00b 37.09s -3.63s 🚀
dist/component-lazy.feb4b6cd.js 2.16kb +0.00b 38.44s -3.55s 🚀
dist/tr.3968c433.js 2.15kb +0.00b 38.44s -3.55s 🚀
dist/vi.bf757a1c.js 2.15kb +0.00b 38.44s -3.55s 🚀
dist/fi.080f52aa.js 2.13kb +0.00b 37.09s -3.63s 🚀
dist/ko.51863560.js 2.13kb +0.00b 37.09s -3.63s 🚀
dist/it.7bb93510.js 2.12kb +0.00b 37.09s -3.63s 🚀
dist/nb.67163f41.js 2.10kb +0.00b 37.09s -3.63s 🚀
dist/date.728667d8.js 2.10kb +0.00b 33.46s -3.65s 🚀
dist/sv.51378563.js 2.09kb +0.00b 38.44s -3.55s 🚀
dist/nl.336a2549.js 2.09kb +0.00b 37.09s -3.63s 🚀
dist/da.f39b0c8c.js 2.07kb +0.00b 37.09s -3.63s 🚀
dist/images.0fe0f35c.js 2.05kb +0.00b 33.46s -3.65s 🚀
dist/zh_TW.6ca95d33.js 2.00kb +0.00b 38.44s -3.55s 🚀
dist/zh.9b716de5.js 1.99kb +0.00b 38.44s -3.55s 🚀
dist/feedback.2ade51a8.js 1.92kb +0.00b 37.09s -3.63s 🚀
dist/status.2160efcd.js 1.82kb +0.00b 33.47s -3.66s 🚀
dist/workerHasher.0904bc5b.js 1.72kb +0.00b 33.46s -3.62s 🚀
dist/workerHasher.6290622a.js 1.72kb +0.00b 42.45s -3.91s 🚀
dist/workerHasher.23d0f86c.js 1.72kb +0.00b 42.45s -3.92s 🚀
dist/workerHasher.e50d242f.js 1.72kb +0.00b 1.33m +33.70s ⚠️
dist/code.414e2c00.js 1.72kb +0.00b 33.46s -3.65s 🚀
dist/component.e636e8c4.js 1.63kb +0.00b 38.44s -3.55s 🚀
dist/list-number.2be0cd6c.js 1.62kb +0.00b 33.46s -3.65s 🚀
dist/heading6.e0c2f3cf.js 1.52kb +0.00b 37.09s -3.63s 🚀
dist/heading3.5b4663e8.js 1.51kb +0.00b 37.09s -3.63s 🚀
dist/16.d28358f5.js 1.48kb +0.00b 42.45s -3.92s 🚀
dist/link.1e33efbb.js 1.43kb +0.00b 33.46s -3.65s 🚀
dist/media-picker-analytics-error-boundary.c847f974.js 1.42kb +0.00b 42.45s -3.92s 🚀
dist/16.86f26d3d.js 1.41kb +0.00b 38.44s -3.55s 🚀
dist/emoji.5404dc09.js 1.40kb +0.00b 33.46s -3.65s 🚀
dist/heading5.df611011.js 1.39kb +0.00b 37.09s -3.63s 🚀
dist/expand.655beb16.js 1.33kb +0.00b 37.09s -3.63s 🚀
dist/heading2.54f14b16.js 1.33kb +0.00b 37.09s -3.63s 🚀
dist/heading4.3ae44c0a.js 1.28kb +0.00b 37.09s -3.63s 🚀
dist/mention.85e501f2.js 1.24kb +0.00b 33.46s -3.65s 🚀
dist/layout.dde5aa7a.js 1.20kb +0.00b 33.46s -3.65s 🚀
dist/divider.3af42f3a.js 1.20kb +0.00b 33.46s -3.65s 🚀
dist/action.633b1d3a.js 1.17kb +0.00b 33.46s -3.65s 🚀
dist/heading1.216107b4.js 1.17kb +0.00b 33.48s -3.65s 🚀
dist/list.1bd3e768.js 1.14kb +0.00b 33.46s -3.65s 🚀
dist/quote.707178c1.js 1.14kb +0.00b 33.47s -3.66s 🚀
dist/16.7c57bd8b.js 1.13kb +0.00b 42.45s -3.92s 🚀
dist/ConfigPanelFieldsLoader.fee2d8bd.js 1.12kb +0.00b 38.44s -3.55s 🚀
dist/decision.5c187f01.js 1.12kb +0.00b 33.46s -3.65s 🚀
dist/panel-warning.817f153e.js 1.10kb +0.00b 33.47s -3.66s 🚀
dist/16.878668fc.js 1.08kb +0.00b 38.44s -3.55s 🚀
dist/table.71e953fa.js 1.08kb +0.00b 33.48s -3.65s 🚀
dist/16.9db4c5fc.js 1.06kb +0.00b 38.44s -3.55s 🚀
dist/16.6bd01cc7.js 1.06kb +0.00b 42.45s -3.92s 🚀
dist/16.a4b6862e.js 1.02kb +0.00b 42.45s -3.91s 🚀
dist/panel.63b53aef.js 1.02kb +0.00b 33.47s -3.67s 🚀
dist/panel-error.3c204bc9.js 1019.00b +0.00b 33.47s -3.66s 🚀
dist/16.f5881244.js 991.00b +0.00b 42.45s -3.92s 🚀
dist/ConfigPanelFieldsLoader.3cc97f45.js 975.00b +0.00b 38.44s -3.55s 🚀
dist/16.0e28197b.js 963.00b +0.00b 42.45s -3.92s 🚀
dist/panel-success.bfed2890.js 960.00b +0.00b 33.47s -3.66s 🚀
dist/16.bcad6da7.js 956.00b +0.00b 38.44s -3.55s 🚀
dist/panel-note.badaa0b2.js 950.00b +0.00b 33.47s -3.66s 🚀
dist/16.006f2efd.js 950.00b +0.00b 42.45s -3.91s 🚀
dist/media-viewer.e4a4cc34.js 935.00b +0.00b 42.45s -3.92s 🚀
dist/16.b50bd25c.js 911.00b +0.00b 42.45s -3.92s 🚀
dist/16.050fcc44.js 905.00b +0.00b 38.44s -3.55s 🚀
dist/16.c2636906.js 904.00b +0.00b 42.45s -3.92s 🚀
dist/16.61242a1f.js 903.00b +0.00b 38.44s -3.55s 🚀
dist/16.37ce783c.js 902.00b +0.00b 38.44s -3.55s 🚀
dist/16.f353315d.js 875.00b +0.00b 42.45s -3.91s 🚀
dist/16.d9e53846.js 854.00b +0.00b 38.44s -3.55s 🚀
dist/16.75acb770.js 826.00b +0.00b 42.45s -3.92s 🚀
dist/sk.dd4e83c8.js 791.00b +0.00b 38.44s -3.55s 🚀
dist/pt_PT.1eda577d.js 786.00b +0.00b 37.09s -3.64s 🚀
dist/et.03b90e09.js 778.00b +0.00b 37.09s -3.63s 🚀
dist/simpleHasher.2e0de700.js 742.00b +0.00b 33.46s -3.62s 🚀
dist/simpleHasher.76c4e98e.js 742.00b +0.00b 42.45s -3.91s 🚀
dist/simpleHasher.cc19c690.js 742.00b +0.00b 42.45s -3.91s 🚀
dist/simpleHasher.46d6f2e5.js 742.00b +0.00b 1.33m +33.70s ⚠️
dist/is.0d0b2897.js 638.00b +0.00b 37.09s -3.63s 🚀
dist/ro.82d888a1.js 633.00b +0.00b 38.44s -2.29s 🚀
dist/en_GB.a4eaa606.js 623.00b +0.00b 37.09s -3.63s 🚀
dist/en.dced70ab.js 620.00b +0.00b 37.09s -3.63s 🚀
dist/ConfigPanelFieldsLoader.e3b1a5db.js 490.00b +0.00b 38.44s -3.55s 🚀
dist/index.html 240.00b +0.00b 1.33m +42.87s ⚠️

Cached Bundles

Bundle Size Difference Time Difference
dist/index.59b5647e.js 3.33mb +0.00b 35.45s +3.06s ⚠️
dist/popup.2cc0d9cd.js 314.51kb +0.00b 43.51s +3.03s ⚠️
dist/ConfigPanelFieldsLoader.06470302.js 287.98kb +0.00b 38.84s +3.05s ⚠️
dist/EmojiPickerComponent.9d8e543c.js 187.29kb +0.00b 35.46s +3.03s ⚠️
dist/mobile-upload.b893855e.js 68.22kb +0.00b 35.45s +3.06s ⚠️
dist/esm.d33c658d.js 65.60kb +0.00b 43.51s +3.03s ⚠️
dist/ElementBrowser.3a733953.js 57.29kb +0.00b 40.05s +3.08s ⚠️
dist/DatePicker.c3dfe370.js 46.98kb +0.00b 38.84s +3.05s ⚠️
dist/component.ea2c474a.js 38.70kb +0.00b 40.05s +3.08s ⚠️
dist/DatePicker.63d5864f.js 26.86kb +0.00b 38.84s +3.05s ⚠️
dist/component-lazy.01028ffb.js 20.54kb +0.00b 40.05s +3.08s ⚠️
dist/ConfigPanelFieldsLoader.dd206ecf.js 16.35kb +0.00b 40.05s +3.08s ⚠️
dist/ui.8102caad.js 14.07kb +0.00b 40.05s +3.08s ⚠️
dist/dropzone.fedc3def.js 13.82kb +0.00b 43.51s +3.03s ⚠️
dist/pdfRenderer.d23553db.js 12.17kb +0.00b 43.51s +3.02s ⚠️
dist/mobile-upload.bf388fdf.js 8.10kb +0.00b 35.45s +3.06s ⚠️
dist/dropzone.f93d7dd9.js 7.36kb +0.00b 43.51s +3.03s ⚠️
dist/component-lazy.a40a67db.js 6.85kb +0.00b 40.05s +3.08s ⚠️
dist/EmojiPickerComponent.16132f88.js 5.54kb +0.00b 35.45s +3.06s ⚠️
dist/media-viewer.7ba2bb8e.js 4.36kb +0.00b 43.51s +3.03s ⚠️
dist/clipboard.eb5719cd.js 3.60kb +0.00b 43.51s +3.02s ⚠️
dist/ru.fdb600e7.js 2.94kb +0.00b 40.05s +3.08s ⚠️
dist/uk.aeae0dd4.js 2.91kb +0.00b 40.05s +3.08s ⚠️
dist/browser.72e17e1d.js 2.86kb +0.00b 43.51s +3.02s ⚠️
dist/th.bcd8fad5.js 2.75kb +0.00b 40.05s +3.08s ⚠️
dist/card.8e8152fc.js 2.71kb +0.00b 43.51s +3.03s ⚠️
dist/ResourcedEmojiComponent.bef36b85.js 2.68kb +0.00b 35.45s +3.06s ⚠️
dist/media-viewer-analytics-error-boundary.8669c765.js 2.39kb +0.00b 43.51s +3.02s ⚠️
dist/pl.4643976c.js 2.37kb +0.00b 38.84s +3.05s ⚠️
dist/cs.08737142.js 2.28kb +0.00b 38.84s +3.05s ⚠️
dist/de.c2e79abd.js 2.26kb +0.00b 38.84s +3.05s ⚠️
dist/es.983af340.js 2.24kb +0.00b 38.84s +3.05s ⚠️
dist/ja.b56014f3.js 2.24kb +0.00b 38.84s +3.05s ⚠️
dist/fr.aaa4d0bf.js 2.20kb +0.00b 38.84s +3.05s ⚠️
dist/pt_BR.6c08dcf7.js 2.17kb +0.00b 38.84s +3.05s ⚠️
dist/hu.3d2e30a0.js 2.17kb +0.00b 38.84s +3.05s ⚠️
dist/component-lazy.feb4b6cd.js 2.16kb +0.00b 40.05s +3.08s ⚠️
dist/tr.3968c433.js 2.15kb +0.00b 40.05s +3.08s ⚠️
dist/vi.bf757a1c.js 2.15kb +0.00b 40.05s +3.08s ⚠️
dist/fi.080f52aa.js 2.13kb +0.00b 38.84s +3.05s ⚠️
dist/ko.51863560.js 2.13kb +0.00b 38.84s +3.05s ⚠️
dist/it.7bb93510.js 2.12kb +0.00b 38.84s +3.05s ⚠️
dist/nb.67163f41.js 2.10kb +0.00b 38.84s +3.05s ⚠️
dist/date.728667d8.js 2.10kb +0.00b 35.45s +3.05s ⚠️
dist/sv.51378563.js 2.09kb +0.00b 40.05s +3.08s ⚠️
dist/nl.336a2549.js 2.09kb +0.00b 38.84s +3.05s ⚠️
dist/da.f39b0c8c.js 2.07kb +0.00b 38.84s +3.05s ⚠️
dist/images.0fe0f35c.js 2.05kb +0.00b 35.46s +3.05s ⚠️
dist/zh_TW.6ca95d33.js 2.00kb +0.00b 40.05s +3.08s ⚠️
dist/zh.9b716de5.js 1.99kb +0.00b 40.05s +3.08s ⚠️
dist/feedback.2ade51a8.js 1.92kb +0.00b 38.84s +3.05s ⚠️
dist/status.2160efcd.js 1.82kb +0.00b 35.46s +3.05s ⚠️
dist/workerHasher.0904bc5b.js 1.72kb +0.00b 35.45s +3.06s ⚠️
dist/workerHasher.6290622a.js 1.72kb +0.00b 43.51s +3.03s ⚠️
dist/workerHasher.23d0f86c.js 1.72kb +0.00b 43.51s +3.03s ⚠️
dist/code.414e2c00.js 1.72kb +0.00b 35.45s +3.06s ⚠️
dist/component.e636e8c4.js 1.63kb +0.00b 40.05s +3.08s ⚠️
dist/list-number.2be0cd6c.js 1.62kb +0.00b 35.46s +3.05s ⚠️
dist/heading6.e0c2f3cf.js 1.52kb +0.00b 38.84s +3.05s ⚠️
dist/heading3.5b4663e8.js 1.51kb +0.00b 38.84s +3.05s ⚠️
dist/16.d28358f5.js 1.48kb +0.00b 43.51s +3.03s ⚠️
dist/link.1e33efbb.js 1.43kb +0.00b 35.46s +3.05s ⚠️
dist/media-picker-analytics-error-boundary.c847f974.js 1.42kb +0.00b 43.51s +3.02s ⚠️
dist/16.86f26d3d.js 1.41kb +0.00b 40.05s +3.08s ⚠️
dist/emoji.5404dc09.js 1.40kb +0.00b 35.45s +3.05s ⚠️
dist/heading5.df611011.js 1.39kb +0.00b 38.84s +3.05s ⚠️
dist/expand.655beb16.js 1.33kb +0.00b 38.84s +3.05s ⚠️
dist/heading2.54f14b16.js 1.33kb +0.00b 38.84s +3.05s ⚠️
dist/heading4.3ae44c0a.js 1.28kb +0.00b 38.84s +3.05s ⚠️
dist/mention.85e501f2.js 1.24kb +0.00b 35.46s +3.05s ⚠️
dist/layout.dde5aa7a.js 1.20kb +0.00b 35.46s +3.05s ⚠️
dist/divider.3af42f3a.js 1.20kb +0.00b 35.45s +3.05s ⚠️
dist/action.633b1d3a.js 1.17kb +0.00b 35.45s +3.06s ⚠️
dist/heading1.216107b4.js 1.17kb +0.00b 35.46s +3.04s ⚠️
dist/list.1bd3e768.js 1.14kb +0.00b 35.46s +3.05s ⚠️
dist/quote.707178c1.js 1.14kb +0.00b 35.46s +3.05s ⚠️
dist/16.7c57bd8b.js 1.13kb +0.00b 43.51s +3.03s ⚠️
dist/ConfigPanelFieldsLoader.fee2d8bd.js 1.12kb +0.00b 40.05s +3.08s ⚠️
dist/decision.5c187f01.js 1.12kb +0.00b 35.45s +3.05s ⚠️
dist/panel-warning.817f153e.js 1.10kb +0.00b 35.46s +3.05s ⚠️
dist/16.878668fc.js 1.08kb +0.00b 40.05s +3.08s ⚠️
dist/16.1969624f.js 1.08kb +0.00b 43.51s +3.03s ⚠️
dist/table.71e953fa.js 1.08kb +0.00b 35.46s +3.05s ⚠️
dist/16.9db4c5fc.js 1.06kb +0.00b 40.05s +3.08s ⚠️
dist/16.6bd01cc7.js 1.06kb +0.00b 43.51s +3.03s ⚠️
dist/16.a4b6862e.js 1.02kb +0.00b 43.51s +3.03s ⚠️
dist/panel.63b53aef.js 1.02kb +0.00b 35.46s +3.05s ⚠️
dist/panel-error.3c204bc9.js 1019.00b +0.00b 35.46s +3.05s ⚠️
dist/16.f5881244.js 991.00b +0.00b 43.51s +3.03s ⚠️
dist/ConfigPanelFieldsLoader.3cc97f45.js 975.00b +0.00b 40.05s +3.08s ⚠️
dist/16.0e28197b.js 963.00b +0.00b 43.51s +3.03s ⚠️
dist/panel-success.bfed2890.js 960.00b +0.00b 35.46s +3.05s ⚠️
dist/16.bcad6da7.js 956.00b +0.00b 40.05s +3.08s ⚠️
dist/panel-note.badaa0b2.js 950.00b +0.00b 35.46s +3.05s ⚠️
dist/16.006f2efd.js 950.00b +0.00b 43.51s +3.03s ⚠️
dist/media-viewer.e4a4cc34.js 935.00b +0.00b 43.51s +3.02s ⚠️
dist/16.b50bd25c.js 911.00b +0.00b 43.51s +3.03s ⚠️
dist/16.050fcc44.js 905.00b +0.00b 40.05s +3.08s ⚠️
dist/16.069344b7.js 905.00b +0.00b 43.51s +3.03s ⚠️
dist/16.c2636906.js 904.00b +0.00b 43.51s +3.03s ⚠️
dist/16.61242a1f.js 903.00b +0.00b 40.05s +3.08s ⚠️
dist/16.37ce783c.js 902.00b +0.00b 40.05s +3.08s ⚠️
dist/16.f353315d.js 875.00b +0.00b 43.51s +3.03s ⚠️
dist/16.d9e53846.js 854.00b +0.00b 40.05s +3.08s ⚠️
dist/16.75acb770.js 826.00b +0.00b 43.51s +3.03s ⚠️
dist/sk.dd4e83c8.js 791.00b +0.00b 40.05s +3.08s ⚠️
dist/pt_PT.1eda577d.js 786.00b +0.00b 38.84s +3.05s ⚠️
dist/et.03b90e09.js 778.00b +0.00b 38.84s +3.05s ⚠️
dist/simpleHasher.2e0de700.js 742.00b +0.00b 35.45s +3.06s ⚠️
dist/simpleHasher.76c4e98e.js 742.00b +0.00b 43.51s +3.03s ⚠️
dist/simpleHasher.cc19c690.js 742.00b +0.00b 43.51s +3.03s ⚠️
dist/is.0d0b2897.js 638.00b +0.00b 38.84s +3.05s ⚠️
dist/ro.82d888a1.js 633.00b +0.00b 40.05s +3.08s ⚠️
dist/en_GB.a4eaa606.js 623.00b +0.00b 38.84s +3.05s ⚠️
dist/en.dced70ab.js 620.00b +0.00b 38.84s +3.05s ⚠️
dist/ConfigPanelFieldsLoader.e3b1a5db.js 490.00b +0.00b 40.05s +3.08s ⚠️

Three.js ✅

Timings

Description Time Difference
Cold 6.73s -683.00ms 🚀
Cached 266.00ms -19.00ms 🚀

Cold Bundles

Bundle Size Difference Time Difference
dist/Three.js 580.04kb +0.00b 4.78s -427.00ms 🚀

Cached Bundles

No bundle changes detected.

Click here to view a detailed benchmark overview.

lettertwo and others added 4 commits April 21, 2022 20:18
Co-authored-by: Eric Eldredge <lettertwo@gmail.com>
Co-authored-by: Eric Eldredge <lettertwo@gmail.com>
@mischnic
Copy link
Member

Looks like there's a problem in the transformer:

import b from './b';
const foo = b.foo;
const bar = require('./b').foo;

output = foo + bar;

becomes

const $aa66d08168f59e76$var$foo = $aa66d08168f59e76$import$61a9e60a12024cdc$2e2bcd8739ae039.foo;
import "aa66d08168f59e76:./b";
var $aa66d08168f59e76$require$bar = $aa66d08168f59e76$import$61a9e60a12024cdc$6a5cdcad01c973fa;
output = $aa66d08168f59e76$var$foo + $aa66d08168f59e76$require$bar;

so both the require and the import usage get attributed to the same dependency.

Furthermore, this dependency has kind=Require:

Bildschirmfoto 2022-04-22 um 22 49 47

And indeed for a Require dependency, default shouldn't do anything special (from the packager's perspective). So this has to be fixed in the JS transformer.

(And there's probably a situation right now where the inverse happens, that require("x").default gets incorrectly wrapped with an interop call)

thebriando and others added 2 commits April 25, 2022 09:39
Co-authored-by: Niklas Mischkulnig <4586894+mischnic@users.noreply.github.com>
((dep.meta.kind === 'Require' ||
dep.meta.kind === 'Import' ||
dep.meta.kind === 'DynamicImport') &&
dep.meta.kind !== kind)
Copy link
Member Author

Choose a reason for hiding this comment

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

dep.meta.kind is a DependencyKind rather than a ImportKind so I wasn't really sure what to do here..

@thebriando thebriando marked this pull request as ready for review May 9, 2022 14:32
@thebriando thebriando changed the title [DRAFT] Default interop missing when importing a CommonJS module Default interop missing when importing a CommonJS module May 9, 2022
Comment on lines 729 to 739
for (let dep of nullthrows(deps.get(source))) {
if (
(dep.meta.kind === 'Require' ||
dep.meta.kind === 'Import' ||
dep.meta.kind === 'DynamicImport') &&
dep.meta.kind !== kind
) {
continue;
}
dep.symbols.set(imported, local, convertLoc(loc));
}
Copy link
Member

Choose a reason for hiding this comment

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

Could this be simplified to just

let dep = nullthrows(deps.get(source)).find(d => dep.meta.kind === kind)

?

Copy link
Member Author

Choose a reason for hiding this comment

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

So there's a case where dep.meta.kind is Export and kind is import and I think we should be setting the symbols in this case which is why I had the condition to continue if there's a mismatch and if dep.meta.kind is an ImportKind

Copy link
Member

Choose a reason for hiding this comment

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

So this would be the case where you have both reexports and imports of the same specifier in a single asset. But it looks like currently import always wins (so dep.meta.kind will be import in asset.getDependencies()). (Kind of strange anyway that we have dep.meta.kind anyway. AFAICT dep.specifierType would be sufficient for the packager, then there's only be esm or cjs)

And in this loop, kind is always Import or Require.

Copy link
Member Author

Choose a reason for hiding this comment

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

Hmm in this test it looks like Export wins for dep.meta.kind so the symbols wouldn't get set if we have that single condition.

dep.sourcePath: /Users/bdo/parcel/packages/core/integration-tests/test/integration/scope-hoisting/es6/re-export-import/d.js
dep.meta.kind: Export

it('supports simultaneous import and re-export of a symbol', async function () {

Comment on lines 742 to 745
for (let dep of nullthrows(deps.get(source))) {
if (local === '*' && imported === '*') {
dep.symbols.set('*', '*', convertLoc(loc), true);
} else {
Copy link
Member

Choose a reason for hiding this comment

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

I think this shouldn't be set for all dependencies with that specified for only for the Import one?

Copy link
Member Author

Choose a reason for hiding this comment

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

So we shouldn't set the symbols if kind is Import?

Copy link
Member

@mischnic mischnic May 13, 2022

Choose a reason for hiding this comment

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

This loop is applying hoist_result.re_exports. Which can only come from ESM export .. from ...; statements. So here we're only interested in the ESM dep . For example in

export {a as b} from "foo";
const {x} = require("foo");
console.log(x)

if (!deps.has(dep.meta.placeholder ?? dep.specifier)) {
deps.set(dep.meta.placeholder ?? dep.specifier, []);
}
deps.get(dep.meta.placeholder ?? dep.specifier)?.push(dep);
Copy link
Member

Choose a reason for hiding this comment

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

A possible alternative way of implementing this could be to make the map keyed by (dep.meta.placeholder ?? dep.specifier) + dep.specifierType, rather than an array of dependencies per specifier.

Copy link
Member Author

Choose a reason for hiding this comment

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

I think the main reason why I didn't add the kind to the key is because we only want to do the ImportKind specific stuff when we are looking at hoist_result.imported_symbols. Keying by specifier + specifierType would mean that we would have to change all the other things in the hoist_result to track the kind, but I'm not sure if we should do that.

Comment on lines 764 to 768
for (let specifier of hoist_result.wrapped_requires) {
let dep = deps.get(specifier);
if (!dep) continue;
dep.meta.shouldWrap = true;
for (let dep of nullthrows(deps.get(specifier))) {
dep.meta.shouldWrap = true;
}
}
Copy link
Member

@mischnic mischnic May 23, 2022

Choose a reason for hiding this comment

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

dep.meta.shouldWrap will get set for every dependency with that specifier. But it should have been for the require dep only.

@mischnic
Copy link
Member

mischnic commented May 23, 2022

I still find the approach of adding for loops problematic. I can't think of a case where an entry from imported_symbols or re_exports ... should be added to more than 1 dependency. So something deps.find()-based seems cleaner and less error prone

@thebriando
Copy link
Member Author

So in this case

import b from './b';
export const foo = b.foo;
export const bar = (() => require('./b').foo)();

output = foo + bar;

We get this error because there's two deps with './b' as the specifier but we only wrap the commonjs one but it looks like we might need to wrap the other one too?

const $b49a022a1bb2bce3$export$6a5cdcad01c973fa = (/*@__PURE__*/$parcel$interopDefault($7RLDk)).foo;
                                                                                       ^

ReferenceError: $7RLDk is not defined

@mischnic
Copy link
Member

mischnic commented May 27, 2022

  1. So the missing var $id = parcelRequire("id"); would come from here: (this works correctly)
    hoisted.set(
    resolvedAsset.id,
    `var $${publicId} = parcelRequire(${JSON.stringify(publicId)});`,
    );
  2. They actually get inserted into the code by this function (also fine)
  3. The function gets called here
    if (d != null) {
    let dep = depMap.get(d);
    if (!dep) {
    return m;
    }
    let resolved = this.bundleGraph.getResolvedAsset(dep, this.bundle);
    let skipped = this.bundleGraph.isDependencySkipped(dep);
    if (resolved && !skipped) {
    // Hoist variable declarations for the referenced parcelRequire dependencies
    // after the dependency is declared. This handles the case where the resulting asset
    // is wrapped, but the dependency in this asset is not marked as wrapped. This means
    // that it was imported/required at the top-level, so its side effects should run immediately.
    let [res, lines] = this.getHoistedParcelRequires(

This loop replaces all occurences of imports and requires as output by the transformer. But there's once again the problem that there's no difference between the twin ESM and CJS deps: there are two identical specifiers here, where the first should refer to the ESM dep and the second to the CJS dep.

import "b49a022a1bb2bce3:./b";
const $b49a022a1bb2bce3$export$6a5cdcad01c973fa = $b49a022a1bb2bce3$import$61a9e60a12024cdc$2e2bcd8739ae039.foo; // <-- missing default interop
import "b49a022a1bb2bce3:./b";
const $b49a022a1bb2bce3$export$d927737047eb3867 = (()=>$b49a022a1bb2bce3$import$61a9e60a12024cdc$6a5cdcad01c973fa
)();
output = $b49a022a1bb2bce3$export$6a5cdcad01c973fa + $b49a022a1bb2bce3$export$d927737047eb3867;

So the callback runs with d = "b49a022a1bb2bce3:./b" twice and dep will always be the CJS dep (more or less by coincidence). So the call generated by step 1 is never inserted.
We need to make sure these ${id}:${specifier} things are unique so that the packager processes both deps

@thebriando
Copy link
Member Author

So how does wrapped_requires work? There's cases where a dependency with the specifier from wrapped_requires should be wrapped, but the dep has the esm specifierType, so it gets skipped in the loop.

for (let specifier of hoist_result.wrapped_requires) {
let dep = deps.get(specifier + 'commonjs');
if (!dep) continue;
dep.meta.shouldWrap = true;
}

specifier 909dbfcd45da280e
deps Map {
  '909dbfcd45da280eesm' => Dependency(/Users/bdo/parcel/packages/core/integration-tests/test/integration/sync-entry-shared/index.js -> ./async)
}
1) scope hoisting
       can run an entry bundle whose entry asset is present in another bundle:
     async.5cf68d6a.js:17
parcelRequire.register("8gGIA", function(module, exports) {
              ^

TypeError: Cannot read property 'register' of undefined

@devongovett
Copy link
Member

Trying to summarize the conversation:

  1. Update the code in hoist.rs so that it does not add dynamic imports to wrapped_requires, and instead, make this implicit. i.e. in the JSTransformer, mark dependencies in dynamic_imports as wrapped.
  2. For URL dependencies, we could either also mark them as wrapped implicitly (which would preserve current behavior), or not and assume that the runtime is side effect free. Probably better for the runtime to decide this though, but we could attempt that separately.
  3. Looks like you're already using dep.meta.placeholder as the key when available, so I guess that already handles the URL require case.

@thebriando thebriando merged commit 99cf505 into v2 Jul 2, 2022
@carlobeltrame
Copy link

Thanks for fixing! Can we ge a release with this fix? I think we are affected in diegomura/react-pdf#1915

@thebriando
Copy link
Member Author

@carlobeltrame Yes! We will try to get one out soon. cc: @devongovett

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

6 participants