@rspack/test-tools 1.2.4 → 1.2.6
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/case/new-incremental.js +3 -2
- package/dist/case/stats-output.js +1 -0
- package/dist/case/watch.js +3 -2
- package/dist/helper/loaders/hot-update.js +6 -3
- package/dist/processor/basic.js +22 -12
- package/dist/processor/hash.js +2 -3
- package/dist/processor/snapshot.js +14 -3
- package/dist/processor/stats.d.ts +2 -0
- package/dist/processor/stats.js +5 -2
- package/dist/processor/watch.d.ts +4 -2
- package/dist/processor/watch.js +52 -19
- package/dist/runner/runner/watch.d.ts +1 -1
- package/dist/runner/runner/watch.js +1 -2
- package/dist/runner/watch.js +5 -0
- package/dist/type.d.ts +7 -4
- package/package.json +26 -26
|
@@ -48,6 +48,7 @@ const watchCreator = new creator_1.BasicCaseCreator({
|
|
|
48
48
|
},
|
|
49
49
|
describe: false,
|
|
50
50
|
steps: ({ name, src, temp }) => {
|
|
51
|
+
const watchState = {};
|
|
51
52
|
const runs = node_fs_1.default
|
|
52
53
|
.readdirSync(src)
|
|
53
54
|
.sort()
|
|
@@ -66,7 +67,7 @@ const watchCreator = new creator_1.BasicCaseCreator({
|
|
|
66
67
|
experiments: {
|
|
67
68
|
incremental: true
|
|
68
69
|
}
|
|
69
|
-
})
|
|
70
|
+
}, watchState)
|
|
70
71
|
: new watch_1.WatchStepProcessor({
|
|
71
72
|
name,
|
|
72
73
|
stepName: run.name,
|
|
@@ -74,7 +75,7 @@ const watchCreator = new creator_1.BasicCaseCreator({
|
|
|
74
75
|
runable: true,
|
|
75
76
|
compilerType: type_1.ECompilerType.Rspack,
|
|
76
77
|
configFiles: ["rspack.config.js", "webpack.config.js"]
|
|
77
|
-
}));
|
|
78
|
+
}, watchState));
|
|
78
79
|
}
|
|
79
80
|
});
|
|
80
81
|
function createWatchNewIncrementalCase(name, src, dist, temp) {
|
package/dist/case/watch.js
CHANGED
|
@@ -20,6 +20,7 @@ const creator = new creator_1.BasicCaseCreator({
|
|
|
20
20
|
},
|
|
21
21
|
describe: false,
|
|
22
22
|
steps: ({ name, src, temp }) => {
|
|
23
|
+
const watchState = {};
|
|
23
24
|
const runs = node_fs_1.default
|
|
24
25
|
.readdirSync(src)
|
|
25
26
|
.sort()
|
|
@@ -35,7 +36,7 @@ const creator = new creator_1.BasicCaseCreator({
|
|
|
35
36
|
runable: true,
|
|
36
37
|
compilerType: type_1.ECompilerType.Rspack,
|
|
37
38
|
configFiles: ["rspack.config.js", "webpack.config.js"]
|
|
38
|
-
})
|
|
39
|
+
}, watchState)
|
|
39
40
|
: new watch_1.WatchStepProcessor({
|
|
40
41
|
name,
|
|
41
42
|
stepName: run.name,
|
|
@@ -43,7 +44,7 @@ const creator = new creator_1.BasicCaseCreator({
|
|
|
43
44
|
runable: true,
|
|
44
45
|
compilerType: type_1.ECompilerType.Rspack,
|
|
45
46
|
configFiles: ["rspack.config.js", "webpack.config.js"]
|
|
46
|
-
}));
|
|
47
|
+
}, watchState));
|
|
47
48
|
}
|
|
48
49
|
});
|
|
49
50
|
function createWatchCase(name, src, dist, temp) {
|
|
@@ -7,14 +7,17 @@ function default_1(c) {
|
|
|
7
7
|
content = `
|
|
8
8
|
${content}
|
|
9
9
|
let __hmr_children__ = [...module.children];
|
|
10
|
-
|
|
11
|
-
|
|
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
|
+
}
|
|
12
14
|
return res;
|
|
13
15
|
}, {});
|
|
14
16
|
module.hot.accept(__hmr_children__, () => {
|
|
15
17
|
__hmr_children__.forEach((child) => {
|
|
16
18
|
const reexports = __webpack_require__(child);
|
|
17
|
-
|
|
19
|
+
for (let key in reexports) {
|
|
20
|
+
if (!__hmr_used_exports__[child]) { continue; }
|
|
18
21
|
Object.defineProperty(__hmr_used_exports__[child], key, {
|
|
19
22
|
configurable: true,
|
|
20
23
|
enumerable: true,
|
package/dist/processor/basic.js
CHANGED
|
@@ -95,19 +95,29 @@ class BasicProcessor {
|
|
|
95
95
|
const compiler = this.getCompiler(context);
|
|
96
96
|
const stats = compiler.getStats();
|
|
97
97
|
if (stats) {
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
errorDetails: true
|
|
104
|
-
});
|
|
105
|
-
node_fs_1.default.writeFileSync(node_path_1.default.join(context.getDist(), "stats.json"), JSON.stringify(jsonStats, null, 2), "utf-8");
|
|
106
|
-
if (jsonStats.errors) {
|
|
107
|
-
errors.push(...jsonStats.errors);
|
|
98
|
+
if (testConfig.writeStatsOuptut) {
|
|
99
|
+
node_fs_1.default.writeFileSync(node_path_1.default.join(context.getDist(), "stats.txt"), stats.toString({
|
|
100
|
+
preset: "verbose",
|
|
101
|
+
colors: false
|
|
102
|
+
}), "utf-8");
|
|
108
103
|
}
|
|
109
|
-
if (
|
|
110
|
-
|
|
104
|
+
if (testConfig.writeStatsJson) {
|
|
105
|
+
const jsonStats = stats.toJson({
|
|
106
|
+
errorDetails: true
|
|
107
|
+
});
|
|
108
|
+
node_fs_1.default.writeFileSync(node_path_1.default.join(context.getDist(), "stats.json"), JSON.stringify(jsonStats, null, 2), "utf-8");
|
|
109
|
+
}
|
|
110
|
+
if (node_fs_1.default.existsSync(context.getSource("errors.js")) ||
|
|
111
|
+
node_fs_1.default.existsSync(context.getSource("warnings.js"))) {
|
|
112
|
+
const statsJson = stats.toJson({
|
|
113
|
+
errorDetails: true
|
|
114
|
+
});
|
|
115
|
+
if (statsJson.errors) {
|
|
116
|
+
errors.push(...statsJson.errors);
|
|
117
|
+
}
|
|
118
|
+
if (statsJson.warnings) {
|
|
119
|
+
warnings.push(...statsJson.warnings);
|
|
120
|
+
}
|
|
111
121
|
}
|
|
112
122
|
}
|
|
113
123
|
await (0, checkArrayExpectation_1.default)(context.getSource(), { errors }, "error", "errors", "Error");
|
package/dist/processor/hash.js
CHANGED
|
@@ -20,12 +20,11 @@ class HashProcessor extends multi_1.MultiTaskProcessor {
|
|
|
20
20
|
env.expect(false);
|
|
21
21
|
return;
|
|
22
22
|
}
|
|
23
|
-
const statsJson = stats.toJson({ assets: true });
|
|
24
23
|
if (REG_ERROR_CASE.test(this._options.name)) {
|
|
25
|
-
env.expect((
|
|
24
|
+
env.expect(stats.hasErrors());
|
|
26
25
|
}
|
|
27
26
|
else {
|
|
28
|
-
env.expect((
|
|
27
|
+
env.expect(!stats.hasErrors());
|
|
29
28
|
}
|
|
30
29
|
if (typeof testConfig.validate === "function") {
|
|
31
30
|
testConfig.validate(stats);
|
|
@@ -21,9 +21,20 @@ class SnapshotProcessor extends basic_1.BasicProcessor {
|
|
|
21
21
|
if (!stats || !c)
|
|
22
22
|
return;
|
|
23
23
|
if (stats.hasErrors()) {
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
24
|
+
const errors = [];
|
|
25
|
+
if (stats.stats) {
|
|
26
|
+
for (const s of stats.stats) {
|
|
27
|
+
if (s.hasErrors()) {
|
|
28
|
+
errors.push(...s.compilation.errors);
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
else {
|
|
33
|
+
const s = stats;
|
|
34
|
+
errors.push(...s.compilation.errors);
|
|
35
|
+
}
|
|
36
|
+
throw new Error(`Failed to compile in fixture ${this._options.name}, Errors: ${errors
|
|
37
|
+
?.map(i => `${i.message}\n${i.stack}`)
|
|
27
38
|
.join("\n\n")}`);
|
|
28
39
|
}
|
|
29
40
|
const compilation = c._lastCompilation ||
|
|
@@ -2,10 +2,12 @@ import type { ECompilerType, ITestContext, ITestEnv, TCompilerOptions } from "..
|
|
|
2
2
|
import { type IMultiTaskProcessorOptions, MultiTaskProcessor } from "./multi";
|
|
3
3
|
export interface IStatsProcessorOptions<T extends ECompilerType> extends Omit<IMultiTaskProcessorOptions<T>, "runable"> {
|
|
4
4
|
snapshotName?: string;
|
|
5
|
+
writeStatsOuptut?: boolean;
|
|
5
6
|
}
|
|
6
7
|
export declare class StatsProcessor<T extends ECompilerType> extends MultiTaskProcessor<T> {
|
|
7
8
|
private stderr;
|
|
8
9
|
private snapshotName?;
|
|
10
|
+
private writeStatsOuptut?;
|
|
9
11
|
constructor(_statsOptions: IStatsProcessorOptions<T>);
|
|
10
12
|
before(context: ITestContext): Promise<void>;
|
|
11
13
|
after(context: ITestContext): Promise<void>;
|
package/dist/processor/stats.js
CHANGED
|
@@ -24,6 +24,7 @@ class StatsProcessor extends multi_1.MultiTaskProcessor {
|
|
|
24
24
|
..._statsOptions
|
|
25
25
|
});
|
|
26
26
|
this.snapshotName = _statsOptions.snapshotName;
|
|
27
|
+
this.writeStatsOuptut = _statsOptions.writeStatsOuptut;
|
|
27
28
|
}
|
|
28
29
|
async before(context) {
|
|
29
30
|
this.stderr = (0, captureStdio_1.default)(process.stderr, true);
|
|
@@ -95,7 +96,7 @@ class StatsProcessor extends multi_1.MultiTaskProcessor {
|
|
|
95
96
|
// errorDetails: true
|
|
96
97
|
}));
|
|
97
98
|
}
|
|
98
|
-
else {
|
|
99
|
+
else if (this.writeStatsOuptut) {
|
|
99
100
|
node_fs_1.default.writeFileSync(node_path_1.default.join(context.getDist(), "stats.txt"), stats.toString({
|
|
100
101
|
preset: "verbose",
|
|
101
102
|
// context: context.getSource(),
|
|
@@ -132,7 +133,9 @@ class StatsProcessor extends multi_1.MultiTaskProcessor {
|
|
|
132
133
|
actual = actual
|
|
133
134
|
.replace(/\u001b\[[0-9;]*m/g, "")
|
|
134
135
|
// CHANGE: The time unit display in Rspack is second
|
|
135
|
-
.replace(/[.0-9]+(\s?s)/g, "X$1")
|
|
136
|
+
.replace(/[.0-9]+(\s?s)/g, "X$1")
|
|
137
|
+
// CHANGE: Replace bundle size, since bundle sizes may differ between platforms
|
|
138
|
+
.replace(/[0-9]+\.?[0-9]+ KiB/g, "xx KiB");
|
|
136
139
|
}
|
|
137
140
|
if (this.snapshotName) {
|
|
138
141
|
env.expect(new RspackStats(actual)).toMatchSnapshot(this.snapshotName);
|
|
@@ -10,9 +10,10 @@ export interface IWatchProcessorOptions<T extends ECompilerType> extends IMultiT
|
|
|
10
10
|
}
|
|
11
11
|
export declare class WatchProcessor<T extends ECompilerType> extends MultiTaskProcessor<T> {
|
|
12
12
|
protected _watchOptions: IWatchProcessorOptions<T>;
|
|
13
|
+
protected _watchState: Record<string, any>;
|
|
13
14
|
protected currentTriggerFilename: string | null;
|
|
14
15
|
protected lastHash: string | null;
|
|
15
|
-
constructor(_watchOptions: IWatchProcessorOptions<T>);
|
|
16
|
+
constructor(_watchOptions: IWatchProcessorOptions<T>, _watchState: Record<string, any>);
|
|
16
17
|
compiler(context: ITestContext): Promise<void>;
|
|
17
18
|
build(context: ITestContext): Promise<void>;
|
|
18
19
|
run(env: ITestEnv, context: ITestContext): Promise<void>;
|
|
@@ -25,7 +26,8 @@ export interface IWatchStepProcessorOptions<T extends ECompilerType> extends Omi
|
|
|
25
26
|
}
|
|
26
27
|
export declare class WatchStepProcessor<T extends ECompilerType> extends WatchProcessor<T> {
|
|
27
28
|
protected _watchOptions: IWatchStepProcessorOptions<T>;
|
|
28
|
-
|
|
29
|
+
protected _watchState: Record<string, any>;
|
|
30
|
+
constructor(_watchOptions: IWatchStepProcessorOptions<T>, _watchState: Record<string, any>);
|
|
29
31
|
compiler(context: ITestContext): Promise<void>;
|
|
30
32
|
build(context: ITestContext): Promise<void>;
|
|
31
33
|
}
|
package/dist/processor/watch.js
CHANGED
|
@@ -15,13 +15,14 @@ const multi_1 = require("./multi");
|
|
|
15
15
|
// This file is used to port step number to rspack.config.js/webpack.config.js
|
|
16
16
|
const currentWatchStepModulePath = node_path_1.default.resolve(__dirname, "../helper/util/currentWatchStep");
|
|
17
17
|
class WatchProcessor extends multi_1.MultiTaskProcessor {
|
|
18
|
-
constructor(_watchOptions) {
|
|
18
|
+
constructor(_watchOptions, _watchState) {
|
|
19
19
|
super({
|
|
20
20
|
overrideOptions: WatchProcessor.overrideOptions(_watchOptions),
|
|
21
21
|
findBundle: (WatchProcessor.findBundle),
|
|
22
22
|
..._watchOptions
|
|
23
23
|
});
|
|
24
24
|
this._watchOptions = _watchOptions;
|
|
25
|
+
this._watchState = _watchState;
|
|
25
26
|
this.currentTriggerFilename = null;
|
|
26
27
|
this.lastHash = null;
|
|
27
28
|
}
|
|
@@ -50,6 +51,7 @@ class WatchProcessor extends multi_1.MultiTaskProcessor {
|
|
|
50
51
|
}
|
|
51
52
|
async run(env, context) {
|
|
52
53
|
context.setValue(this._options.name, "watchStepName", this._watchOptions.stepName);
|
|
54
|
+
context.setValue(this._options.name, "watchState", this._watchState);
|
|
53
55
|
await super.run(env, context);
|
|
54
56
|
}
|
|
55
57
|
async check(env, context) {
|
|
@@ -65,22 +67,48 @@ class WatchProcessor extends multi_1.MultiTaskProcessor {
|
|
|
65
67
|
const stats = compiler.getStats();
|
|
66
68
|
const checkStats = testConfig.checkStats || (() => true);
|
|
67
69
|
if (stats) {
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
errorDetails: true
|
|
74
|
-
});
|
|
75
|
-
if (!checkStats(this._watchOptions.stepName, jsonStats)) {
|
|
76
|
-
throw new Error("stats check failed");
|
|
70
|
+
if (testConfig.writeStatsOuptut) {
|
|
71
|
+
node_fs_1.default.writeFileSync(node_path_1.default.join(context.getDist(), "stats.txt"), stats.toString({
|
|
72
|
+
preset: "verbose",
|
|
73
|
+
colors: false
|
|
74
|
+
}), "utf-8");
|
|
77
75
|
}
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
76
|
+
const getJsonStats = (() => {
|
|
77
|
+
let cached = null;
|
|
78
|
+
return () => {
|
|
79
|
+
if (!cached) {
|
|
80
|
+
cached = stats.toJson({
|
|
81
|
+
errorDetails: true
|
|
82
|
+
});
|
|
83
|
+
}
|
|
84
|
+
return cached;
|
|
85
|
+
};
|
|
86
|
+
})();
|
|
87
|
+
if (checkStats.length > 1) {
|
|
88
|
+
if (!checkStats(this._watchOptions.stepName, getJsonStats())) {
|
|
89
|
+
throw new Error("stats check failed");
|
|
90
|
+
}
|
|
81
91
|
}
|
|
82
|
-
|
|
83
|
-
|
|
92
|
+
else {
|
|
93
|
+
// @ts-expect-error only one param
|
|
94
|
+
if (!checkStats(this._watchOptions.stepName)) {
|
|
95
|
+
throw new Error("stats check failed");
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
if (testConfig.writeStatsJson) {
|
|
99
|
+
node_fs_1.default.writeFileSync(node_path_1.default.join(context.getDist(), "stats.json"), JSON.stringify(getJsonStats(), null, 2), "utf-8");
|
|
100
|
+
}
|
|
101
|
+
if (node_fs_1.default.existsSync(context.getSource(`${this._watchOptions.stepName}/errors.js`)) ||
|
|
102
|
+
node_fs_1.default.existsSync(context.getSource(`${this._watchOptions.stepName}/warnings.js`))) {
|
|
103
|
+
const statsJson = stats.toJson({
|
|
104
|
+
errorDetails: true
|
|
105
|
+
});
|
|
106
|
+
if (statsJson.errors) {
|
|
107
|
+
errors.push(...statsJson.errors);
|
|
108
|
+
}
|
|
109
|
+
if (statsJson.warnings) {
|
|
110
|
+
warnings.push(...statsJson.warnings);
|
|
111
|
+
}
|
|
84
112
|
}
|
|
85
113
|
}
|
|
86
114
|
await (0, checkArrayExpectation_1.default)(node_path_1.default.join(context.getSource(), this._watchOptions.stepName), { errors }, "error", "errors", "Error");
|
|
@@ -90,8 +118,12 @@ class WatchProcessor extends multi_1.MultiTaskProcessor {
|
|
|
90
118
|
context.clearError(this._options.name);
|
|
91
119
|
}
|
|
92
120
|
// check hash
|
|
93
|
-
|
|
94
|
-
|
|
121
|
+
if (testConfig.writeStatsOuptut) {
|
|
122
|
+
node_fs_1.default.renameSync(node_path_1.default.join(context.getDist(), "stats.txt"), node_path_1.default.join(context.getDist(), `stats.${this._watchOptions.stepName}.txt`));
|
|
123
|
+
}
|
|
124
|
+
if (testConfig.writeStatsJson) {
|
|
125
|
+
node_fs_1.default.renameSync(node_path_1.default.join(context.getDist(), "stats.json"), node_path_1.default.join(context.getDist(), `stats.${this._watchOptions.stepName}.json`));
|
|
126
|
+
}
|
|
95
127
|
}
|
|
96
128
|
async config(context) {
|
|
97
129
|
this.multiCompilerOptions = [];
|
|
@@ -172,9 +204,10 @@ class WatchProcessor extends multi_1.MultiTaskProcessor {
|
|
|
172
204
|
}
|
|
173
205
|
exports.WatchProcessor = WatchProcessor;
|
|
174
206
|
class WatchStepProcessor extends WatchProcessor {
|
|
175
|
-
constructor(_watchOptions) {
|
|
176
|
-
super(_watchOptions);
|
|
207
|
+
constructor(_watchOptions, _watchState) {
|
|
208
|
+
super(_watchOptions, _watchState);
|
|
177
209
|
this._watchOptions = _watchOptions;
|
|
210
|
+
this._watchState = _watchState;
|
|
178
211
|
}
|
|
179
212
|
async compiler(context) {
|
|
180
213
|
// do nothing
|
|
@@ -5,10 +5,10 @@ import { FakeDocumentWebRunner } from "./web/fake";
|
|
|
5
5
|
interface IWatchRunnerOptions<T extends ECompilerType = ECompilerType.Rspack> extends IBasicRunnerOptions<T> {
|
|
6
6
|
stepName: string;
|
|
7
7
|
isWeb: boolean;
|
|
8
|
+
state: Record<string, any>;
|
|
8
9
|
}
|
|
9
10
|
export declare class WatchRunner<T extends ECompilerType = ECompilerType.Rspack> extends FakeDocumentWebRunner<T> {
|
|
10
11
|
protected _watchOptions: IWatchRunnerOptions<T>;
|
|
11
|
-
private state;
|
|
12
12
|
constructor(_watchOptions: IWatchRunnerOptions<T>);
|
|
13
13
|
protected createModuleScope(requireFn: TRunnerRequirer, m: any, file: TBasicRunnerFile): IBasicModuleScope;
|
|
14
14
|
run(file: string): Promise<unknown>;
|
|
@@ -10,13 +10,12 @@ class WatchRunner extends fake_1.FakeDocumentWebRunner {
|
|
|
10
10
|
constructor(_watchOptions) {
|
|
11
11
|
super(_watchOptions);
|
|
12
12
|
this._watchOptions = _watchOptions;
|
|
13
|
-
this.state = {};
|
|
14
13
|
}
|
|
15
14
|
createModuleScope(requireFn, m, file) {
|
|
16
15
|
const moduleScope = super.createModuleScope(requireFn, m, file);
|
|
17
16
|
moduleScope.__dirname = node_path_1.default.dirname(file.path);
|
|
18
17
|
moduleScope.document = this.globalContext.document;
|
|
19
|
-
moduleScope.STATE = this.state;
|
|
18
|
+
moduleScope.STATE = this._watchOptions.state;
|
|
20
19
|
moduleScope.WATCH_STEP = this._watchOptions.stepName;
|
|
21
20
|
moduleScope.STATS_JSON = this._options.stats;
|
|
22
21
|
return moduleScope;
|
package/dist/runner/watch.js
CHANGED
|
@@ -14,6 +14,10 @@ class WatchRunnerFactory extends basic_1.BasicRunnerFactory {
|
|
|
14
14
|
if (!stepName) {
|
|
15
15
|
throw new Error("Can not get watch step name from context");
|
|
16
16
|
}
|
|
17
|
+
const state = this.context.getValue(this.name, "watchState");
|
|
18
|
+
if (!state) {
|
|
19
|
+
throw new Error("Can not get watch state from context");
|
|
20
|
+
}
|
|
17
21
|
const isWeb = Array.isArray(compilerOptions)
|
|
18
22
|
? compilerOptions.some(option => {
|
|
19
23
|
return option.target === "web" || option.target === "webworker";
|
|
@@ -24,6 +28,7 @@ class WatchRunnerFactory extends basic_1.BasicRunnerFactory {
|
|
|
24
28
|
env,
|
|
25
29
|
stats,
|
|
26
30
|
name: this.name,
|
|
31
|
+
state,
|
|
27
32
|
stepName,
|
|
28
33
|
runInNewContext: isWeb,
|
|
29
34
|
isWeb,
|
package/dist/type.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type EventEmitter from "node:events";
|
|
2
|
-
import type { Compiler as RspackCompiler, RspackOptions, Stats as RspackStats, StatsCompilation as RspackStatsCompilation } from "@rspack/core";
|
|
3
|
-
import type { Compiler as WebpackCompiler, Configuration as WebpackOptions, Stats as WebpackStats, StatsCompilation as WebpackStatsCompilation } from "webpack";
|
|
2
|
+
import type { Compiler as RspackCompiler, MultiStats as RspackMultiStats, RspackOptions, Stats as RspackStats, StatsCompilation as RspackStatsCompilation } from "@rspack/core";
|
|
3
|
+
import type { Compiler as WebpackCompiler, MultiStats as WebpackMultiStats, Configuration as WebpackOptions, Stats as WebpackStats, StatsCompilation as WebpackStatsCompilation } from "webpack";
|
|
4
4
|
import type { IBasicModuleScope, TRunnerRequirer } from "./runner/type";
|
|
5
5
|
export interface ITestContext {
|
|
6
6
|
getSource(sub?: string): string;
|
|
@@ -26,6 +26,7 @@ export declare enum ECompilerType {
|
|
|
26
26
|
export type TCompilerOptions<T> = T extends ECompilerType.Rspack ? RspackOptions : WebpackOptions;
|
|
27
27
|
export type TCompiler<T> = T extends ECompilerType.Rspack ? RspackCompiler : WebpackCompiler;
|
|
28
28
|
export type TCompilerStats<T> = T extends ECompilerType.Rspack ? RspackStats : WebpackStats;
|
|
29
|
+
export type TCompilerMultiStats<T> = T extends ECompilerType.Rspack ? RspackMultiStats : WebpackMultiStats;
|
|
29
30
|
export type TCompilerStatsCompilation<T> = T extends ECompilerType.Rspack ? RspackStatsCompilation : WebpackStatsCompilation;
|
|
30
31
|
export interface ITestCompilerManager<T extends ECompilerType> {
|
|
31
32
|
getOptions(): TCompilerOptions<T>;
|
|
@@ -35,7 +36,7 @@ export interface ITestCompilerManager<T extends ECompilerType> {
|
|
|
35
36
|
createCompiler(): TCompiler<T>;
|
|
36
37
|
build(): Promise<TCompilerStats<T>>;
|
|
37
38
|
watch(timeout?: number): void;
|
|
38
|
-
getStats(): TCompilerStats<T> | null;
|
|
39
|
+
getStats(): TCompilerStats<T> | TCompilerMultiStats<T> | null;
|
|
39
40
|
getEmitter(): EventEmitter;
|
|
40
41
|
close(): Promise<void>;
|
|
41
42
|
}
|
|
@@ -133,8 +134,10 @@ export declare enum EDocumentType {
|
|
|
133
134
|
}
|
|
134
135
|
export type TTestConfig<T extends ECompilerType> = {
|
|
135
136
|
documentType?: EDocumentType;
|
|
136
|
-
validate?: (stats: TCompilerStats<T>, stderr?: string) => void;
|
|
137
|
+
validate?: (stats: TCompilerStats<T> | TCompilerMultiStats<T>, stderr?: string) => void;
|
|
137
138
|
noTest?: boolean;
|
|
139
|
+
writeStatsOuptut?: boolean;
|
|
140
|
+
writeStatsJson?: boolean;
|
|
138
141
|
beforeExecute?: () => void;
|
|
139
142
|
afterExecute?: () => void;
|
|
140
143
|
moduleScope?: (ms: IBasicModuleScope, stats?: TCompilerStatsCompilation<T>) => IBasicModuleScope;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rspack/test-tools",
|
|
3
|
-
"version": "1.2.
|
|
3
|
+
"version": "1.2.6",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"description": "Test tools for rspack",
|
|
6
6
|
"main": "dist/index.js",
|
|
@@ -31,18 +31,18 @@
|
|
|
31
31
|
"directory": "packages/rspack-test-tools"
|
|
32
32
|
},
|
|
33
33
|
"dependencies": {
|
|
34
|
-
"@babel/generator": "7.26.
|
|
35
|
-
"@babel/helpers": "7.26.
|
|
36
|
-
"@babel/parser": "7.26.
|
|
34
|
+
"@babel/generator": "7.26.9",
|
|
35
|
+
"@babel/helpers": "7.26.9",
|
|
36
|
+
"@babel/parser": "7.26.9",
|
|
37
37
|
"@babel/template": "7.25.9",
|
|
38
|
-
"@babel/traverse": "7.26.
|
|
39
|
-
"@babel/types": "7.26.
|
|
38
|
+
"@babel/traverse": "7.26.9",
|
|
39
|
+
"@babel/types": "7.26.9",
|
|
40
40
|
"cross-env": "^7.0.3",
|
|
41
|
-
"csv-to-markdown-table": "^1.
|
|
41
|
+
"csv-to-markdown-table": "^1.4.1",
|
|
42
42
|
"deepmerge": "^4.3.1",
|
|
43
43
|
"filenamify": "4.3.0",
|
|
44
44
|
"fs-extra": "^11.3.0",
|
|
45
|
-
"glob": "^11.0.
|
|
45
|
+
"glob": "^11.0.1",
|
|
46
46
|
"graceful-fs": "^4.2.11",
|
|
47
47
|
"jest-diff": "^29.7.0",
|
|
48
48
|
"jest-snapshot": "29.7.0",
|
|
@@ -53,52 +53,52 @@
|
|
|
53
53
|
"pretty-format": "29.7.0",
|
|
54
54
|
"rimraf": "^5.0.10",
|
|
55
55
|
"source-map": "^0.7.4",
|
|
56
|
-
"terser-webpack-plugin": "^5.3.
|
|
57
|
-
"webpack": "5.
|
|
56
|
+
"terser-webpack-plugin": "^5.3.11",
|
|
57
|
+
"webpack": "5.98.0",
|
|
58
58
|
"webpack-merge": "5.9.0",
|
|
59
59
|
"webpack-sources": "3.2.3"
|
|
60
60
|
},
|
|
61
61
|
"devDependencies": {
|
|
62
62
|
"@arco-design/web-react": "^2.65.0",
|
|
63
63
|
"@monaco-editor/react": "^4.7.0",
|
|
64
|
-
"@rspack/plugin-preact-refresh": "1.1.
|
|
64
|
+
"@rspack/plugin-preact-refresh": "1.1.2",
|
|
65
65
|
"@rspack/plugin-react-refresh": "^1.0.1",
|
|
66
66
|
"@swc/helpers": "0.5.15",
|
|
67
|
-
"@swc/plugin-remove-console": "^6.2
|
|
67
|
+
"@swc/plugin-remove-console": "^6.3.2",
|
|
68
68
|
"@types/babel__generator": "7.6.8",
|
|
69
69
|
"@types/babel__traverse": "7.20.6",
|
|
70
70
|
"@types/fs-extra": "11.0.4",
|
|
71
71
|
"@types/jsdom": "^21.1.7",
|
|
72
|
-
"@types/react": "^19.0.
|
|
73
|
-
"@types/react-dom": "^19.0.
|
|
72
|
+
"@types/react": "^19.0.10",
|
|
73
|
+
"@types/react-dom": "^19.0.4",
|
|
74
74
|
"@types/webpack": "5.28.5",
|
|
75
75
|
"@types/webpack-sources": "3.2.3",
|
|
76
76
|
"@webdiscus/pug-loader": "^2.11.1",
|
|
77
77
|
"acorn": "^8.14.0",
|
|
78
78
|
"babel-loader": "^9.2.1",
|
|
79
|
-
"babel-plugin-import": "^1.13.
|
|
80
|
-
"chalk": "^4.1.
|
|
79
|
+
"babel-plugin-import": "^1.13.8",
|
|
80
|
+
"chalk": "^4.1.2",
|
|
81
81
|
"coffee-loader": "^5.0.0",
|
|
82
|
-
"coffeescript": "^2.
|
|
82
|
+
"coffeescript": "^2.7.0",
|
|
83
83
|
"core-js": "3.40.0",
|
|
84
84
|
"css-loader": "^7.1.2",
|
|
85
85
|
"file-loader": "^6.2.0",
|
|
86
86
|
"graceful-fs": "^4.2.11",
|
|
87
87
|
"html-loader": "^5.0.0",
|
|
88
|
-
"html-webpack-plugin": "^5.
|
|
88
|
+
"html-webpack-plugin": "^5.6.3",
|
|
89
89
|
"less-loader": "^12.2.0",
|
|
90
90
|
"lodash": "^4.17.21",
|
|
91
|
-
"monaco-editor": "0.52.
|
|
91
|
+
"monaco-editor": "0.52.2",
|
|
92
92
|
"monaco-editor-webpack-plugin": "7.1.0",
|
|
93
|
-
"normalize.css": "^8.0.
|
|
94
|
-
"postcss-loader": "^8.
|
|
95
|
-
"postcss-pxtorem": "^6.
|
|
93
|
+
"normalize.css": "^8.0.1",
|
|
94
|
+
"postcss-loader": "^8.1.1",
|
|
95
|
+
"postcss-pxtorem": "^6.1.0",
|
|
96
96
|
"raw-loader": "^4.0.2",
|
|
97
97
|
"react": "^19.0.0",
|
|
98
98
|
"react-dom": "^19.0.0",
|
|
99
99
|
"react-refresh": "^0.16.0",
|
|
100
100
|
"sass-embedded": "^1.85.0",
|
|
101
|
-
"sass-loader": "^16.0.
|
|
101
|
+
"sass-loader": "^16.0.5",
|
|
102
102
|
"source-map": "^0.7.4",
|
|
103
103
|
"source-map-loader": "^5.0.0",
|
|
104
104
|
"style-loader": "^4.0.0",
|
|
@@ -106,9 +106,9 @@
|
|
|
106
106
|
"typescript": "^5.7.3",
|
|
107
107
|
"wast-loader": "^1.14.1",
|
|
108
108
|
"worker-rspack-loader": "^3.1.2",
|
|
109
|
-
"@rspack/cli": "1.2.
|
|
110
|
-
"@rspack/
|
|
111
|
-
"@rspack/
|
|
109
|
+
"@rspack/cli": "1.2.6",
|
|
110
|
+
"@rspack/test-tools": "1.2.6",
|
|
111
|
+
"@rspack/core": "1.2.6"
|
|
112
112
|
},
|
|
113
113
|
"peerDependencies": {
|
|
114
114
|
"@rspack/core": ">=1.0.0"
|