From 22a98dc15d10a2c43119645e88a9ab8915a0f834 Mon Sep 17 00:00:00 2001 From: Niklas Mischkulnig <4586894+mischnic@users.noreply.github.com> Date: Tue, 22 Nov 2022 10:59:53 +0100 Subject: [PATCH] Add test --- .../scope-hoisting/es6/re-export-all-override/a.js | 3 +++ .../scope-hoisting/es6/re-export-all-override/b.js | 8 ++++++++ .../scope-hoisting/es6/re-export-all-override/c.js | 5 +++++ .../es6/re-export-all-override/index.js | 3 +++ .../core/integration-tests/test/scope-hoisting.js | 12 ++++++++++++ 5 files changed, 31 insertions(+) create mode 100644 packages/core/integration-tests/test/integration/scope-hoisting/es6/re-export-all-override/a.js create mode 100644 packages/core/integration-tests/test/integration/scope-hoisting/es6/re-export-all-override/b.js create mode 100644 packages/core/integration-tests/test/integration/scope-hoisting/es6/re-export-all-override/c.js create mode 100644 packages/core/integration-tests/test/integration/scope-hoisting/es6/re-export-all-override/index.js diff --git a/packages/core/integration-tests/test/integration/scope-hoisting/es6/re-export-all-override/a.js b/packages/core/integration-tests/test/integration/scope-hoisting/es6/re-export-all-override/a.js new file mode 100644 index 00000000000..7973586a0f6 --- /dev/null +++ b/packages/core/integration-tests/test/integration/scope-hoisting/es6/re-export-all-override/a.js @@ -0,0 +1,3 @@ +import { foo, c } from "./b.js"; + +export default foo() + c; diff --git a/packages/core/integration-tests/test/integration/scope-hoisting/es6/re-export-all-override/b.js b/packages/core/integration-tests/test/integration/scope-hoisting/es6/re-export-all-override/b.js new file mode 100644 index 00000000000..48594e8d61d --- /dev/null +++ b/packages/core/integration-tests/test/integration/scope-hoisting/es6/re-export-all-override/b.js @@ -0,0 +1,8 @@ +import { foo as old } from "./c"; +export * from "./c"; + +function foo() { + return "fooB" + old(); +} + +export { foo }; diff --git a/packages/core/integration-tests/test/integration/scope-hoisting/es6/re-export-all-override/c.js b/packages/core/integration-tests/test/integration/scope-hoisting/es6/re-export-all-override/c.js new file mode 100644 index 00000000000..9f3df1dbd3f --- /dev/null +++ b/packages/core/integration-tests/test/integration/scope-hoisting/es6/re-export-all-override/c.js @@ -0,0 +1,5 @@ +export function foo() { + return "fooC"; +} + +export const c = "C"; diff --git a/packages/core/integration-tests/test/integration/scope-hoisting/es6/re-export-all-override/index.js b/packages/core/integration-tests/test/integration/scope-hoisting/es6/re-export-all-override/index.js new file mode 100644 index 00000000000..63e96797b22 --- /dev/null +++ b/packages/core/integration-tests/test/integration/scope-hoisting/es6/re-export-all-override/index.js @@ -0,0 +1,3 @@ +if (Date.now() > 0) { + output = require("./a.js").default; +} diff --git a/packages/core/integration-tests/test/scope-hoisting.js b/packages/core/integration-tests/test/scope-hoisting.js index fcbe8e2b4d9..9ac369ecfab 100644 --- a/packages/core/integration-tests/test/scope-hoisting.js +++ b/packages/core/integration-tests/test/scope-hoisting.js @@ -397,6 +397,18 @@ describe('scope hoisting', function () { assert.equal(output, 15); }); + it('supports re-exporting all exports and overriding individual exports', async function () { + let b = await bundle( + path.join( + __dirname, + '/integration/scope-hoisting/es6/re-export-all-override/index.js', + ), + ); + + let output = await run(b); + assert.strictEqual(output, 'fooBfooCC'); + }); + it('can import from a different bundle via a re-export (1)', async function () { let b = await bundle( path.join(