Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

Consider sibling in available assets to younger sibling for parallel deps #8414

Merged
merged 5 commits into from Sep 8, 2022
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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