@rspack/test-tools 1.1.0-beta.0 → 1.1.0
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.
|
@@ -23,9 +23,9 @@ async function checkSourceMap(out, outCodeMap, toSearch, _checkColumn = true //
|
|
|
23
23
|
const map = await new sourceMap.SourceMapConsumer(outCodeMap);
|
|
24
24
|
for (const id in toSearch) {
|
|
25
25
|
const isSearchConfig = typeof toSearch[id] === "object" && toSearch[id] !== null;
|
|
26
|
-
const outId = isSearchConfig ? toSearch[id].outId ?? id : id;
|
|
26
|
+
const outId = isSearchConfig ? (toSearch[id].outId ?? id) : id;
|
|
27
27
|
const checkColumn = isSearchConfig
|
|
28
|
-
? toSearch[id].checkColumn ?? _checkColumn
|
|
28
|
+
? (toSearch[id].checkColumn ?? _checkColumn)
|
|
29
29
|
: _checkColumn;
|
|
30
30
|
const inSource = isSearchConfig ? toSearch[id].inSource : toSearch[id];
|
|
31
31
|
const outIndex = out.indexOf(outId);
|
|
@@ -5,8 +5,8 @@ exports.checkChunkModules = function checkChunkModules(statsJson, chunkModulesMa
|
|
|
5
5
|
const chunk = getChunk(statsJson, chunkId);
|
|
6
6
|
const expectedModules = chunkModulesMap[chunkId];
|
|
7
7
|
const chunkModules = chunk.modules.map(m => m.identifier);
|
|
8
|
-
if (strict) {
|
|
9
|
-
|
|
8
|
+
if (strict && expectedModules.length !== chunkModules.length) {
|
|
9
|
+
throw new Error(`expect chunk ${chunkId} has ${chunkModules.length} modules: ${chunkModules}\nbut received ${chunkModules.length} modules`);
|
|
10
10
|
}
|
|
11
11
|
for (const module of expectedModules) {
|
|
12
12
|
if (!chunkModules.find(moduleId => moduleId.includes(module))) {
|
package/dist/processor/watch.js
CHANGED
|
@@ -63,6 +63,7 @@ class WatchProcessor extends multi_1.MultiTaskProcessor {
|
|
|
63
63
|
const warnings = [];
|
|
64
64
|
const compiler = this.getCompiler(context);
|
|
65
65
|
const stats = compiler.getStats();
|
|
66
|
+
const checkStats = testConfig.checkStats || (() => true);
|
|
66
67
|
if (stats) {
|
|
67
68
|
node_fs_1.default.writeFileSync(node_path_1.default.join(context.getDist(), "stats.txt"), stats.toString({
|
|
68
69
|
preset: "verbose",
|
|
@@ -71,6 +72,9 @@ class WatchProcessor extends multi_1.MultiTaskProcessor {
|
|
|
71
72
|
const jsonStats = stats.toJson({
|
|
72
73
|
errorDetails: true
|
|
73
74
|
});
|
|
75
|
+
if (!checkStats(this._watchOptions.stepName, jsonStats)) {
|
|
76
|
+
throw new Error("stats check failed");
|
|
77
|
+
}
|
|
74
78
|
node_fs_1.default.writeFileSync(node_path_1.default.join(context.getDist(), "stats.json"), JSON.stringify(jsonStats, null, 2), "utf-8");
|
|
75
79
|
if (jsonStats.errors) {
|
|
76
80
|
errors.push(...jsonStats.errors);
|
package/dist/type.d.ts
CHANGED
|
@@ -138,6 +138,7 @@ export type TTestConfig<T extends ECompilerType> = {
|
|
|
138
138
|
beforeExecute?: () => void;
|
|
139
139
|
afterExecute?: () => void;
|
|
140
140
|
moduleScope?: (ms: IBasicModuleScope, stats?: TCompilerStatsCompilation<T>) => IBasicModuleScope;
|
|
141
|
+
checkStats?: (stepName: string, stats: TCompilerStatsCompilation<T>) => boolean;
|
|
141
142
|
findBundle?: (index: number, options: TCompilerOptions<T>) => string | string[];
|
|
142
143
|
bundlePath?: string[];
|
|
143
144
|
nonEsmThis?: (p: string | string[]) => Object;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rspack/test-tools",
|
|
3
|
-
"version": "1.1.0
|
|
3
|
+
"version": "1.1.0",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"description": "Test tools for rspack",
|
|
6
6
|
"main": "dist/index.js",
|
|
@@ -46,7 +46,7 @@
|
|
|
46
46
|
"jest-serializer-path": "^0.1.15",
|
|
47
47
|
"jest-snapshot": "29.7.0",
|
|
48
48
|
"jsdom": "^25.0.0",
|
|
49
|
-
"memfs": "4.
|
|
49
|
+
"memfs": "4.14.0",
|
|
50
50
|
"mkdirp": "0.5.6",
|
|
51
51
|
"path-serializer": "0.1.2",
|
|
52
52
|
"pretty-format": "29.7.0",
|
|
@@ -59,12 +59,12 @@
|
|
|
59
59
|
"devDependencies": {
|
|
60
60
|
"@arco-design/web-react": "^2.56.1",
|
|
61
61
|
"@monaco-editor/react": "^4.6.0",
|
|
62
|
-
"@rspack/plugin-preact-refresh": "1.
|
|
62
|
+
"@rspack/plugin-preact-refresh": "1.1.0",
|
|
63
63
|
"@rspack/plugin-react-refresh": "1.0.0",
|
|
64
64
|
"@swc/helpers": "0.5.13",
|
|
65
65
|
"@swc/plugin-remove-console": "^3.0.0",
|
|
66
66
|
"@types/babel__generator": "7.6.8",
|
|
67
|
-
"@types/babel__traverse": "7.20.
|
|
67
|
+
"@types/babel__traverse": "7.20.6",
|
|
68
68
|
"@types/fs-extra": "11.0.4",
|
|
69
69
|
"@types/jsdom": "^21.1.7",
|
|
70
70
|
"@types/react": "^18.2.48",
|
|
@@ -78,14 +78,14 @@
|
|
|
78
78
|
"coffee-loader": "^5.0.0",
|
|
79
79
|
"coffeescript": "^2.5.1",
|
|
80
80
|
"copy-webpack-plugin": "5.1.2",
|
|
81
|
-
"core-js": "3.
|
|
81
|
+
"core-js": "3.38.1",
|
|
82
82
|
"css-loader": "^6.11.0",
|
|
83
83
|
"file-loader": "^6.2.0",
|
|
84
84
|
"html-loader": "^5.0.0",
|
|
85
85
|
"html-webpack-plugin": "^5.5.0",
|
|
86
86
|
"less-loader": "^12.2.0",
|
|
87
87
|
"lodash": "^4.17.21",
|
|
88
|
-
"monaco-editor": "0.
|
|
88
|
+
"monaco-editor": "0.52.0",
|
|
89
89
|
"monaco-editor-webpack-plugin": "7.1.0",
|
|
90
90
|
"normalize.css": "^8.0.0",
|
|
91
91
|
"postcss-loader": "^8.0.0",
|
|
@@ -99,14 +99,14 @@
|
|
|
99
99
|
"sass-loader": "^16.0.0",
|
|
100
100
|
"source-map-loader": "^5.0.0",
|
|
101
101
|
"style-loader": "^4.0.0",
|
|
102
|
-
"terser": "5.
|
|
102
|
+
"terser": "5.36.0",
|
|
103
103
|
"typescript": "^5.6.3",
|
|
104
104
|
"wast-loader": "^1.12.1",
|
|
105
|
-
"@rspack/cli": "1.1.0
|
|
106
|
-
"@rspack/core": "1.1.0
|
|
105
|
+
"@rspack/cli": "1.1.0",
|
|
106
|
+
"@rspack/core": "1.1.0"
|
|
107
107
|
},
|
|
108
108
|
"peerDependencies": {
|
|
109
|
-
"@rspack/core": ">=0.
|
|
109
|
+
"@rspack/core": ">=1.0.0"
|
|
110
110
|
},
|
|
111
111
|
"scripts": {
|
|
112
112
|
"build": "tsc -b ./tsconfig.build.json",
|