@rspack-canary/test-tools 1.5.6-canary-9360f4d0-20250918174212 → 1.5.6-canary-7c0091e4-20250919173930
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.
- package/dist/compare/format-code.d.ts +1 -1
- package/dist/compare/format-code.js +6 -1
- package/dist/helper/legacy/checkArrayExpectation.d.ts +1 -1
- package/dist/helper/legacy/checkArrayExpectation.js +7 -7
- package/dist/processor/basic.js +3 -2
- package/dist/processor/cache.js +3 -1
- package/dist/processor/config.js +3 -1
- package/dist/processor/diagnostic.js +3 -1
- package/dist/processor/hash.js +3 -1
- package/dist/processor/hook.js +3 -1
- package/dist/processor/hot.js +3 -1
- package/dist/processor/normal.js +2 -0
- package/dist/processor/stats.js +3 -1
- package/dist/processor/watch.js +3 -2
- package/dist/runner/cache.js +6 -4
- package/dist/runner/hot.js +3 -2
- package/package.json +6 -6
|
@@ -11,6 +11,6 @@ export interface IFormatCodeOptions {
|
|
|
11
11
|
}
|
|
12
12
|
export interface IFormatCodeReplacement {
|
|
13
13
|
from: string | RegExp;
|
|
14
|
-
to: string;
|
|
14
|
+
to: string | ((substring: string, ...args: any[]) => string);
|
|
15
15
|
}
|
|
16
16
|
export declare function formatCode(name: string, raw: string, options: IFormatCodeOptions): string;
|
|
@@ -221,7 +221,12 @@ function formatCode(name, raw, options) {
|
|
|
221
221
|
}
|
|
222
222
|
if (options.replacements) {
|
|
223
223
|
for (const { from, to } of options.replacements) {
|
|
224
|
-
|
|
224
|
+
if (typeof to === "string") {
|
|
225
|
+
result = result.replaceAll(from, to);
|
|
226
|
+
}
|
|
227
|
+
else {
|
|
228
|
+
result = result.replaceAll(from, to);
|
|
229
|
+
}
|
|
225
230
|
}
|
|
226
231
|
}
|
|
227
232
|
// result of generate() is not stable with comments sometimes
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
declare function _exports(testDirectory: any, object: any, kind: any, filename: any, upperCaseKind: any, done: any): Promise<true | undefined>;
|
|
1
|
+
declare function _exports(testDirectory: any, object: any, kind: any, filename: any, upperCaseKind: any, options: any, done: any): Promise<true | undefined>;
|
|
2
2
|
export = _exports;
|
|
@@ -59,16 +59,13 @@ ${tooMuch.map(item => `${explain(item)}`).join("\n\n")}`);
|
|
|
59
59
|
}
|
|
60
60
|
return diff.join("\n\n");
|
|
61
61
|
};
|
|
62
|
-
module.exports = async function checkArrayExpectation(testDirectory, object, kind, filename, upperCaseKind, done) {
|
|
63
|
-
const usePromise = typeof done === "function";
|
|
62
|
+
module.exports = async function checkArrayExpectation(testDirectory, object, kind, filename, upperCaseKind, options, done) {
|
|
64
63
|
done = typeof done === "function" ? done : error => {
|
|
65
64
|
throw error;
|
|
66
65
|
};
|
|
67
66
|
let array = object[`${kind}s`];
|
|
68
|
-
if (Array.isArray(array)) {
|
|
69
|
-
|
|
70
|
-
array = array.filter(item => !/from Terser/.test(item));
|
|
71
|
-
}
|
|
67
|
+
if (Array.isArray(array) && kind === "warning") {
|
|
68
|
+
array = array.filter(item => !/from Terser/.test(item));
|
|
72
69
|
}
|
|
73
70
|
if (fs.existsSync(path.join(testDirectory, `${filename}.js`))) {
|
|
74
71
|
// CHANGE: added file for sorting messages in multi-thread environment
|
|
@@ -77,7 +74,10 @@ module.exports = async function checkArrayExpectation(testDirectory, object, kin
|
|
|
77
74
|
array = sorter(array);
|
|
78
75
|
}
|
|
79
76
|
const expectedFilename = path.join(testDirectory, `${filename}.js`);
|
|
80
|
-
|
|
77
|
+
let expected = require(expectedFilename);
|
|
78
|
+
if (typeof expected === "function") {
|
|
79
|
+
expected = expected(options);
|
|
80
|
+
}
|
|
81
81
|
const diff = diffItems(array, expected, kind);
|
|
82
82
|
if (expected.length < array.length) {
|
|
83
83
|
done(new Error(`More ${kind}s (${array.length} instead of ${expected.length}) while compiling than expected:\n\n${diff}\n\nCheck expected ${kind}s: ${expectedFilename}`));
|
package/dist/processor/basic.js
CHANGED
|
@@ -97,6 +97,7 @@ class BasicProcessor {
|
|
|
97
97
|
const warnings = [];
|
|
98
98
|
const compiler = this.getCompiler(context);
|
|
99
99
|
const stats = compiler.getStats();
|
|
100
|
+
const options = compiler.getOptions();
|
|
100
101
|
if (stats) {
|
|
101
102
|
if (testConfig.writeStatsOuptut) {
|
|
102
103
|
node_fs_1.default.writeFileSync(node_path_1.default.join(context.getDist(), "stats.txt"), stats.toString({
|
|
@@ -125,8 +126,8 @@ class BasicProcessor {
|
|
|
125
126
|
}
|
|
126
127
|
}
|
|
127
128
|
}
|
|
128
|
-
await (0, checkArrayExpectation_1.default)(context.getSource(), { errors }, "error", "errors", "Error");
|
|
129
|
-
await (0, checkArrayExpectation_1.default)(context.getSource(), { warnings }, "warning", "warnings", "Warning");
|
|
129
|
+
await (0, checkArrayExpectation_1.default)(context.getSource(), { errors }, "error", "errors", "Error", options);
|
|
130
|
+
await (0, checkArrayExpectation_1.default)(context.getSource(), { warnings }, "warning", "warnings", "Warning", options);
|
|
130
131
|
// clear error if checked
|
|
131
132
|
if (node_fs_1.default.existsSync(context.getSource("errors.js"))) {
|
|
132
133
|
context.clearError(this._options.name);
|
package/dist/processor/cache.js
CHANGED
package/dist/processor/config.js
CHANGED
package/dist/processor/hash.js
CHANGED
package/dist/processor/hook.js
CHANGED
package/dist/processor/hot.js
CHANGED
package/dist/processor/normal.js
CHANGED
|
@@ -145,6 +145,8 @@ class NormalProcessor extends basic_1.BasicProcessor {
|
|
|
145
145
|
},
|
|
146
146
|
asyncWebAssembly: true,
|
|
147
147
|
topLevelAwait: true,
|
|
148
|
+
inlineConst: true,
|
|
149
|
+
lazyBarrel: true,
|
|
148
150
|
// CHANGE: rspack does not support `backCompat` yet.
|
|
149
151
|
// backCompat: false,
|
|
150
152
|
// CHANGE: Rspack enables `css` by default.
|
package/dist/processor/stats.js
CHANGED
package/dist/processor/watch.js
CHANGED
|
@@ -66,6 +66,7 @@ class WatchProcessor extends multi_1.MultiTaskProcessor {
|
|
|
66
66
|
const warnings = [];
|
|
67
67
|
const compiler = this.getCompiler(context);
|
|
68
68
|
const stats = compiler.getStats();
|
|
69
|
+
const options = compiler.getOptions();
|
|
69
70
|
const checkStats = testConfig.checkStats || (() => true);
|
|
70
71
|
if (stats) {
|
|
71
72
|
if (testConfig.writeStatsOuptut) {
|
|
@@ -125,8 +126,8 @@ class WatchProcessor extends multi_1.MultiTaskProcessor {
|
|
|
125
126
|
}
|
|
126
127
|
}
|
|
127
128
|
}
|
|
128
|
-
await (0, checkArrayExpectation_1.default)(node_path_1.default.join(context.getSource(), this._watchOptions.stepName), { errors }, "error", "errors", "Error");
|
|
129
|
-
await (0, checkArrayExpectation_1.default)(node_path_1.default.join(context.getSource(), this._watchOptions.stepName), { warnings }, "warning", "warnings", "Warning");
|
|
129
|
+
await (0, checkArrayExpectation_1.default)(node_path_1.default.join(context.getSource(), this._watchOptions.stepName), { errors }, "error", "errors", "Error", options);
|
|
130
|
+
await (0, checkArrayExpectation_1.default)(node_path_1.default.join(context.getSource(), this._watchOptions.stepName), { warnings }, "warning", "warnings", "Warning", options);
|
|
130
131
|
// clear error if checked
|
|
131
132
|
if (node_fs_1.default.existsSync(context.getSource("errors.js"))) {
|
|
132
133
|
context.clearError(this._options.name);
|
package/dist/runner/cache.js
CHANGED
|
@@ -52,9 +52,10 @@ class CacheRunnerFactory extends basic_1.BasicRunnerFactory {
|
|
|
52
52
|
const jsonStats = stats.toJson({
|
|
53
53
|
// errorDetails: true
|
|
54
54
|
});
|
|
55
|
+
const compilerOptions = compiler.getOptions();
|
|
55
56
|
const updateIndex = updatePlugin.getUpdateIndex();
|
|
56
|
-
await (0, checkArrayExpectation_1.default)(source, jsonStats, "error", `errors${updateIndex}`, "Error");
|
|
57
|
-
await (0, checkArrayExpectation_1.default)(source, jsonStats, "warning", `warnings${updateIndex}`, "Warning");
|
|
57
|
+
await (0, checkArrayExpectation_1.default)(source, jsonStats, "error", `errors${updateIndex}`, "Error", compilerOptions);
|
|
58
|
+
await (0, checkArrayExpectation_1.default)(source, jsonStats, "warning", `warnings${updateIndex}`, "Warning", compilerOptions);
|
|
58
59
|
const updatedModules = await m.hot.check(options || true);
|
|
59
60
|
if (!updatedModules) {
|
|
60
61
|
throw new Error("No update available");
|
|
@@ -72,9 +73,10 @@ class CacheRunnerFactory extends basic_1.BasicRunnerFactory {
|
|
|
72
73
|
const jsonStats = stats.toJson({
|
|
73
74
|
// errorDetails: true
|
|
74
75
|
});
|
|
76
|
+
const compilerOptions = compiler.getOptions();
|
|
75
77
|
const updateIndex = updatePlugin.getUpdateIndex();
|
|
76
|
-
await (0, checkArrayExpectation_1.default)(source, jsonStats, "error", `errors${updateIndex}`, "Error");
|
|
77
|
-
await (0, checkArrayExpectation_1.default)(source, jsonStats, "warning", `warnings${updateIndex}`, "Warning");
|
|
78
|
+
await (0, checkArrayExpectation_1.default)(source, jsonStats, "error", `errors${updateIndex}`, "Error", compilerOptions);
|
|
79
|
+
await (0, checkArrayExpectation_1.default)(source, jsonStats, "warning", `warnings${updateIndex}`, "Warning", compilerOptions);
|
|
78
80
|
env.it(`NEXT_START run with compilerIndex==${compilerIndex + 1}`, async () => {
|
|
79
81
|
if (compilerIndex > MAX_COMPILER_INDEX) {
|
|
80
82
|
throw new Error("NEXT_START has been called more than the maximum times");
|
package/dist/runner/hot.js
CHANGED
|
@@ -26,14 +26,15 @@ class HotRunnerFactory extends basic_1.BasicRunnerFactory {
|
|
|
26
26
|
const jsonStats = stats.toJson({
|
|
27
27
|
// errorDetails: true
|
|
28
28
|
});
|
|
29
|
+
const compilerOptions = compiler.getOptions();
|
|
29
30
|
const checker = this.context.getValue(this.name, jsonStats.errors?.length
|
|
30
31
|
? "hotUpdateStepErrorChecker"
|
|
31
32
|
: "hotUpdateStepChecker");
|
|
32
33
|
if (checker) {
|
|
33
34
|
checker(hotUpdateContext, stats, runner.getGlobal("__HMR_UPDATED_RUNTIME__"));
|
|
34
35
|
}
|
|
35
|
-
await (0, checkArrayExpectation_1.default)(source, jsonStats, "error", `errors${hotUpdateContext.updateIndex}`, "Error");
|
|
36
|
-
await (0, checkArrayExpectation_1.default)(source, jsonStats, "warning", `warnings${hotUpdateContext.updateIndex}`, "Warning");
|
|
36
|
+
await (0, checkArrayExpectation_1.default)(source, jsonStats, "error", `errors${hotUpdateContext.updateIndex}`, "Error", compilerOptions);
|
|
37
|
+
await (0, checkArrayExpectation_1.default)(source, jsonStats, "warning", `warnings${hotUpdateContext.updateIndex}`, "Warning", compilerOptions);
|
|
37
38
|
if (usePromise) {
|
|
38
39
|
// old callback style hmr cases
|
|
39
40
|
callback(null, jsonStats);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rspack-canary/test-tools",
|
|
3
|
-
"version": "1.5.6-canary-
|
|
3
|
+
"version": "1.5.6-canary-7c0091e4-20250919173930",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"description": "Test tools for rspack",
|
|
6
6
|
"main": "dist/index.js",
|
|
@@ -65,7 +65,7 @@
|
|
|
65
65
|
"@rspack/plugin-preact-refresh": "1.1.2",
|
|
66
66
|
"@rspack/plugin-react-refresh": "^1.5.1",
|
|
67
67
|
"@swc/helpers": "0.5.17",
|
|
68
|
-
"@swc/plugin-remove-console": "^9.
|
|
68
|
+
"@swc/plugin-remove-console": "^9.1.0",
|
|
69
69
|
"@types/babel__generator": "7.27.0",
|
|
70
70
|
"@types/babel__traverse": "7.28.0",
|
|
71
71
|
"@types/fs-extra": "11.0.4",
|
|
@@ -100,10 +100,10 @@
|
|
|
100
100
|
"wast-loader": "^1.14.1",
|
|
101
101
|
"worker-rspack-loader": "^3.1.2",
|
|
102
102
|
"exports-loader": "^5.0.0",
|
|
103
|
-
"@rspack/
|
|
104
|
-
"@rspack/
|
|
105
|
-
"@rspack/
|
|
106
|
-
"@rspack/
|
|
103
|
+
"@rspack/core": "npm:@rspack-canary/core@1.5.6-canary-7c0091e4-20250919173930",
|
|
104
|
+
"@rspack/cli": "npm:@rspack-canary/cli@1.5.6-canary-7c0091e4-20250919173930",
|
|
105
|
+
"@rspack/binding-testing": "1.4.1",
|
|
106
|
+
"@rspack/test-tools": "npm:@rspack-canary/test-tools@1.5.6-canary-7c0091e4-20250919173930"
|
|
107
107
|
},
|
|
108
108
|
"peerDependencies": {
|
|
109
109
|
"@rspack/core": ">=1.0.0"
|