diff --git a/packages/core/integration-tests/test/integration/scope-hoisting/es6/retarget-namespace-single/index.js b/packages/core/integration-tests/test/integration/scope-hoisting/es6/retarget-namespace-single/index.js new file mode 100644 index 00000000000..461f6e483ef --- /dev/null +++ b/packages/core/integration-tests/test/integration/scope-hoisting/es6/retarget-namespace-single/index.js @@ -0,0 +1,5 @@ +import { v } from "./library/a.js"; + +import * as y from "./library/a.js"; + +output = [v, sideEffectNoop(y).v]; diff --git a/packages/core/integration-tests/test/integration/scope-hoisting/es6/retarget-namespace-single/library/a.js b/packages/core/integration-tests/test/integration/scope-hoisting/es6/retarget-namespace-single/library/a.js new file mode 100644 index 00000000000..d165e999022 --- /dev/null +++ b/packages/core/integration-tests/test/integration/scope-hoisting/es6/retarget-namespace-single/library/a.js @@ -0,0 +1 @@ +export * from "./b.js"; diff --git a/packages/core/integration-tests/test/integration/scope-hoisting/es6/retarget-namespace-single/library/b.js b/packages/core/integration-tests/test/integration/scope-hoisting/es6/retarget-namespace-single/library/b.js new file mode 100644 index 00000000000..0e07370072f --- /dev/null +++ b/packages/core/integration-tests/test/integration/scope-hoisting/es6/retarget-namespace-single/library/b.js @@ -0,0 +1 @@ +export {v} from "./c.js"; diff --git a/packages/core/integration-tests/test/integration/scope-hoisting/es6/retarget-namespace-single/library/c.js b/packages/core/integration-tests/test/integration/scope-hoisting/es6/retarget-namespace-single/library/c.js new file mode 100644 index 00000000000..098cc0c9e17 --- /dev/null +++ b/packages/core/integration-tests/test/integration/scope-hoisting/es6/retarget-namespace-single/library/c.js @@ -0,0 +1 @@ +export const v = 123; diff --git a/packages/core/integration-tests/test/integration/scope-hoisting/es6/retarget-namespace-single/library/package.json b/packages/core/integration-tests/test/integration/scope-hoisting/es6/retarget-namespace-single/library/package.json new file mode 100644 index 00000000000..1b95642997c --- /dev/null +++ b/packages/core/integration-tests/test/integration/scope-hoisting/es6/retarget-namespace-single/library/package.json @@ -0,0 +1,3 @@ +{ + "sideEffects": false +} diff --git a/packages/core/integration-tests/test/scope-hoisting.js b/packages/core/integration-tests/test/scope-hoisting.js index fcbe8e2b4d9..ec15fdaaeae 100644 --- a/packages/core/integration-tests/test/scope-hoisting.js +++ b/packages/core/integration-tests/test/scope-hoisting.js @@ -2224,6 +2224,17 @@ describe('scope hoisting', function () { ]); }); + it('should correctly retarget dependencies when both namespace and indvidual export are used', async function () { + let b = await bundle( + path.join( + __dirname, + '/integration/scope-hoisting/es6/retarget-namespace-single/index.js', + ), + ); + let output = await run(b); + assert.deepEqual(output, [123, 123]); + }); + it('should correctly handle circular dependencies', async function () { let b = await bundle( path.join(__dirname, '/integration/scope-hoisting/es6/circular/a.mjs'), diff --git a/packages/core/test-utils/src/utils.js b/packages/core/test-utils/src/utils.js index eb2788ccd3a..8a6a3c4ffcc 100644 --- a/packages/core/test-utils/src/utils.js +++ b/packages/core/test-utils/src/utils.js @@ -338,7 +338,7 @@ export async function runBundles( // A utility to prevent optimizers from removing side-effect-free code needed for testing // $FlowFixMe[prop-missing] - ctx.sideEffectNoop = () => {}; + ctx.sideEffectNoop = v => v; vm.createContext(ctx); let esmOutput;