diff --git a/packages/core/core/src/public/MutableBundleGraph.js b/packages/core/core/src/public/MutableBundleGraph.js index f732d9409ec..7565db82c0a 100644 --- a/packages/core/core/src/public/MutableBundleGraph.js +++ b/packages/core/core/src/public/MutableBundleGraph.js @@ -120,7 +120,17 @@ export default class MutableBundleGraph resolvedNodeId, bundleGraphEdgeTypes.references, ); - this.#graph._graph.removeEdge(dependencyNodeId, resolvedNodeId); + if ( + // This check is needed for multiple targets, when we go over the same nodes twice + this.#graph._graph.hasEdge( + dependencyNodeId, + resolvedNodeId, + bundleGraphEdgeTypes.null, + ) + ) { + //nullEdgeType + this.#graph._graph.removeEdge(dependencyNodeId, resolvedNodeId); + } if (dependency.isEntry) { this.#graph._graph.addEdge( diff --git a/packages/core/integration-tests/test/integration/scss-html-import/fa-regular-400.ttf b/packages/core/integration-tests/test/integration/scss-html-import/fa-regular-400.ttf new file mode 100644 index 00000000000..d67c5c8ffa2 Binary files /dev/null and b/packages/core/integration-tests/test/integration/scss-html-import/fa-regular-400.ttf differ diff --git a/packages/core/integration-tests/test/integration/scss-html-import/package.json b/packages/core/integration-tests/test/integration/scss-html-import/package.json new file mode 100644 index 00000000000..9144bc55d8a --- /dev/null +++ b/packages/core/integration-tests/test/integration/scss-html-import/package.json @@ -0,0 +1,18 @@ +{ + "name": "scss-import-targets", + "private": true, + "targets": { + "target1": { + "source": [ + "./target1.html" + ], + "distDir": "./target1/" + }, + "target2": { + "source": [ + "./target2.html" + ], + "distDir": "./target2/" + } + } +} \ No newline at end of file diff --git a/packages/core/integration-tests/test/integration/scss-html-import/style.scss b/packages/core/integration-tests/test/integration/scss-html-import/style.scss new file mode 100644 index 00000000000..71485406dfb --- /dev/null +++ b/packages/core/integration-tests/test/integration/scss-html-import/style.scss @@ -0,0 +1,4 @@ +@font-face { + font-family: 'Font Awesome 6 Free'; + src: url('fa-regular-400.ttf') format('truetype'); +} diff --git a/packages/core/integration-tests/test/integration/scss-html-import/target1.html b/packages/core/integration-tests/test/integration/scss-html-import/target1.html new file mode 100644 index 00000000000..2c3c823a226 --- /dev/null +++ b/packages/core/integration-tests/test/integration/scss-html-import/target1.html @@ -0,0 +1,8 @@ + + + + What's going on here + + + + diff --git a/packages/core/integration-tests/test/integration/scss-html-import/target2.html b/packages/core/integration-tests/test/integration/scss-html-import/target2.html new file mode 100644 index 00000000000..2c3c823a226 --- /dev/null +++ b/packages/core/integration-tests/test/integration/scss-html-import/target2.html @@ -0,0 +1,8 @@ + + + + What's going on here + + + + diff --git a/packages/core/integration-tests/test/integration/scss-html-import/yarn.lock b/packages/core/integration-tests/test/integration/scss-html-import/yarn.lock new file mode 100644 index 00000000000..e69de29bb2d diff --git a/packages/core/integration-tests/test/sass.js b/packages/core/integration-tests/test/sass.js index 1af3d682add..1253ea0ba07 100644 --- a/packages/core/integration-tests/test/sass.js +++ b/packages/core/integration-tests/test/sass.js @@ -79,6 +79,34 @@ describe('sass', function () { assert(css.includes('.bar')); }); + it('should support scss imports in html for >1 target', async function () { + //Repro copied from https://github.com/parcel-bundler/parcel/issues/8754 + let b = await bundle(path.join(__dirname, '/integration/scss-html-import')); + + assertBundles(b, [ + { + name: 'target1.html', + assets: ['target1.html'], + }, + { + assets: ['style.scss'], + }, + { + name: 'target2.html', + assets: ['target2.html'], + }, + { + assets: ['style.scss'], + }, + { + assets: ['fa-regular-400.ttf'], + }, + { + assets: ['fa-regular-400.ttf'], + }, + ]); + }); + it('should support requiring empty scss files', async function () { let b = await bundle( path.join(__dirname, '/integration/scss-empty/index.js'),