Skip to content

Commit

Permalink
Consider sibling in available assets to younger sibling for parallel …
Browse files Browse the repository at this point in the history
…deps (#8414)
  • Loading branch information
AGawrys committed Sep 8, 2022
1 parent 1572df0 commit b934741
Show file tree
Hide file tree
Showing 2 changed files with 45 additions and 0 deletions.
1 change: 1 addition & 0 deletions packages/bundlers/experimental/src/ExperimentalBundler.js
Expand Up @@ -816,6 +816,7 @@ function createIdealGraph(
parallelAvailability,
assetsFromBundleRoot,
);
parallelAvailability.add(child); //The next sibling should have older sibling available via parallel
}
}
}
Expand Down
44 changes: 44 additions & 0 deletions packages/core/integration-tests/test/html.js
Expand Up @@ -2809,6 +2809,50 @@ describe('html', function () {
});
});

it('should share older JS sibling (script) assets to younger siblings', async function () {
// JS script tags are siblings to a common parent, and are marked as such by parallel dependency priority
// Becuase of load order any older sibling (and it's assets) are loaded before any subsequent sibling
// Which means no younger sibling should have to reference sibling bundles for assets in them
let b = await bundle(
path.join(
__dirname,
'integration/scope-hoisting/es6/sibling-dependencies/index.html',
),
);
assertBundles(b, [
{
name: 'index.html',
assets: ['index.html'],
},
{
assets: ['a.js', 'esmodule-helpers.js'],
},
{
assets: ['b.js'],
},
]);

let youngerSibling; // bundle containing younger sibling, b.js
let olderSibling; // bundle containing old sibling, a.js
b.traverseBundles(bundle => {
bundle.traverseAssets(asset => {
if (asset.filePath.includes('b.js')) {
youngerSibling = bundle;
} else if (asset.filePath.includes('a.js')) {
olderSibling = bundle;
}
});
});

assert(
b.getReferencedBundles(youngerSibling).filter(b => b == olderSibling)
.length == 0,
);

let res = await run(b, {output: null}, {require: false});
assert.equal(res.output, 'a');
});

it('should escape quotes in inline style attributes and style tags', async function () {
let b = await bundle(
path.join(__dirname, 'integration/html-inline-escape/style.html'),
Expand Down

0 comments on commit b934741

Please sign in to comment.