From 14182bf7c55be6e3dbf27aba4cc9fb74462ce9c4 Mon Sep 17 00:00:00 2001 From: SoonIter Date: Sun, 28 Apr 2024 17:09:40 +0800 Subject: [PATCH] fix(config): snapshot config {timestamp: true} and {hash: true} --- packages/rspack/src/config/defaults.ts | 28 ++++++++++++++++++-------- 1 file changed, 20 insertions(+), 8 deletions(-) diff --git a/packages/rspack/src/config/defaults.ts b/packages/rspack/src/config/defaults.ts index 7d2ae3fd167..c1a0d9ce80f 100644 --- a/packages/rspack/src/config/defaults.ts +++ b/packages/rspack/src/config/defaults.ts @@ -191,14 +191,26 @@ const applySnapshotDefaults = ( snapshot: SnapshotOptions, { production }: { production: boolean } ) => { - D(snapshot, "module", {}); - assertNotNill(snapshot.module); - D(snapshot.module, "timestamp", true); - D(snapshot.module, "hash", production); - D(snapshot, "resolve", {}); - assertNotNill(snapshot.resolve); - D(snapshot.resolve, "timestamp", true); - D(snapshot.resolve, "hash", production); + if (typeof snapshot.module === "object") { + D(snapshot.module, "timestamp", false); + D(snapshot.module, "hash", false); + } else { + F(snapshot, "module", () => + production + ? { timestamp: true, hash: true } + : { timestamp: true, hash: false } + ); + } + if (typeof snapshot.resolve === "object") { + D(snapshot.resolve, "timestamp", false); + D(snapshot.resolve, "hash", false); + } else { + F(snapshot, "resolve", () => + production + ? { timestamp: true, hash: true } + : { timestamp: true, hash: false } + ); + } }; const applyJavascriptParserOptionsDefaults = (