Skip to content

Commit

Permalink
Missing edge for multiple targets (parcel-bundler#8854)
Browse files Browse the repository at this point in the history
* fix
  • Loading branch information
AGawrys authored Feb 27, 2023
1 parent 359f6bb commit 0cf2aff
Show file tree
Hide file tree
Showing 8 changed files with 77 additions and 1 deletion.
12 changes: 11 additions & 1 deletion packages/core/core/src/public/MutableBundleGraph.js
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
{
"name": "scss-import-targets",
"private": true,
"targets": {
"target1": {
"source": [
"./target1.html"
],
"distDir": "./target1/"
},
"target2": {
"source": [
"./target2.html"
],
"distDir": "./target2/"
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
@font-face {
font-family: 'Font Awesome 6 Free';
src: url('fa-regular-400.ttf') format('truetype');
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<!DOCTYPE html>
<html lang="en">
<head>
<title>What's going on here</title>
<link href="style.scss" rel="stylesheet" type="text/css" />
</head>
<body></body>
</html>
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<!DOCTYPE html>
<html lang="en">
<head>
<title>What's going on here</title>
<link href="style.scss" rel="stylesheet" type="text/css" />
</head>
<body></body>
</html>
Empty file.
28 changes: 28 additions & 0 deletions packages/core/integration-tests/test/sass.js
Original file line number Diff line number Diff line change
Expand Up @@ -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'),
Expand Down

0 comments on commit 0cf2aff

Please sign in to comment.