Skip to content

Commit a23cfae

Browse files
authored
Merge pull request #302 from webdeveric/fix/merge
fix: ignore `ENOENT` error during merge
2 parents 6c93b2b + 8b6247c commit a23cfae

File tree

3 files changed

+16
-0
lines changed

3 files changed

+16
-0
lines changed

cspell.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
"Analyse",
66
"chunkhash",
77
"conventionalcommits",
8+
"ENOENT",
89
"nvmrc",
910
"postbuild",
1011
"subresource",

src/plugin.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -422,6 +422,13 @@ export class WebpackAssetsManifest implements WebpackPluginInstance {
422422
this.set(key, oldValue);
423423
}
424424
}
425+
} catch (error) {
426+
// Ignore ENOENT errors when merging.
427+
if (error instanceof Error && 'code' in error && error.code === 'ENOENT') {
428+
return;
429+
}
430+
431+
throw error;
425432
} finally {
426433
this.#isMerging = false;
427434
}

test/plugin.test.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -523,6 +523,14 @@ describe('Options', () => {
523523
);
524524
});
525525

526+
it('Should not error if output file does not exist before merging', async () => {
527+
const { run } = create(configs.hello(), {
528+
merge: true,
529+
});
530+
531+
await expect(run()).resolves.not.toThrow();
532+
});
533+
526534
it('Can customize during merge', async () => {
527535
const mergingResults: boolean[] = [];
528536
const { manifest, run } = create(configs.hello(), {

0 commit comments

Comments
 (0)