Skip to content

Commit deb53a4

Browse files
committed
add a test
1 parent 4002105 commit deb53a4

File tree

8 files changed

+53
-0
lines changed

8 files changed

+53
-0
lines changed

packages/rspack-test-tools/src/helper/hot-update/plugin.ts

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,17 @@ export class HotUpdatePlugin {
6666
await fs.writeFile(filePath, content);
6767
return;
6868
}
69+
if (command.startsWith("link")) {
70+
const [_, from, to] = command.split(" ");
71+
const fromPath = path.join(filePath, from);
72+
const toPath = path.join(filePath, to);
73+
74+
try {
75+
await fs.unlink(toPath);
76+
} catch {}
77+
78+
await fs.symlink(fromPath, toPath);
79+
}
6980
// default
7081
const { content: oldContent } = this.getContent(
7182
filePath,
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
<link ../test_lib_1 ../test_lib>export default 0;
2+
---
3+
<link ../test_lib_2 ../test_lib>export default 1;
4+
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
import value from "./driver";
2+
import version from "./test_lib"
3+
4+
it("should snapshot managed-paths work", async () => {
5+
if (COMPILER_INDEX == 0) {
6+
expect(version).toBe(100);
7+
await NEXT_START();
8+
}
9+
if (COMPILER_INDEX == 1) {
10+
expect(version).toBe(200);
11+
}
12+
});
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
const path = require("path");
2+
3+
/** @type {import("@rspack/core").Configuration} */
4+
module.exports = {
5+
context: __dirname,
6+
experiments: {
7+
cache: {
8+
type: "persistent",
9+
snapshot: {
10+
managedPaths: [path.join(__dirname, "./test_lib")]
11+
}
12+
}
13+
}
14+
};
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
export default 100
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{
2+
"name": "managed-paths-test-lib",
3+
"version": "0.0.100",
4+
"main": "./file.js"
5+
}
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
export default 200
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{
2+
"name": "managed-paths-test-lib",
3+
"version": "0.0.200",
4+
"main": "./file.js"
5+
}

0 commit comments

Comments
 (0)