Skip to content

Commit

Permalink
Add test for wrapping assets, even if the first ancestor is not
Browse files Browse the repository at this point in the history
  • Loading branch information
Will Binns-Smith committed Mar 31, 2022
1 parent 80c728c commit eda0627
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 0 deletions.
@@ -0,0 +1,4 @@
import value from './shouldBeWrapped';
import otherValue from './wraps';

output = [value, otherValue];
@@ -0,0 +1 @@
export default 42;
@@ -0,0 +1,5 @@
import value from './shouldBeWrapped';

eval('void 0');

export default value + 1;
21 changes: 21 additions & 0 deletions packages/core/integration-tests/test/scope-hoisting.js
Expand Up @@ -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(
Expand Down

0 comments on commit eda0627

Please sign in to comment.