-
-
Notifications
You must be signed in to change notification settings - Fork 641
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
22b6027
commit 52d566d
Showing
6 changed files
with
100 additions
and
0 deletions.
There are no files selected for viewing
7 changes: 7 additions & 0 deletions
7
packages/rspack-test-tools/tests/cacheCases/invalidation/config-mode/file.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
export default 1; | ||
--- | ||
export default 2; | ||
--- | ||
export default 3; | ||
--- | ||
export default 4; |
15 changes: 15 additions & 0 deletions
15
packages/rspack-test-tools/tests/cacheCases/invalidation/config-mode/index.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
import value from "./file"; | ||
|
||
it("should invalidation using config.mode work", async () => { | ||
if (COMPILER_INDEX == 0) { | ||
expect(value).toBe(1); | ||
await NEXT_HMR(); | ||
expect(value).toBe(2); | ||
await NEXT_START(); | ||
} | ||
if (COMPILER_INDEX == 1) { | ||
expect(value).toBe(3); | ||
await NEXT_HMR(); | ||
expect(value).toBe(4); | ||
} | ||
}); |
30 changes: 30 additions & 0 deletions
30
packages/rspack-test-tools/tests/cacheCases/invalidation/config-mode/rspack.config.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
const path = require("path"); | ||
|
||
let index = 1; | ||
|
||
/** @type {import("@rspack/core").Configuration} */ | ||
module.exports = { | ||
context: __dirname, | ||
experiments: { | ||
cache: { | ||
type: "persistent", | ||
snapshot: { | ||
immutablePaths: [path.join(__dirname, "./file.js")] | ||
} | ||
} | ||
}, | ||
plugins: [ | ||
{ | ||
apply(compiler) { | ||
compiler.hooks.beforeCompile.tap("Test Plugin", function () { | ||
if (index === 1) { | ||
compiler.options.mode = "development"; | ||
} else { | ||
compiler.options.mode = "production"; | ||
} | ||
index++; | ||
}); | ||
} | ||
} | ||
] | ||
}; |
7 changes: 7 additions & 0 deletions
7
packages/rspack-test-tools/tests/cacheCases/invalidation/config-name/file.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
export default 1; | ||
--- | ||
export default 2; | ||
--- | ||
export default 3; | ||
--- | ||
export default 4; |
15 changes: 15 additions & 0 deletions
15
packages/rspack-test-tools/tests/cacheCases/invalidation/config-name/index.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
import value from "./file"; | ||
|
||
it("should invalidation using config.name work", async () => { | ||
if (COMPILER_INDEX == 0) { | ||
expect(value).toBe(1); | ||
await NEXT_HMR(); | ||
expect(value).toBe(2); | ||
await NEXT_START(); | ||
} | ||
if (COMPILER_INDEX == 1) { | ||
expect(value).toBe(3); | ||
await NEXT_HMR(); | ||
expect(value).toBe(4); | ||
} | ||
}); |
26 changes: 26 additions & 0 deletions
26
packages/rspack-test-tools/tests/cacheCases/invalidation/config-name/rspack.config.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
const path = require("path"); | ||
|
||
let index = 1; | ||
|
||
/** @type {import("@rspack/core").Configuration} */ | ||
module.exports = { | ||
context: __dirname, | ||
experiments: { | ||
cache: { | ||
type: "persistent", | ||
snapshot: { | ||
immutablePaths: [path.join(__dirname, "./file.js")] | ||
} | ||
} | ||
}, | ||
plugins: [ | ||
{ | ||
apply(compiler) { | ||
compiler.hooks.beforeCompile.tap("Test Plugin", function () { | ||
compiler.options.name = String(index); | ||
index++; | ||
}); | ||
} | ||
} | ||
] | ||
}; |