Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -314,11 +314,11 @@ function* emitOutputResults(
}

// Initially assume all previous assets files have been removed
const removedAssetFiles = new Map(previousAssetsInfo);
const removedAssetFiles = new Set(previousAssetsInfo);
for (const { source, destination } of assetFiles) {
removedAssetFiles.delete(source);
removedAssetFiles.delete(destination);

if (!previousAssetsInfo.has(source)) {
if (!previousAssetsInfo.has(destination)) {
incrementalResult.added.push(destination);
incrementalResult.background = false;
} else if (changes.modified.has(source)) {
Expand Down Expand Up @@ -353,7 +353,7 @@ function* emitOutputResults(
path,
type,
})),
...Array.from(removedAssetFiles.values(), (path) => ({
...Array.from(removedAssetFiles, (path) => ({
path,
type: BuildOutputFileType.Browser,
})),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,5 +76,39 @@ describeBuilder(buildApplication, APPLICATION_BUILDER_INFO, (harness) => {
},
]);
});

it('remove all outputs of a deleted asset copied to multiple destinations', async () => {
harness.useTarget('build', {
...BASE_OPTIONS,
assets: [
{
glob: '**/*',
input: 'public',
},
{
glob: '**/*',
input: 'public',
output: 'static',
},
],
watch: true,
});

await harness.executeWithCases([
async ({ result }) => {
expect(result?.success).toBeTrue();
harness.expectFile('dist/browser/asset.txt').toExist();
harness.expectFile('dist/browser/static/asset.txt').toExist();

await harness.removeFile('public/asset.txt');
},

({ result }) => {
expect(result?.success).toBeTrue();
harness.expectFile('dist/browser/asset.txt').toNotExist();
harness.expectFile('dist/browser/static/asset.txt').toNotExist();
},
]);
});
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ export interface RebuildState {
string,
{ hash: string; type: BuildOutputFileType; path: string }
>;
previousAssetsInfo: ReadonlyMap<string, string>;
previousAssetsInfo: ReadonlySet<string>;
templateUpdates?: Map<string, string>;
}

Expand Down Expand Up @@ -176,9 +176,8 @@ export class ExecutionResult {
previousOutputInfo: new Map(
this.outputFiles.map(({ path, hash, type }) => [`${type}:${path}`, { hash, type, path }]),
),
previousAssetsInfo: new Map(
this.assetFiles.map(({ source, destination }) => [source, destination]),
),
// Tracked by destination since one source can be copied to several outputs (e.g. per locale).
previousAssetsInfo: new Set(this.assetFiles.map(({ destination }) => destination)),
templateUpdates: this.templateUpdates,
};
}
Expand Down
Loading