@rspack/test-tools 1.6.8 → 1.7.0-beta.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.
- 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/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/createFakeWorker.js +19 -1
- package/dist/plugin/lazy-compilation-test-plugin.js +1 -1
- package/package.json +3 -3
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/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)
|
|
@@ -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; },
|
|
@@ -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.0",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"description": "Test tools for rspack",
|
|
6
6
|
"main": "dist/index.js",
|
|
@@ -47,7 +47,7 @@
|
|
|
47
47
|
"jest-diff": "^29.7.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
52
|
"pretty-format": "29.7.0",
|
|
53
53
|
"rimraf": "^5.0.10",
|
|
@@ -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.0"
|
|
69
69
|
},
|
|
70
70
|
"peerDependencies": {
|
|
71
71
|
"@rspack/core": ">=1.0.0"
|