diff --git a/packages/core/integration-tests/test/integration/scope-hoisting/es6/multiple-ancestors-wrap/index.js b/packages/core/integration-tests/test/integration/scope-hoisting/es6/multiple-ancestors-wrap/index.js new file mode 100644 index 00000000000..ebf8b39436c --- /dev/null +++ b/packages/core/integration-tests/test/integration/scope-hoisting/es6/multiple-ancestors-wrap/index.js @@ -0,0 +1,4 @@ +import value from './shouldBeWrapped'; +import otherValue from './wraps'; + +output = [value, otherValue]; diff --git a/packages/core/integration-tests/test/integration/scope-hoisting/es6/multiple-ancestors-wrap/shouldBeWrapped.js b/packages/core/integration-tests/test/integration/scope-hoisting/es6/multiple-ancestors-wrap/shouldBeWrapped.js new file mode 100644 index 00000000000..7a4e8a723a4 --- /dev/null +++ b/packages/core/integration-tests/test/integration/scope-hoisting/es6/multiple-ancestors-wrap/shouldBeWrapped.js @@ -0,0 +1 @@ +export default 42; diff --git a/packages/core/integration-tests/test/integration/scope-hoisting/es6/multiple-ancestors-wrap/wraps.js b/packages/core/integration-tests/test/integration/scope-hoisting/es6/multiple-ancestors-wrap/wraps.js new file mode 100644 index 00000000000..96d9fbd4023 --- /dev/null +++ b/packages/core/integration-tests/test/integration/scope-hoisting/es6/multiple-ancestors-wrap/wraps.js @@ -0,0 +1,5 @@ +import value from './shouldBeWrapped'; + +eval('void 0'); + +export default value + 1; diff --git a/packages/core/integration-tests/test/scope-hoisting.js b/packages/core/integration-tests/test/scope-hoisting.js index b1632bfc83e..39592f262c4 100644 --- a/packages/core/integration-tests/test/scope-hoisting.js +++ b/packages/core/integration-tests/test/scope-hoisting.js @@ -1003,6 +1003,27 @@ describe('scope hoisting', function () { assert.deepEqual(output, ['a', true]); }); + it('wraps an asset if any of its ancestors is wrapped, even if one is not', async function () { + let b = await bundle( + path.join( + __dirname, + '/integration/scope-hoisting/es6/multiple-ancestors-wrap/index.js', + ), + ); + + let contents = await outputFS.readFile( + b.getBundles()[0].filePath, + 'utf8', + ); + assert.strictEqual( + contents.match(/parcelRequire.register\(/g).length, + 2 /* once for parent asset, once for child wrapped asset */, + ); + + let output = await run(b); + assert.deepEqual(output, [42, 43]); + }); + it('supports importing from a wrapped asset with multiple bailouts', async function () { let b = await bundle( path.join(