Skip to content

Commit db2f2fc

Browse files
authored
Use old namespace reexport code pattern for better Node support (#4826)
1 parent b87a2e5 commit db2f2fc

22 files changed

Lines changed: 34 additions & 36 deletions

File tree

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
3030
"prepublishOnly": "node scripts/check-release.js",
3131
"release": "node scripts/release.js",
3232
"test": "npm run build && npm run test:all",
33+
"test:update-snapshots": "node scripts/update-snapshots.js",
3334
"test:cjs": "npm run build:cjs && npm run test:only",
3435
"test:quick": "mocha -b test/test.js",
3536
"test:all": "concurrently --kill-others-on-fail -c green,blue,magenta,cyan,red 'npm:test:only' 'npm:test:browser' 'npm:test:typescript' 'npm:test:leak' 'npm:test:package' 'npm:test:options'",

src/finalisers/shared/getExportBlock.ts

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ export function getExportBlock(
1818
externalLiveBindings: boolean,
1919
mechanism = 'return '
2020
): string {
21-
const { _, cnst, getDirectReturnFunction, getFunctionIntro, getPropertyAccess, n, s } = snippets;
21+
const { _, getDirectReturnFunction, getFunctionIntro, getPropertyAccess, n, s } = snippets;
2222
if (!namedExportsMode) {
2323
return `${n}${n}${mechanism}${getSingleDefaultExport(
2424
exports,
@@ -96,13 +96,10 @@ export function getExportBlock(
9696
t,
9797
snippets
9898
)}${s}${n}}`;
99-
exportBlock +=
100-
cnst === 'var' && specifier.needsLiveBinding
101-
? `Object.keys(${name}).forEach(${getFunctionIntro(['k'], {
102-
isAsync: false,
103-
name: null
104-
})}${copyPropertyIfNecessary});`
105-
: `for${_}(${cnst} k in ${name})${_}${copyPropertyIfNecessary}`;
99+
exportBlock += `Object.keys(${name}).forEach(${getFunctionIntro(['k'], {
100+
isAsync: false,
101+
name: null
102+
})}${copyPropertyIfNecessary});`;
106103
}
107104
}
108105
}

test/form/samples/generated-code-compact/const-bindings-false/_expected/amd.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

test/form/samples/generated-code-compact/const-bindings-false/_expected/cjs.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

test/form/samples/generated-code-compact/const-bindings-false/_expected/iife.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

test/form/samples/generated-code-compact/const-bindings-false/_expected/umd.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

test/form/samples/generated-code-compact/const-bindings-true/_expected/amd.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

test/form/samples/generated-code-compact/const-bindings-true/_expected/cjs.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

test/form/samples/generated-code-compact/const-bindings-true/_expected/iife.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

test/form/samples/generated-code-compact/const-bindings-true/_expected/umd.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)