Skip to content

Commit d3b7342

Browse files
Pass through includeInline (#9730)
1 parent db3ca09 commit d3b7342

File tree

2 files changed

+66
-2
lines changed

2 files changed

+66
-2
lines changed

packages/core/core/src/BundleGraph.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -1600,7 +1600,7 @@ export default class BundleGraph {
16001600
}
16011601

16021602
for (let referencedBundle of this.getReferencedBundles(bundle, {
1603-
includeInline: true,
1603+
includeInline: opts?.includeInline,
16041604
})) {
16051605
bundles.add(referencedBundle);
16061606
}

packages/core/integration-tests/test/BundleGraph.js

+65-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,8 @@
22

33
import assert from 'assert';
44
import path from 'path';
5-
import {bundle} from '@parcel/test-utils';
5+
import {bundle, fsFixture, overlayFS} from '@parcel/test-utils';
6+
import type {BundleGraph, BundleGroup, PackagedBundle} from '@parcel/types';
67

78
describe('BundleGraph', () => {
89
it('can traverse assets across bundles and contexts', async () => {
@@ -77,4 +78,67 @@ describe('BundleGraph', () => {
7778
},
7879
]);
7980
});
81+
82+
describe('getBundlesInBundleGroup', () => {
83+
let bundleGraph: BundleGraph<PackagedBundle>;
84+
let bundleGroup: BundleGroup;
85+
let dir = path.join(__dirname, 'get-bundles-in-bundle-group');
86+
87+
before(async () => {
88+
await overlayFS.mkdirp(dir);
89+
90+
await fsFixture(overlayFS, dir)`
91+
logo.svg:
92+
<svg></svg>
93+
94+
index.jsx:
95+
import logo from 'data-url:./logo.svg';
96+
97+
yarn.lock: {}
98+
`;
99+
100+
bundleGraph = await bundle(path.join(dir, 'index.jsx'), {
101+
inputFS: overlayFS,
102+
});
103+
104+
bundleGroup = bundleGraph.getBundleGroupsContainingBundle(
105+
bundleGraph.getBundles({includeInline: true})[0],
106+
)[0];
107+
});
108+
109+
after(async () => {
110+
await overlayFS.rimraf(dir);
111+
});
112+
113+
it('does not return inlineAssets by default', () => {
114+
const bundles = bundleGraph.getBundlesInBundleGroup(bundleGroup);
115+
116+
assert.deepEqual(
117+
bundles.map(b => b.bundleBehavior),
118+
[null],
119+
);
120+
});
121+
122+
it('does not return inlineAssets when requested', () => {
123+
const bundles = bundleGraph.getBundlesInBundleGroup(bundleGroup, {
124+
includeInline: false,
125+
});
126+
127+
assert.deepEqual(
128+
bundles.map(b => b.bundleBehavior),
129+
[null],
130+
);
131+
});
132+
133+
it('returns inlineAssets when requested', () => {
134+
const bundles = bundleGraph.getBundlesInBundleGroup(bundleGroup, {
135+
includeInline: true,
136+
});
137+
138+
assert.deepEqual(
139+
bundles.map(b => b.bundleBehavior),
140+
[null, 'inline'],
141+
);
142+
});
143+
});
80144
});

0 commit comments

Comments
 (0)