@rspack/test-tools 1.6.8 → 1.7.0-beta.1
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/builtin.js +1 -0
- package/dist/case/cache.js +1 -2
- package/dist/case/config.js +1 -2
- package/dist/case/diagnostic.js +1 -2
- package/dist/case/esm-output.js +4 -0
- package/dist/case/hash.js +1 -2
- package/dist/case/hook.js +1 -2
- package/dist/case/hot.js +1 -2
- package/dist/case/normal.js +1 -1
- package/dist/case/stats-output.js +8 -4
- package/dist/case/watch.js +17 -11
- package/dist/helper/legacy/checkArrayExpectation.js +8 -5
- package/dist/helper/legacy/createFakeWorker.js +20 -2
- package/dist/helper/legacy/createLazyTestEnv.js +1 -1
- package/dist/helper/legacy/deprecationTracking.js +11 -17
- package/dist/plugin/lazy-compilation-test-plugin.js +1 -1
- package/package.json +7 -7
package/dist/case/builtin.js
CHANGED
package/dist/case/cache.js
CHANGED
package/dist/case/config.js
CHANGED
package/dist/case/diagnostic.js
CHANGED
package/dist/case/esm-output.js
CHANGED
|
@@ -101,6 +101,10 @@ const defaultOptions = (_index, context) => ({
|
|
|
101
101
|
chunkIds: "named",
|
|
102
102
|
runtimeChunk: "single"
|
|
103
103
|
},
|
|
104
|
+
externals: {
|
|
105
|
+
fs: "module-import fs",
|
|
106
|
+
path: "module-import path"
|
|
107
|
+
},
|
|
104
108
|
plugins: [new core_1.default.experiments.EsmLibraryPlugin()],
|
|
105
109
|
experiments: {
|
|
106
110
|
css: true,
|
package/dist/case/hash.js
CHANGED
package/dist/case/hook.js
CHANGED
package/dist/case/hot.js
CHANGED
package/dist/case/normal.js
CHANGED
|
@@ -111,6 +111,7 @@ function defaultOptions(context, compilerOptions, mode) {
|
|
|
111
111
|
providedExports: true,
|
|
112
112
|
usedExports: true,
|
|
113
113
|
mangleExports: true,
|
|
114
|
+
inlineExports: true,
|
|
114
115
|
// CHANGE: rspack does not support `emitOnErrors` yet.
|
|
115
116
|
emitOnErrors: true,
|
|
116
117
|
concatenateModules: !!testConfig?.optimization?.concatenateModules,
|
|
@@ -195,7 +196,6 @@ function defaultOptions(context, compilerOptions, mode) {
|
|
|
195
196
|
},
|
|
196
197
|
asyncWebAssembly: true,
|
|
197
198
|
topLevelAwait: true,
|
|
198
|
-
inlineConst: true,
|
|
199
199
|
// CHANGE: rspack does not support `backCompat` yet.
|
|
200
200
|
// backCompat: false,
|
|
201
201
|
// CHANGE: Rspack enables `css` by default.
|
|
@@ -83,8 +83,7 @@ function defaultOptions(index, context) {
|
|
|
83
83
|
bundlerInfo: {
|
|
84
84
|
force: false
|
|
85
85
|
}
|
|
86
|
-
}
|
|
87
|
-
inlineConst: true
|
|
86
|
+
}
|
|
88
87
|
}
|
|
89
88
|
};
|
|
90
89
|
}
|
|
@@ -174,9 +173,14 @@ async function check(env, context, name, writeStatsOuptut, snapshot, stderr) {
|
|
|
174
173
|
// CHANGE: The time unit display in Rspack is second
|
|
175
174
|
.replace(/[.0-9]+(\s?s)/g, "X$1")
|
|
176
175
|
// CHANGE: Replace bundle size, since bundle sizes may differ between platforms
|
|
177
|
-
.replace(/[0-9]
|
|
178
|
-
.replace(/[0-9]+
|
|
176
|
+
.replace(/[0-9]+(\.[0-9]+)? KiB/g, "xx KiB")
|
|
177
|
+
.replace(/[0-9]+(\.[0-9]+)? bytes/g, "xx bytes")
|
|
178
|
+
.replace(/[0-9]+(\.[0-9]+)? ms/g, "xx ms");
|
|
179
179
|
}
|
|
180
|
+
actual = actual
|
|
181
|
+
.split("\n")
|
|
182
|
+
.filter(line => !line.includes("@rstest/core/dist"))
|
|
183
|
+
.join("\n");
|
|
180
184
|
const snapshotPath = node_path_1.default.isAbsolute(snapshot)
|
|
181
185
|
? snapshot
|
|
182
186
|
: node_path_1.default.resolve(context.getSource(), `./__snapshots__/${snapshot}`);
|
package/dist/case/watch.js
CHANGED
|
@@ -8,8 +8,8 @@ exports.createWatchStepProcessor = createWatchStepProcessor;
|
|
|
8
8
|
exports.createWatchCase = createWatchCase;
|
|
9
9
|
exports.getWatchRunnerKey = getWatchRunnerKey;
|
|
10
10
|
exports.createWatchRunner = createWatchRunner;
|
|
11
|
-
const node_fs_1 = __importDefault(require("node:fs"));
|
|
12
11
|
const node_path_1 = __importDefault(require("node:path"));
|
|
12
|
+
const fs_extra_1 = __importDefault(require("fs-extra"));
|
|
13
13
|
const webpack_merge_1 = __importDefault(require("webpack-merge"));
|
|
14
14
|
const compiler_1 = require("../compiler");
|
|
15
15
|
const helper_1 = require("../helper");
|
|
@@ -58,8 +58,14 @@ function createWatchInitialProcessor(name, tempDir, step, watchState, { incremen
|
|
|
58
58
|
},
|
|
59
59
|
build: async (context) => {
|
|
60
60
|
const compiler = context.getCompiler();
|
|
61
|
-
|
|
61
|
+
fs_extra_1.default.mkdirSync(watchContext.tempDir, { recursive: true });
|
|
62
62
|
(0, copyDiff_1.default)(node_path_1.default.join(context.getSource(), watchContext.step), watchContext.tempDir, true);
|
|
63
|
+
const pkgJsonFile = node_path_1.default.join(watchContext.tempDir, "package.json");
|
|
64
|
+
if (!fs_extra_1.default.existsSync(pkgJsonFile)) {
|
|
65
|
+
fs_extra_1.default.writeJsonSync(pkgJsonFile, { name, version: "0.0.1" });
|
|
66
|
+
const longTimeAgo = Date.now() - 1000 * 60 * 60 * 24;
|
|
67
|
+
fs_extra_1.default.utimesSync(pkgJsonFile, Date.now() - longTimeAgo, Date.now() - longTimeAgo);
|
|
68
|
+
}
|
|
63
69
|
const task = new Promise((resolve, reject) => {
|
|
64
70
|
compiler.getEmitter().once(compiler_1.ECompilerEvent.Build, (e, stats) => {
|
|
65
71
|
if (e)
|
|
@@ -88,7 +94,7 @@ function createWatchInitialProcessor(name, tempDir, step, watchState, { incremen
|
|
|
88
94
|
const checkStats = testConfig.checkStats || (() => true);
|
|
89
95
|
if (stats) {
|
|
90
96
|
if (testConfig.writeStatsOuptut) {
|
|
91
|
-
|
|
97
|
+
fs_extra_1.default.writeFileSync(node_path_1.default.join(context.getDist(), "stats.txt"), stats.toString({
|
|
92
98
|
preset: "verbose",
|
|
93
99
|
colors: false
|
|
94
100
|
}), "utf-8");
|
|
@@ -127,10 +133,10 @@ function createWatchInitialProcessor(name, tempDir, step, watchState, { incremen
|
|
|
127
133
|
}
|
|
128
134
|
}
|
|
129
135
|
if (testConfig.writeStatsJson) {
|
|
130
|
-
|
|
136
|
+
fs_extra_1.default.writeFileSync(node_path_1.default.join(context.getDist(), "stats.json"), JSON.stringify(getJsonStats(), null, 2), "utf-8");
|
|
131
137
|
}
|
|
132
|
-
if (
|
|
133
|
-
|
|
138
|
+
if (fs_extra_1.default.existsSync(context.getSource(`${watchContext.step}/errors.js`)) ||
|
|
139
|
+
fs_extra_1.default.existsSync(context.getSource(`${watchContext.step}/warnings.js`)) ||
|
|
134
140
|
stats.hasErrors() ||
|
|
135
141
|
stats.hasWarnings()) {
|
|
136
142
|
const statsJson = stats.toJson({
|
|
@@ -147,15 +153,15 @@ function createWatchInitialProcessor(name, tempDir, step, watchState, { incremen
|
|
|
147
153
|
await (0, checkArrayExpectation_1.default)(node_path_1.default.join(context.getSource(), watchContext.step), { errors }, "error", "errors", "Error", options);
|
|
148
154
|
await (0, checkArrayExpectation_1.default)(node_path_1.default.join(context.getSource(), watchContext.step), { warnings }, "warning", "warnings", "Warning", options);
|
|
149
155
|
// clear error if checked
|
|
150
|
-
if (
|
|
156
|
+
if (fs_extra_1.default.existsSync(context.getSource("errors.js"))) {
|
|
151
157
|
context.clearError();
|
|
152
158
|
}
|
|
153
159
|
// check hash
|
|
154
160
|
if (testConfig.writeStatsOuptut) {
|
|
155
|
-
|
|
161
|
+
fs_extra_1.default.renameSync(node_path_1.default.join(context.getDist(), "stats.txt"), node_path_1.default.join(context.getDist(), `stats.${watchContext.step}.txt`));
|
|
156
162
|
}
|
|
157
163
|
if (testConfig.writeStatsJson) {
|
|
158
|
-
|
|
164
|
+
fs_extra_1.default.renameSync(node_path_1.default.join(context.getDist(), "stats.json"), node_path_1.default.join(context.getDist(), `stats.${watchContext.step}.json`));
|
|
159
165
|
}
|
|
160
166
|
},
|
|
161
167
|
after: async (context) => {
|
|
@@ -206,10 +212,10 @@ const creator = new creator_1.BasicCaseCreator({
|
|
|
206
212
|
describe: false,
|
|
207
213
|
steps: ({ name, src, temp }) => {
|
|
208
214
|
const watchState = {};
|
|
209
|
-
const runs =
|
|
215
|
+
const runs = fs_extra_1.default
|
|
210
216
|
.readdirSync(src)
|
|
211
217
|
.sort()
|
|
212
|
-
.filter(name =>
|
|
218
|
+
.filter(name => fs_extra_1.default.statSync(node_path_1.default.join(src, name)).isDirectory())
|
|
213
219
|
.map(name => ({ name }));
|
|
214
220
|
return runs.map((run, index) => index === 0
|
|
215
221
|
? createWatchInitialProcessor(name, temp, run.name, watchState)
|
|
@@ -60,9 +60,12 @@ ${tooMuch.map(item => `${explain(item)}`).join("\n\n")}`);
|
|
|
60
60
|
return diff.join("\n\n");
|
|
61
61
|
};
|
|
62
62
|
module.exports = async function checkArrayExpectation(testDirectory, object, kind, filename, upperCaseKind, options, done) {
|
|
63
|
-
done =
|
|
64
|
-
|
|
65
|
-
|
|
63
|
+
done =
|
|
64
|
+
typeof done === "function"
|
|
65
|
+
? done
|
|
66
|
+
: error => {
|
|
67
|
+
throw error;
|
|
68
|
+
};
|
|
66
69
|
let array = object[`${kind}s`];
|
|
67
70
|
if (Array.isArray(array) && kind === "warning") {
|
|
68
71
|
array = array.filter(item => !/from Terser/.test(item));
|
|
@@ -121,14 +124,14 @@ module.exports = async function checkArrayExpectation(testDirectory, object, kin
|
|
|
121
124
|
for (let j = 0; j < expected.length; j++) {
|
|
122
125
|
if (!usedExpected[j]) {
|
|
123
126
|
unused.push(Array.isArray(expected[j])
|
|
124
|
-
? expected[j].map(explain).join(
|
|
127
|
+
? expected[j].map(explain).join(" | ")
|
|
125
128
|
: explain(expected[j]));
|
|
126
129
|
}
|
|
127
130
|
}
|
|
128
131
|
if (unused.length > 0) {
|
|
129
132
|
done(new Error(`The following expected ${kind}s were not matched:\n${unused
|
|
130
133
|
.map(u => ` ${u}`)
|
|
131
|
-
.join(
|
|
134
|
+
.join("\n")}`));
|
|
132
135
|
return true;
|
|
133
136
|
}
|
|
134
137
|
}
|
|
@@ -36,6 +36,22 @@ self.importScripts = url => {
|
|
|
36
36
|
: "require(urlToPath(url))"};
|
|
37
37
|
};
|
|
38
38
|
self.fetch = async url => {
|
|
39
|
+
if (typeof url === "string" ? url.endsWith(".wasm") : url.toString().endsWith(".wasm")) {
|
|
40
|
+
return new Promise((resolve, reject) => {
|
|
41
|
+
fs.readFile(require("node:url").fileURLToPath(url), (err, data) => {
|
|
42
|
+
if (err) {
|
|
43
|
+
reject(err);
|
|
44
|
+
return;
|
|
45
|
+
}
|
|
46
|
+
return resolve(
|
|
47
|
+
new Response(data, {
|
|
48
|
+
headers: { "Content-Type": "application/wasm" }
|
|
49
|
+
})
|
|
50
|
+
);
|
|
51
|
+
});
|
|
52
|
+
});
|
|
53
|
+
}
|
|
54
|
+
|
|
39
55
|
try {
|
|
40
56
|
const buffer = await new Promise((resolve, reject) =>
|
|
41
57
|
fs.readFile(urlToPath(url), (err, b) =>
|
|
@@ -43,7 +59,9 @@ self.fetch = async url => {
|
|
|
43
59
|
)
|
|
44
60
|
);
|
|
45
61
|
return {
|
|
46
|
-
headers: { get(name) {
|
|
62
|
+
headers: { get(name) {
|
|
63
|
+
if (name.toLowerCase() === "content-type") {}
|
|
64
|
+
} },
|
|
47
65
|
status: 200,
|
|
48
66
|
ok: true,
|
|
49
67
|
arrayBuffer() { return buffer; },
|
|
@@ -89,7 +107,7 @@ if (${options.type === "module"}) {
|
|
|
89
107
|
set onmessage(value) {
|
|
90
108
|
if (this._onmessage)
|
|
91
109
|
this.worker.off("message", this._onmessage);
|
|
92
|
-
this.worker.on("message", (this._onmessage =
|
|
110
|
+
this.worker.on("message", (this._onmessage = data => {
|
|
93
111
|
value({
|
|
94
112
|
data
|
|
95
113
|
});
|
|
@@ -4,24 +4,18 @@
|
|
|
4
4
|
Author Tobias Koppers @sokra
|
|
5
5
|
*/
|
|
6
6
|
"use strict";
|
|
7
|
-
const util = require("util");
|
|
8
7
|
let interception = undefined;
|
|
9
|
-
const
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
}
|
|
21
|
-
else {
|
|
22
|
-
return original.apply(this, args);
|
|
23
|
-
}
|
|
24
|
-
};
|
|
8
|
+
const originalWarn = console.warn;
|
|
9
|
+
console.warn = (message, ...args) => {
|
|
10
|
+
if (interception &&
|
|
11
|
+
typeof message === "string" &&
|
|
12
|
+
message.includes("[Rspack Deprecation]")) {
|
|
13
|
+
interception.set(message, {
|
|
14
|
+
message,
|
|
15
|
+
stack: new Error(message).stack
|
|
16
|
+
});
|
|
17
|
+
}
|
|
18
|
+
return originalWarn.apply(console, [message, ...args]);
|
|
25
19
|
};
|
|
26
20
|
exports.start = handler => {
|
|
27
21
|
interception = new Map();
|
|
@@ -29,7 +29,7 @@ class LazyCompilationTestPlugin {
|
|
|
29
29
|
else if (compiler.options.lazyCompilation) {
|
|
30
30
|
compiler.options.lazyCompilation.serverUrl = urlBase;
|
|
31
31
|
}
|
|
32
|
-
middleware = core_1.
|
|
32
|
+
middleware = (0, core_1.lazyCompilationMiddleware)(compiler);
|
|
33
33
|
resolve(null);
|
|
34
34
|
});
|
|
35
35
|
server.on("request", (req, res) => {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rspack/test-tools",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.7.0-beta.1",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"description": "Test tools for rspack",
|
|
6
6
|
"main": "dist/index.js",
|
|
@@ -42,17 +42,17 @@
|
|
|
42
42
|
"cross-env": "^10.1.0",
|
|
43
43
|
"filenamify": "4.3.0",
|
|
44
44
|
"fs-extra": "^11.3.2",
|
|
45
|
-
"iconv-lite": "^0.7.
|
|
45
|
+
"iconv-lite": "^0.7.1",
|
|
46
46
|
"javascript-stringify": "^2.1.0",
|
|
47
|
-
"jest-diff": "^
|
|
47
|
+
"jest-diff": "^30.2.0",
|
|
48
48
|
"jest-snapshot": "29.7.0",
|
|
49
49
|
"jsdom": "^26.1.0",
|
|
50
|
-
"memfs": "4.
|
|
50
|
+
"memfs": "4.51.1",
|
|
51
51
|
"path-serializer": "0.5.1",
|
|
52
|
-
"pretty-format": "
|
|
52
|
+
"pretty-format": "30.2.0",
|
|
53
53
|
"rimraf": "^5.0.10",
|
|
54
54
|
"source-map": "^0.7.6",
|
|
55
|
-
"terser-webpack-plugin": "^5.3.
|
|
55
|
+
"terser-webpack-plugin": "^5.3.16",
|
|
56
56
|
"webpack": "5.102.1",
|
|
57
57
|
"webpack-merge": "6.0.1",
|
|
58
58
|
"webpack-sources": "3.3.3",
|
|
@@ -65,7 +65,7 @@
|
|
|
65
65
|
"@types/jsdom": "^21.1.7",
|
|
66
66
|
"typescript": "^5.9.3",
|
|
67
67
|
"wast-loader": "^1.14.1",
|
|
68
|
-
"@rspack/core": "1.
|
|
68
|
+
"@rspack/core": "1.7.0-beta.1"
|
|
69
69
|
},
|
|
70
70
|
"peerDependencies": {
|
|
71
71
|
"@rspack/core": ">=1.0.0"
|