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 = (