From b934741bd6e06e39f43abae0a7df7fe96d7687a0 Mon Sep 17 00:00:00 2001 From: Agnieszka Gawrys Date: Thu, 8 Sep 2022 07:58:05 -0400 Subject: [PATCH] Consider sibling in available assets to younger sibling for parallel deps (#8414) --- .../experimental/src/ExperimentalBundler.js | 1 + packages/core/integration-tests/test/html.js | 44 +++++++++++++++++++ 2 files changed, 45 insertions(+) diff --git a/packages/bundlers/experimental/src/ExperimentalBundler.js b/packages/bundlers/experimental/src/ExperimentalBundler.js index da18a9018ad..a5f8d26b012 100644 --- a/packages/bundlers/experimental/src/ExperimentalBundler.js +++ b/packages/bundlers/experimental/src/ExperimentalBundler.js @@ -816,6 +816,7 @@ function createIdealGraph( parallelAvailability, assetsFromBundleRoot, ); + parallelAvailability.add(child); //The next sibling should have older sibling available via parallel } } } diff --git a/packages/core/integration-tests/test/html.js b/packages/core/integration-tests/test/html.js index f4bb022b218..ca014eb2d96 100644 --- a/packages/core/integration-tests/test/html.js +++ b/packages/core/integration-tests/test/html.js @@ -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'),