@rspack-canary/test-tools 1.6.0-canary-c1ffd5c5-20251016085846 → 1.6.0-canary-2ccce257-20251016173648
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -1 +1,2 @@
|
|
|
1
|
-
|
|
1
|
+
declare const loader: (c: string) => string;
|
|
2
|
+
export default loader;
|
|
@@ -1,32 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
${content}
|
|
9
|
-
let __hmr_children__ = [...module.children];
|
|
10
|
-
let __hmr_used_exports__ = __hmr_children__.reduce((res, child) => {
|
|
11
|
-
if (__webpack_module_cache__[child]) {
|
|
12
|
-
res[child] = __webpack_module_cache__[child].exports;
|
|
13
|
-
}
|
|
14
|
-
return res;
|
|
15
|
-
}, {});
|
|
16
|
-
module.hot.accept(__hmr_children__, () => {
|
|
17
|
-
__hmr_children__.forEach((child) => {
|
|
18
|
-
const reexports = __webpack_require__(child);
|
|
19
|
-
for (let key in reexports) {
|
|
20
|
-
if (!__hmr_used_exports__[child]) { continue; }
|
|
21
|
-
Object.defineProperty(__hmr_used_exports__[child], key, {
|
|
22
|
-
configurable: true,
|
|
23
|
-
enumerable: true,
|
|
24
|
-
get: () => reexports[key]
|
|
25
|
-
});
|
|
26
|
-
}
|
|
27
|
-
});
|
|
28
|
-
});
|
|
29
|
-
`;
|
|
30
|
-
}
|
|
31
|
-
return content.replace(/NEXT_HMR/g, "NEXT_HMR.bind(null, module)");
|
|
32
|
-
}
|
|
3
|
+
const loader = function (c) {
|
|
4
|
+
return c.replace(/NEXT_HMR/g, "NEXT_HMR.bind(null, module)");
|
|
5
|
+
};
|
|
6
|
+
module.exports = loader;
|
|
7
|
+
exports.default = loader;
|
|
@@ -4,15 +4,16 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
exports.HotUpdatePlugin = void 0;
|
|
7
|
-
const promises_1 = __importDefault(require("node:fs/promises"));
|
|
8
7
|
const node_path_1 = __importDefault(require("node:path"));
|
|
8
|
+
const fs_extra_1 = __importDefault(require("fs-extra"));
|
|
9
|
+
const rimraf_1 = require("rimraf");
|
|
9
10
|
async function loopFile(dir, callback) {
|
|
10
|
-
const children = await
|
|
11
|
+
const children = await fs_extra_1.default.readdir(dir);
|
|
11
12
|
await Promise.all(children.map(async (filename) => {
|
|
12
13
|
const filePath = node_path_1.default.join(dir, filename);
|
|
13
|
-
const stat = await
|
|
14
|
+
const stat = await fs_extra_1.default.stat(filePath);
|
|
14
15
|
if (stat.isFile()) {
|
|
15
|
-
const content = await
|
|
16
|
+
const content = await fs_extra_1.default.readFile(filePath);
|
|
16
17
|
callback(filePath, content.toString());
|
|
17
18
|
}
|
|
18
19
|
else if (stat.isDirectory()) {
|
|
@@ -48,11 +49,11 @@ class HotUpdatePlugin {
|
|
|
48
49
|
const { content, command } = this.getContent(filePath, this.updateIndex);
|
|
49
50
|
// match command
|
|
50
51
|
if (command === "delete") {
|
|
51
|
-
await
|
|
52
|
+
await fs_extra_1.default.unlink(filePath);
|
|
52
53
|
return;
|
|
53
54
|
}
|
|
54
55
|
if (command === "force_write") {
|
|
55
|
-
await
|
|
56
|
+
await fs_extra_1.default.writeFile(filePath, content);
|
|
56
57
|
return;
|
|
57
58
|
}
|
|
58
59
|
// default
|
|
@@ -60,7 +61,7 @@ class HotUpdatePlugin {
|
|
|
60
61
|
if (this.updateIndex !== 0 && content === oldContent) {
|
|
61
62
|
return;
|
|
62
63
|
}
|
|
63
|
-
await
|
|
64
|
+
await fs_extra_1.default.writeFile(filePath, content);
|
|
64
65
|
}));
|
|
65
66
|
}
|
|
66
67
|
async initialize() {
|
|
@@ -68,13 +69,8 @@ class HotUpdatePlugin {
|
|
|
68
69
|
return;
|
|
69
70
|
}
|
|
70
71
|
this.initialized = true;
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
}
|
|
74
|
-
catch (_e) {
|
|
75
|
-
// empty
|
|
76
|
-
}
|
|
77
|
-
await promises_1.default.cp(this.projectDir, this.tempDir, { recursive: true });
|
|
72
|
+
(0, rimraf_1.rimrafSync)(this.tempDir);
|
|
73
|
+
fs_extra_1.default.copySync(this.projectDir, this.tempDir);
|
|
78
74
|
await loopFile(this.tempDir, (filePath, content) => {
|
|
79
75
|
const contents = content.split(/---+\r?\n/g);
|
|
80
76
|
if (contents.length > 1) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rspack-canary/test-tools",
|
|
3
|
-
"version": "1.6.0-canary-
|
|
3
|
+
"version": "1.6.0-canary-2ccce257-20251016173648",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"description": "Test tools for rspack",
|
|
6
6
|
"main": "dist/index.js",
|
|
@@ -72,7 +72,7 @@
|
|
|
72
72
|
"terser": "5.43.1",
|
|
73
73
|
"typescript": "^5.9.3",
|
|
74
74
|
"wast-loader": "^1.14.1",
|
|
75
|
-
"@rspack/core": "npm:@rspack-canary/core@1.6.0-canary-
|
|
75
|
+
"@rspack/core": "npm:@rspack-canary/core@1.6.0-canary-2ccce257-20251016173648"
|
|
76
76
|
},
|
|
77
77
|
"peerDependencies": {
|
|
78
78
|
"@rspack/core": ">=1.0.0"
|