From 552801d61bb2372f2858dc89c4e372b53df44d1b Mon Sep 17 00:00:00 2001 From: Eric Eldredge Date: Thu, 14 Apr 2022 19:56:05 -0400 Subject: [PATCH 1/4] Add test for chained reexports from a hybrid module This captures a case where a CJS export is missing. --- .../scope-hoisting/es6/re-export-hybrid/a.js | 3 +++ .../scope-hoisting/es6/re-export-hybrid/b.js | 1 + .../scope-hoisting/es6/re-export-hybrid/c.js | 2 ++ .../scope-hoisting/es6/re-export-hybrid/d.js | 1 + .../core/integration-tests/test/scope-hoisting.js | 11 +++++++++++ 5 files changed, 18 insertions(+) create mode 100644 packages/core/integration-tests/test/integration/scope-hoisting/es6/re-export-hybrid/a.js create mode 100644 packages/core/integration-tests/test/integration/scope-hoisting/es6/re-export-hybrid/b.js create mode 100644 packages/core/integration-tests/test/integration/scope-hoisting/es6/re-export-hybrid/c.js create mode 100644 packages/core/integration-tests/test/integration/scope-hoisting/es6/re-export-hybrid/d.js diff --git a/packages/core/integration-tests/test/integration/scope-hoisting/es6/re-export-hybrid/a.js b/packages/core/integration-tests/test/integration/scope-hoisting/es6/re-export-hybrid/a.js new file mode 100644 index 00000000000..d1d39e3bc64 --- /dev/null +++ b/packages/core/integration-tests/test/integration/scope-hoisting/es6/re-export-hybrid/a.js @@ -0,0 +1,3 @@ +import {foo, bar} from './b'; + +output = foo + bar; diff --git a/packages/core/integration-tests/test/integration/scope-hoisting/es6/re-export-hybrid/b.js b/packages/core/integration-tests/test/integration/scope-hoisting/es6/re-export-hybrid/b.js new file mode 100644 index 00000000000..34a28aa08d0 --- /dev/null +++ b/packages/core/integration-tests/test/integration/scope-hoisting/es6/re-export-hybrid/b.js @@ -0,0 +1 @@ +export * from './c'; diff --git a/packages/core/integration-tests/test/integration/scope-hoisting/es6/re-export-hybrid/c.js b/packages/core/integration-tests/test/integration/scope-hoisting/es6/re-export-hybrid/c.js new file mode 100644 index 00000000000..29a35de9403 --- /dev/null +++ b/packages/core/integration-tests/test/integration/scope-hoisting/es6/re-export-hybrid/c.js @@ -0,0 +1,2 @@ +export foo from './d'; +export const bar = require('./d'); diff --git a/packages/core/integration-tests/test/integration/scope-hoisting/es6/re-export-hybrid/d.js b/packages/core/integration-tests/test/integration/scope-hoisting/es6/re-export-hybrid/d.js new file mode 100644 index 00000000000..bd816eaba4c --- /dev/null +++ b/packages/core/integration-tests/test/integration/scope-hoisting/es6/re-export-hybrid/d.js @@ -0,0 +1 @@ +module.exports = 1; diff --git a/packages/core/integration-tests/test/scope-hoisting.js b/packages/core/integration-tests/test/scope-hoisting.js index 39592f262c4..8f8820eb9cb 100644 --- a/packages/core/integration-tests/test/scope-hoisting.js +++ b/packages/core/integration-tests/test/scope-hoisting.js @@ -1985,6 +1985,17 @@ describe('scope hoisting', function () { assert(new output[3]() instanceof output[2]); }); + it('should support chained reexports from hybrid files', async function () { + let b = await bundle( + path.join( + __dirname, + '/integration/scope-hoisting/es6/re-export-hybrid/a.js', + ), + ); + let output = await run(b); + assert.deepEqual(output, 2); + }); + it('support chained namespace reexports of CommonJS', async function () { let b = await bundle( path.join( From f2ed68afd3b2474da860acf499f35c59454cc167 Mon Sep 17 00:00:00 2001 From: Eric Eldredge Date: Tue, 19 Apr 2022 19:18:07 -0400 Subject: [PATCH 2/4] Add test for reexports as default from a hybrid module This captures a case where packaging fails with `Asset was skipped or not found`. --- .../scope-hoisting/es6/re-export-default-hybrid/a.js | 3 +++ .../scope-hoisting/es6/re-export-default-hybrid/b.js | 2 ++ .../scope-hoisting/es6/re-export-default-hybrid/c.js | 2 ++ .../scope-hoisting/es6/re-export-default-hybrid/d.js | 1 + .../core/integration-tests/test/scope-hoisting.js | 11 +++++++++++ 5 files changed, 19 insertions(+) create mode 100644 packages/core/integration-tests/test/integration/scope-hoisting/es6/re-export-default-hybrid/a.js create mode 100644 packages/core/integration-tests/test/integration/scope-hoisting/es6/re-export-default-hybrid/b.js create mode 100644 packages/core/integration-tests/test/integration/scope-hoisting/es6/re-export-default-hybrid/c.js create mode 100644 packages/core/integration-tests/test/integration/scope-hoisting/es6/re-export-default-hybrid/d.js diff --git a/packages/core/integration-tests/test/integration/scope-hoisting/es6/re-export-default-hybrid/a.js b/packages/core/integration-tests/test/integration/scope-hoisting/es6/re-export-default-hybrid/a.js new file mode 100644 index 00000000000..7f129231c85 --- /dev/null +++ b/packages/core/integration-tests/test/integration/scope-hoisting/es6/re-export-default-hybrid/a.js @@ -0,0 +1,3 @@ +import b from './b'; + +output = b.foo + b.bar; diff --git a/packages/core/integration-tests/test/integration/scope-hoisting/es6/re-export-default-hybrid/b.js b/packages/core/integration-tests/test/integration/scope-hoisting/es6/re-export-default-hybrid/b.js new file mode 100644 index 00000000000..1d134aa51d1 --- /dev/null +++ b/packages/core/integration-tests/test/integration/scope-hoisting/es6/re-export-default-hybrid/b.js @@ -0,0 +1,2 @@ +import * as c from './c'; +export default c; diff --git a/packages/core/integration-tests/test/integration/scope-hoisting/es6/re-export-default-hybrid/c.js b/packages/core/integration-tests/test/integration/scope-hoisting/es6/re-export-default-hybrid/c.js new file mode 100644 index 00000000000..29a35de9403 --- /dev/null +++ b/packages/core/integration-tests/test/integration/scope-hoisting/es6/re-export-default-hybrid/c.js @@ -0,0 +1,2 @@ +export foo from './d'; +export const bar = require('./d'); diff --git a/packages/core/integration-tests/test/integration/scope-hoisting/es6/re-export-default-hybrid/d.js b/packages/core/integration-tests/test/integration/scope-hoisting/es6/re-export-default-hybrid/d.js new file mode 100644 index 00000000000..bd816eaba4c --- /dev/null +++ b/packages/core/integration-tests/test/integration/scope-hoisting/es6/re-export-default-hybrid/d.js @@ -0,0 +1 @@ +module.exports = 1; diff --git a/packages/core/integration-tests/test/scope-hoisting.js b/packages/core/integration-tests/test/scope-hoisting.js index 8f8820eb9cb..74a59ad32e8 100644 --- a/packages/core/integration-tests/test/scope-hoisting.js +++ b/packages/core/integration-tests/test/scope-hoisting.js @@ -1996,6 +1996,17 @@ describe('scope hoisting', function () { assert.deepEqual(output, 2); }); + it('should support chained reexports as default from hybrid files', async function () { + let b = await bundle( + path.join( + __dirname, + '/integration/scope-hoisting/es6/re-export-default-hybrid/a.js', + ), + ); + let output = await run(b); + assert.deepEqual(output, 2); + }); + it('support chained namespace reexports of CommonJS', async function () { let b = await bundle( path.join( From 261824da59d407e10caf3013943bb284f5e22dee Mon Sep 17 00:00:00 2001 From: Eric Eldredge Date: Tue, 19 Apr 2022 19:57:22 -0400 Subject: [PATCH 3/4] Use strict equality checks --- packages/core/integration-tests/test/scope-hoisting.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/core/integration-tests/test/scope-hoisting.js b/packages/core/integration-tests/test/scope-hoisting.js index 74a59ad32e8..70a6d0e36b5 100644 --- a/packages/core/integration-tests/test/scope-hoisting.js +++ b/packages/core/integration-tests/test/scope-hoisting.js @@ -1993,7 +1993,7 @@ describe('scope hoisting', function () { ), ); let output = await run(b); - assert.deepEqual(output, 2); + assert.strictEqual(output, 2); }); it('should support chained reexports as default from hybrid files', async function () { @@ -2004,7 +2004,7 @@ describe('scope hoisting', function () { ), ); let output = await run(b); - assert.deepEqual(output, 2); + assert.strictEqual(output, 2); }); it('support chained namespace reexports of CommonJS', async function () { From bade66933a51744d72c411a934b4d7e7f6ad2105 Mon Sep 17 00:00:00 2001 From: lettertwo Date: Thu, 21 Apr 2022 15:57:31 -0400 Subject: [PATCH 4/4] nit: match similar test terminology --- packages/core/integration-tests/test/scope-hoisting.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/core/integration-tests/test/scope-hoisting.js b/packages/core/integration-tests/test/scope-hoisting.js index 70a6d0e36b5..a82408b448e 100644 --- a/packages/core/integration-tests/test/scope-hoisting.js +++ b/packages/core/integration-tests/test/scope-hoisting.js @@ -1985,7 +1985,7 @@ describe('scope hoisting', function () { assert(new output[3]() instanceof output[2]); }); - it('should support chained reexports from hybrid files', async function () { + it('should support chained reexports from hybrid modules', async function () { let b = await bundle( path.join( __dirname, @@ -1996,7 +1996,7 @@ describe('scope hoisting', function () { assert.strictEqual(output, 2); }); - it('should support chained reexports as default from hybrid files', async function () { + it('should support chained reexports as default from hybrid modules', async function () { let b = await bundle( path.join( __dirname,