Skip to content

Commit 2aa753c

Browse files
authored
Fix missing content key in symbol prop when asset is removed (#9627)
1 parent 0b77a56 commit 2aa753c

File tree

2 files changed

+48
-2
lines changed

2 files changed

+48
-2
lines changed

packages/core/core/src/requests/AssetGraphRequest.js

+15-2
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,7 @@ export class AssetGraphBuilder {
108108
queue: PromiseQueue<mixed>;
109109
changedAssets: Map<string, Asset>;
110110
changedAssetsPropagation: Set<string>;
111+
prevChangedAssetsPropagation: ?Set<string>;
111112
optionsRef: SharedReference;
112113
options: ParcelOptions;
113114
api: RunAPI<AssetGraphRequestResult>;
@@ -146,8 +147,9 @@ export class AssetGraphBuilder {
146147
this.previousSymbolPropagationErrors =
147148
prevResult?.previousSymbolPropagationErrors ?? new Map();
148149
this.changedAssets = prevResult?.changedAssets ?? new Map();
149-
this.changedAssetsPropagation =
150-
prevResult?.changedAssetsPropagation ?? new Set();
150+
this.changedAssetsPropagation = new Set();
151+
this.prevChangedAssetsPropagation = prevResult?.changedAssetsPropagation;
152+
151153
this.assetGraph = assetGraph;
152154
this.optionsRef = optionsRef;
153155
this.options = options;
@@ -230,6 +232,17 @@ export class AssetGraphBuilder {
230232
visit(rootNodeId);
231233
await this.queue.run();
232234

235+
if (this.prevChangedAssetsPropagation) {
236+
// Add any previously seen Assets that have not been propagated yet to
237+
// 'this.changedAssetsPropagation', but only if they still remain in the graph
238+
// as they could have been removed since the last build
239+
for (let assetId of this.prevChangedAssetsPropagation) {
240+
if (this.assetGraph.hasContentKey(assetId)) {
241+
this.changedAssetsPropagation.add(assetId);
242+
}
243+
}
244+
}
245+
233246
if (errors.length) {
234247
this.api.storeResult(
235248
{
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
import assert from 'assert';
2+
import path from 'path';
3+
import {bundler, run, overlayFS, fsFixture} from '@parcel/test-utils';
4+
5+
describe('symbol propagation', () => {
6+
it('should handle removed assets from previous failed builds', async () => {
7+
await fsFixture(overlayFS, __dirname)`
8+
broken.js:
9+
module.exports = require('./missing.js');
10+
working.js:
11+
module.exports = 'ITS WORKING';
12+
index.js:
13+
module.exports = require('./broken.js');`;
14+
15+
let b = bundler(path.join(__dirname, 'index.js'), {
16+
inputFS: overlayFS,
17+
shouldDisableCache: false,
18+
});
19+
20+
await assert.rejects(() => b.run(), {
21+
message: `Failed to resolve './missing.js' from './broken.js'`,
22+
});
23+
24+
await overlayFS.writeFile(
25+
path.join(__dirname, 'index.js'),
26+
`module.exports = require('./working.js');`,
27+
);
28+
29+
let {bundleGraph} = await b.run();
30+
31+
assert(await run(bundleGraph), 'ITS WORKING');
32+
});
33+
});

0 commit comments

Comments
 (0)