Skip to content

Commit

Permalink
fix(config): snapshot config
Browse files Browse the repository at this point in the history
  • Loading branch information
SoonIter authored and ahabhgk committed Apr 29, 2024
1 parent 6d8ec18 commit 8d70aeb
Show file tree
Hide file tree
Showing 4 changed files with 37 additions and 10 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export default 1;
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
const a = "a";
import(`./a/${a}.js`);
it("should work when snapshot.module or snapshot.resolve only set { timestamp: true }", () => {
expect(require("./a/a").default).toBe(1);
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
module.exports = {
cache: true,
snapshot: {
module: {
timestamp: true,
},
resolve: {
timestamp: true,
},
},
};
30 changes: 20 additions & 10 deletions packages/rspack/src/config/defaults.ts
Original file line number Diff line number Diff line change
Expand Up @@ -191,16 +191,26 @@ const applySnapshotDefaults = (
snapshot: SnapshotOptions,
{ production }: { production: boolean }
) => {
F(snapshot, "module", () =>
production
? { timestamp: true, hash: true }
: { timestamp: true, hash: false }
);
F(snapshot, "resolve", () =>
production
? { timestamp: true, hash: true }
: { timestamp: true, hash: false }
);
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 = (
Expand Down

0 comments on commit 8d70aeb

Please sign in to comment.