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 reexports of a CommonJS asset on namespace object are undefined #6909

Closed
wants to merge 1 commit into from

Conversation

mischnic
Copy link
Member

The reproduction from #6361 (comment) would still fail even after fixing #6361 because of this bug.

The problem is that c.js is treated as ESM and "default" isn't translated to the namespace exports object. The output contains

// 42309d7075d0fd86 is the reexporting b.js
// 89f40be4dd9522be is the CJS file c.js

$parcel$export($42309d7075d0fd86$exports, "foo", () => $89f40be4dd9522be$exports.default);

The invalid call comes from here:

let resolved = this.getSymbolResolution(asset, asset, exp);
let get = this.buildFunctionExpression([], resolved);
let set = asset.meta.hasCJSExports
? ', ' + this.buildFunctionExpression(['v'], `${resolved} = v`)
: '';
return `$parcel$export($${assetId}$exports, ${JSON.stringify(
exp,
)}, ${get}${set});`;

probably because getSymbolResolution isn't passed the optional dep (which isn't really available here anyway) and then dep?.meta.kind === "Imported" is false:

let isDefaultInterop =
exportSymbol === 'default' &&
staticExports &&
!isWrapped &&
dep?.meta.kind === 'Import' &&
resolvedAsset.symbols.hasExportSymbol('*') &&
resolvedAsset.symbols.hasExportSymbol('default') &&
!resolvedAsset.symbols.hasExportSymbol('__esModule');

@height
Copy link

height bot commented Sep 10, 2021

Link Height tasks by mentioning a task ID in the pull request title or description, commit messages, or comments.

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

@parcel-benchmark
Copy link

Benchmark Results

Kitchen Sink ✅

Timings

Description Time Difference
Cold 1.82s +15.00ms
Cached 300.00ms -16.00ms 🚀

Cold Bundles

No bundle changes detected.

Cached Bundles

No bundle changes detected.

React HackerNews ✅

Timings

Description Time Difference
Cold 9.76s -6.00ms
Cached 481.00ms +1.00ms

Cold Bundles

No bundle changes detected.

Cached Bundles

No bundle changes detected.

AtlasKit Editor ✅

Timings

Description Time Difference
Cold 1.08m -1.04s
Cached 1.77s +46.00ms

Cold Bundles

Bundle Size Difference Time Difference
dist/index.f0f1e037.js 1.78mb -8.00b 🚀 18.85s +54.00ms
dist/index.71da6dbc.js 694.72kb -15.00b 🚀 49.77s -659.00ms
dist/editorView.fd78f3a5.js 594.92kb +0.00b 49.15s +11.84s ⚠️
dist/popup.8281fd48.js 209.67kb +0.00b 49.12s +11.82s ⚠️
dist/Toolbar.5b2cb10b.js 107.23kb +0.00b 49.15s +11.84s ⚠️
dist/Modal.3befb51c.js 45.33kb +0.00b 49.12s +11.82s ⚠️
dist/ui.d52fa306.js 14.94kb +0.00b 49.12s +11.82s ⚠️
dist/smartMediaEditor.42c0cc9f.js 13.25kb +0.00b 49.15s +11.84s ⚠️
dist/dropzone.0d183115.js 12.15kb +0.00b 49.12s +11.82s ⚠️
dist/EmojiPickerComponent.55e0a64c.js 3.73kb +0.00b 49.12s +11.81s ⚠️
dist/dropzone.a10cce43.js 3.29kb +0.00b 49.12s +11.82s ⚠️
dist/clipboard.969d5ad7.js 2.93kb +0.00b 49.12s +11.82s ⚠️
dist/ResourcedEmojiComponent.78f6ddfc.js 2.12kb +0.00b 49.12s +11.81s ⚠️
dist/browser.09200cd5.js 1.69kb +0.00b 49.15s +11.84s ⚠️
dist/media-card-analytics-error-boundary.75fac461.js 1.12kb +0.00b 49.12s +11.82s ⚠️
dist/media-picker-analytics-error-boundary.cfe02cc6.js 966.00b +0.00b 49.12s +11.82s ⚠️
dist/simpleHasher.2a6e12b6.js 643.00b +0.00b 49.12s +11.81s ⚠️

Cached Bundles

Bundle Size Difference Time Difference
dist/index.7ccda836.js 1.78mb -6.00b 🚀 18.57s +65.00ms
dist/index.37f58506.js 694.69kb +19.00b ⚠️ 50.35s +1.03s
dist/editorView.b84805b8.js 594.92kb +0.00b 49.94s +13.32s ⚠️
dist/popup.df1aaf85.js 209.67kb +0.00b 49.94s +13.32s ⚠️
dist/Toolbar.a8872498.js 107.23kb +0.00b 49.94s +13.32s ⚠️
dist/Modal.b3c5c175.js 45.31kb +15.00b ⚠️ 49.94s +13.32s ⚠️
dist/js.0f0bb621.js 17.25kb +0.00b 49.94s +13.32s ⚠️
dist/ui.35496a8d.js 14.94kb +0.00b 49.94s +13.32s ⚠️
dist/smartMediaEditor.c2a9ff6d.js 13.25kb +0.00b 49.94s +13.32s ⚠️
dist/dropzone.0d183115.js 12.15kb +0.00b 49.94s +13.32s ⚠️
dist/EmojiPickerComponent.55e0a64c.js 3.73kb +0.00b 49.94s +13.32s ⚠️
dist/png-chunks-extract.94b5b9fc.js 3.58kb +0.00b 49.94s +13.32s ⚠️
dist/dropzone.cf53fd41.js 3.29kb +0.00b 49.94s +13.32s ⚠️
dist/clipboard.d25985ee.js 2.93kb +0.00b 49.94s +13.32s ⚠️
dist/ResourcedEmojiComponent.78f6ddfc.js 2.12kb +0.00b 49.94s +13.32s ⚠️
dist/browser.09200cd5.js 1.69kb +0.00b 49.94s +13.32s ⚠️
dist/media-card-analytics-error-boundary.75fac461.js 1.12kb +0.00b 49.94s +13.32s ⚠️
dist/media-picker-analytics-error-boundary.1602c912.js 966.00b +0.00b 49.94s +13.32s ⚠️
dist/simpleHasher.2a6e12b6.js 643.00b +0.00b 49.94s +13.32s ⚠️

Three.js ✅

Timings

Description Time Difference
Cold 6.99s -148.00ms
Cached 432.00ms +35.00ms ⚠️

Cold Bundles

No bundle changes detected.

Cached Bundles

No bundle changes detected.

Click here to view a detailed benchmark overview.

@mischnic mischnic deleted the namespace-default-reexport-cjs branch November 16, 2021 18:50
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

2 participants