From 4ce0a9b9b5ede353b15366088b02c28602baf070 Mon Sep 17 00:00:00 2001 From: Agnieszka Gawrys Date: Mon, 22 Aug 2022 14:42:25 -0400 Subject: [PATCH 1/2] consider sibling for parallel availability fix --- .../experimental/src/ExperimentalBundler.js | 1 + packages/core/integration-tests/test/html.js | 24 +++++++++++++++++++ 2 files changed, 25 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..724630720cc 100644 --- a/packages/core/integration-tests/test/html.js +++ b/packages/core/integration-tests/test/html.js @@ -2809,6 +2809,30 @@ describe('html', function () { }); }); + it('should insert the prelude for sibling bundles referenced in HTML', async function () { + 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 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'), From d66a974316305a97f8f72b781b63c45a0e2b33e5 Mon Sep 17 00:00:00 2001 From: Agnieszka Gawrys Date: Tue, 23 Aug 2022 14:32:18 -0400 Subject: [PATCH 2/2] Add test --- packages/core/integration-tests/test/html.js | 22 +++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) diff --git a/packages/core/integration-tests/test/html.js b/packages/core/integration-tests/test/html.js index 724630720cc..ca014eb2d96 100644 --- a/packages/core/integration-tests/test/html.js +++ b/packages/core/integration-tests/test/html.js @@ -2809,7 +2809,10 @@ describe('html', function () { }); }); - it('should insert the prelude for sibling bundles referenced in HTML', async 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, @@ -2829,6 +2832,23 @@ describe('html', function () { }, ]); + 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'); });