Skip to content

Commit

Permalink
Pass through includeInline
Browse files Browse the repository at this point in the history
  • Loading branch information
MonicaOlejniczak committed May 22, 2024
1 parent db3ca09 commit 0385ce4
Show file tree
Hide file tree
Showing 2 changed files with 66 additions and 2 deletions.
2 changes: 1 addition & 1 deletion packages/core/core/src/BundleGraph.js
Original file line number Diff line number Diff line change
Expand Up @@ -1600,7 +1600,7 @@ export default class BundleGraph {
}

for (let referencedBundle of this.getReferencedBundles(bundle, {
includeInline: true,
includeInline: opts?.includeInline,
})) {
bundles.add(referencedBundle);
}
Expand Down
66 changes: 65 additions & 1 deletion packages/core/integration-tests/test/BundleGraph.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@

import assert from 'assert';
import path from 'path';
import {bundle} from '@parcel/test-utils';
import {bundle, fsFixture, overlayFS} from '@parcel/test-utils';
import type {BundleGraph, BundleGroup, PackagedBundle} from '@parcel/types';

describe('BundleGraph', () => {
it('can traverse assets across bundles and contexts', async () => {
Expand Down Expand Up @@ -77,4 +78,67 @@ describe('BundleGraph', () => {
},
]);
});

describe('getBundlesInBundleGroup', () => {
let bundleGraph: BundleGraph<PackagedBundle>;
let bundleGroup: BundleGroup;
let dir = path.join(__dirname, 'get-bundles-in-bundle-group');

before(async () => {
await overlayFS.mkdirp(dir);

await fsFixture(overlayFS, dir)`
logo.svg:
<svg></svg>
index.jsx:
import logo from 'data-url:./logo.svg';
yarn.lock: {}
`;

bundleGraph = await bundle(path.join(dir, 'index.jsx'), {
inputFS: overlayFS,
});

bundleGroup = bundleGraph.getBundleGroupsContainingBundle(
bundleGraph.getBundles({includeInline: true})[0],
)[0];
});

after(async () => {
await overlayFS.rimraf(dir);
});

it('does not return inlineAssets by default', () => {
const bundles = bundleGraph.getBundlesInBundleGroup(bundleGroup);

assert.deepEqual(
bundles.map(b => b.bundleBehavior),
[null],
);
});

it('does not return inlineAssets when requested', () => {
const bundles = bundleGraph.getBundlesInBundleGroup(bundleGroup, {
includeInline: false,
});

assert.deepEqual(
bundles.map(b => b.bundleBehavior),
[null],
);
});

it('returns inlineAssets when requested', () => {
const bundles = bundleGraph.getBundlesInBundleGroup(bundleGroup, {
includeInline: true,
});

assert.deepEqual(
bundles.map(b => b.bundleBehavior),
[null, 'inline'],
);
});
});
});

0 comments on commit 0385ce4

Please sign in to comment.