@rspack-canary/test-tools 1.6.0-canary-2ccce257-20251016173648 → 1.6.0-canary-beafb11e-20251017173713
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/cache.d.ts +1 -1
- package/dist/case/cache.js +1 -3
- package/dist/case/common.js +2 -2
- package/dist/case/diagnostic.js +1 -1
- package/dist/case/hot-step.js +0 -3
- package/dist/case/hot.js +30 -43
- package/dist/case/incremental.js +1 -1
- package/dist/case/runner.js +1 -1
- package/dist/case/watch.js +2 -2
- package/dist/helper/read-config-file.d.ts +2 -2
- package/dist/helper/read-config-file.js +5 -2
- package/dist/runner/node/index.js +1 -0
- package/dist/runner/web/fake.js +0 -1
- package/dist/runner/web/jsdom.d.ts +1 -1
- package/dist/runner/web/jsdom.js +45 -28
- package/dist/test/tester.js +6 -1
- package/package.json +2 -2
- package/dist/helper/legacy/update.d.ts +0 -2
- package/dist/helper/legacy/update.esm.d.ts +0 -1
- package/dist/helper/legacy/update.esm.js +0 -23
- package/dist/helper/legacy/update.js +0 -19
package/dist/case/cache.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import type { ECompilerType, TCompilerOptions } from "../type";
|
|
2
2
|
export declare function createCacheCase(name: string, src: string, dist: string, target: TCompilerOptions<ECompilerType.Rspack>["target"], temp: string): void;
|
package/dist/case/cache.js
CHANGED
|
@@ -11,7 +11,6 @@ const hot_update_1 = require("../helper/hot-update");
|
|
|
11
11
|
const checkArrayExpectation_1 = __importDefault(require("../helper/legacy/checkArrayExpectation"));
|
|
12
12
|
const runner_1 = require("../runner");
|
|
13
13
|
const creator_1 = require("../test/creator");
|
|
14
|
-
const type_1 = require("../type");
|
|
15
14
|
const common_1 = require("./common");
|
|
16
15
|
const runner_2 = require("./runner");
|
|
17
16
|
const MAX_COMPILER_INDEX = 100;
|
|
@@ -161,8 +160,7 @@ function createRunner(context, name, file, env) {
|
|
|
161
160
|
const dist = context.getDist();
|
|
162
161
|
const updatePlugin = context.getValue(name, "hotUpdateContext");
|
|
163
162
|
const getWebRunner = () => {
|
|
164
|
-
return new runner_1.
|
|
165
|
-
dom: context.getValue(name, "documentType") || type_1.EDocumentType.JSDOM,
|
|
163
|
+
return new runner_1.NodeRunner({
|
|
166
164
|
env,
|
|
167
165
|
stats: (0, runner_2.cachedStats)(context, name),
|
|
168
166
|
cachable: false,
|
package/dist/case/common.js
CHANGED
|
@@ -26,7 +26,7 @@ async function config(context, name, configFiles, defaultOptions = {}) {
|
|
|
26
26
|
const compiler = getCompiler(context, name);
|
|
27
27
|
compiler.setOptions(defaultOptions);
|
|
28
28
|
if (Array.isArray(configFiles)) {
|
|
29
|
-
const fileOptions = (0, helper_1.readConfigFile)(configFiles.map(i => context.getSource(i)))[0];
|
|
29
|
+
const fileOptions = (0, helper_1.readConfigFile)(configFiles.map(i => context.getSource(i)), context, defaultOptions)[0];
|
|
30
30
|
compiler.mergeOptions(fileOptions);
|
|
31
31
|
}
|
|
32
32
|
return compiler.getOptions();
|
|
@@ -215,7 +215,7 @@ function findMultiCompilerBundle(context, name, multiFindBundle) {
|
|
|
215
215
|
function configMultiCompiler(context, name, configFiles, defaultOptions, overrideOptions) {
|
|
216
216
|
const multiCompilerOptions = [];
|
|
217
217
|
const caseOptions = Array.isArray(configFiles)
|
|
218
|
-
? (0, helper_1.readConfigFile)(configFiles.map(i => context.getSource(i)), configs => {
|
|
218
|
+
? (0, helper_1.readConfigFile)(configFiles.map(i => context.getSource(i)), context, {}, configs => {
|
|
219
219
|
return configs.flatMap(c => {
|
|
220
220
|
if (typeof c === "function") {
|
|
221
221
|
const options = {
|
package/dist/case/diagnostic.js
CHANGED
|
@@ -19,7 +19,7 @@ const creator = new creator_1.BasicCaseCreator({
|
|
|
19
19
|
config: async (context) => {
|
|
20
20
|
const compiler = (0, common_1.getCompiler)(context, name);
|
|
21
21
|
let options = defaultOptions(context);
|
|
22
|
-
const custom = (0, helper_1.readConfigFile)(["rspack.config.js", "webpack.config.js"].map(i => context.getSource(i)))[0];
|
|
22
|
+
const custom = (0, helper_1.readConfigFile)(["rspack.config.js", "webpack.config.js"].map(i => context.getSource(i)), context, options)[0];
|
|
23
23
|
if (custom) {
|
|
24
24
|
options = (0, webpack_merge_1.default)(options, custom);
|
|
25
25
|
}
|
package/dist/case/hot-step.js
CHANGED
|
@@ -24,9 +24,6 @@ const SELF_HANDLER = (file, options) => {
|
|
|
24
24
|
global.self[hotUpdateGlobalKey] = hotUpdateGlobal;
|
|
25
25
|
require(file);
|
|
26
26
|
delete global.self[hotUpdateGlobalKey];
|
|
27
|
-
if (!Object.keys(global.self).length) {
|
|
28
|
-
delete global.self;
|
|
29
|
-
}
|
|
30
27
|
return res;
|
|
31
28
|
};
|
|
32
29
|
const NODE_HANDLER = (file) => {
|
package/dist/case/hot.js
CHANGED
|
@@ -175,67 +175,43 @@ function createHotRunner(context, name, file, env) {
|
|
|
175
175
|
const source = context.getSource();
|
|
176
176
|
const dist = context.getDist();
|
|
177
177
|
const updatePlugin = context.getValue(name, "hotUpdatePlugin");
|
|
178
|
-
const
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
if (!stats) {
|
|
184
|
-
throw new Error("Should generate stats during build");
|
|
185
|
-
}
|
|
186
|
-
const jsonStats = stats.toJson({
|
|
187
|
-
// errorDetails: true
|
|
188
|
-
});
|
|
189
|
-
const compilerOptions = compiler.getOptions();
|
|
190
|
-
const checker = context.getValue(name, jsonStats.errors?.length
|
|
191
|
-
? "hotUpdateStepErrorChecker"
|
|
192
|
-
: "hotUpdateStepChecker");
|
|
193
|
-
if (checker) {
|
|
194
|
-
checker(updatePlugin.getUpdateIndex(), stats, runner.getGlobal("__HMR_UPDATED_RUNTIME__"));
|
|
195
|
-
}
|
|
196
|
-
await (0, checkArrayExpectation_1.default)(source, jsonStats, "error", `errors${updatePlugin.getUpdateIndex()}`, "Error", compilerOptions);
|
|
197
|
-
await (0, checkArrayExpectation_1.default)(source, jsonStats, "warning", `warnings${updatePlugin.getUpdateIndex()}`, "Warning", compilerOptions);
|
|
198
|
-
if (usePromise) {
|
|
199
|
-
// old callback style hmr cases
|
|
200
|
-
callback(null, jsonStats);
|
|
201
|
-
}
|
|
202
|
-
else {
|
|
203
|
-
// new promise style hmr cases
|
|
204
|
-
return jsonStats;
|
|
205
|
-
}
|
|
178
|
+
const nextHMR = async (m, options) => {
|
|
179
|
+
await updatePlugin.goNext();
|
|
180
|
+
const stats = await compiler.build();
|
|
181
|
+
if (!stats) {
|
|
182
|
+
throw new Error("Should generate stats during build");
|
|
206
183
|
}
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
184
|
+
const jsonStats = stats.toJson({
|
|
185
|
+
// errorDetails: true
|
|
186
|
+
});
|
|
187
|
+
const compilerOptions = compiler.getOptions();
|
|
188
|
+
const checker = context.getValue(name, jsonStats.errors?.length
|
|
189
|
+
? "hotUpdateStepErrorChecker"
|
|
190
|
+
: "hotUpdateStepChecker");
|
|
191
|
+
if (checker) {
|
|
192
|
+
checker(updatePlugin.getUpdateIndex(), stats, runner.getGlobal("__HMR_UPDATED_RUNTIME__"));
|
|
214
193
|
}
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
const jsonStats = await next();
|
|
194
|
+
await (0, checkArrayExpectation_1.default)(source, jsonStats, "error", `errors${updatePlugin.getUpdateIndex()}`, "Error", compilerOptions);
|
|
195
|
+
await (0, checkArrayExpectation_1.default)(source, jsonStats, "warning", `warnings${updatePlugin.getUpdateIndex()}`, "Warning", compilerOptions);
|
|
218
196
|
const updatedModules = await m.hot.check(options || true);
|
|
219
197
|
if (!updatedModules) {
|
|
220
198
|
throw new Error("No update available");
|
|
221
199
|
}
|
|
222
200
|
return jsonStats;
|
|
223
201
|
};
|
|
224
|
-
const
|
|
225
|
-
dom: context.getValue(name, "documentType") || type_1.EDocumentType.JSDOM,
|
|
202
|
+
const commonOptions = {
|
|
226
203
|
env,
|
|
227
204
|
stats: (0, runner_2.cachedStats)(context, name),
|
|
228
205
|
name: name,
|
|
229
206
|
runInNewContext: false,
|
|
230
207
|
testConfig: {
|
|
231
|
-
documentType: testConfig.documentType || type_1.EDocumentType.
|
|
208
|
+
documentType: testConfig.documentType || type_1.EDocumentType.JSDOM,
|
|
232
209
|
...testConfig,
|
|
233
210
|
moduleScope(ms, stats, options) {
|
|
234
211
|
const moduleScope = ms;
|
|
235
212
|
if (typeof testConfig.moduleScope === "function") {
|
|
236
213
|
testConfig.moduleScope(moduleScope, stats, compilerOptions);
|
|
237
214
|
}
|
|
238
|
-
moduleScope.NEXT = next;
|
|
239
215
|
moduleScope.NEXT_HMR = nextHMR;
|
|
240
216
|
return moduleScope;
|
|
241
217
|
}
|
|
@@ -244,6 +220,17 @@ function createHotRunner(context, name, file, env) {
|
|
|
244
220
|
source,
|
|
245
221
|
dist,
|
|
246
222
|
compilerOptions
|
|
247
|
-
}
|
|
223
|
+
};
|
|
224
|
+
let runner;
|
|
225
|
+
if (compilerOptions.target === "web" ||
|
|
226
|
+
compilerOptions.target === "webworker") {
|
|
227
|
+
runner = new runner_1.WebRunner({
|
|
228
|
+
dom: context.getValue(name, "documentType") || type_1.EDocumentType.JSDOM,
|
|
229
|
+
...commonOptions
|
|
230
|
+
});
|
|
231
|
+
}
|
|
232
|
+
else {
|
|
233
|
+
runner = new runner_1.NodeRunner(commonOptions);
|
|
234
|
+
}
|
|
248
235
|
return runner;
|
|
249
236
|
}
|
package/dist/case/incremental.js
CHANGED
|
@@ -17,7 +17,7 @@ function createHotIncrementalProcessor(name, src, temp, target, webpackCases) {
|
|
|
17
17
|
const originalBefore = processor.before;
|
|
18
18
|
processor.before = async (context) => {
|
|
19
19
|
await originalBefore?.(context);
|
|
20
|
-
context.setValue(name, "documentType", webpackCases ? type_1.EDocumentType.
|
|
20
|
+
context.setValue(name, "documentType", webpackCases ? type_1.EDocumentType.JSDOM : type_1.EDocumentType.JSDOM);
|
|
21
21
|
};
|
|
22
22
|
const originalAfterAll = processor.afterAll;
|
|
23
23
|
processor.afterAll = async function (context) {
|
package/dist/case/runner.js
CHANGED
|
@@ -42,7 +42,7 @@ function createRunner(context, name, file, env) {
|
|
|
42
42
|
return new runner_1.WebRunner({
|
|
43
43
|
...runnerOptions,
|
|
44
44
|
runInNewContext: true,
|
|
45
|
-
dom: context.getValue(name, "documentType") || type_1.EDocumentType.
|
|
45
|
+
dom: context.getValue(name, "documentType") || type_1.EDocumentType.JSDOM
|
|
46
46
|
});
|
|
47
47
|
}
|
|
48
48
|
return new runner_1.NodeRunner(runnerOptions);
|
package/dist/case/watch.js
CHANGED
|
@@ -35,7 +35,7 @@ function createWatchInitialProcessor(name, tempDir, step, watchState, { incremen
|
|
|
35
35
|
config: async (context) => {
|
|
36
36
|
const testConfig = context.getTestConfig();
|
|
37
37
|
const multiCompilerOptions = [];
|
|
38
|
-
const caseOptions = (0, helper_1.readConfigFile)(["rspack.config.js", "webpack.config.js"].map(i => context.getSource(i)));
|
|
38
|
+
const caseOptions = (0, helper_1.readConfigFile)(["rspack.config.js", "webpack.config.js"].map(i => context.getSource(i)), context, {});
|
|
39
39
|
for (const [index, options] of caseOptions.entries()) {
|
|
40
40
|
const compilerOptions = (0, webpack_merge_1.default)(defaultOptions({
|
|
41
41
|
incremental,
|
|
@@ -321,7 +321,7 @@ function createWatchRunner(context, name, file, env) {
|
|
|
321
321
|
: compilerOptions.target === "web" ||
|
|
322
322
|
compilerOptions.target === "webworker";
|
|
323
323
|
const testConfig = context.getTestConfig();
|
|
324
|
-
const documentType = context.getValue(name, "documentType") || type_1.EDocumentType.
|
|
324
|
+
const documentType = context.getValue(name, "documentType") || type_1.EDocumentType.JSDOM;
|
|
325
325
|
return new runner_1.WebRunner({
|
|
326
326
|
dom: documentType,
|
|
327
327
|
env,
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import type { ECompilerType, TCompilerOptions } from "../type";
|
|
2
|
-
export declare function readConfigFile<T extends ECompilerType>(files: string[], functionApply?: (config: (TCompilerOptions<T> | ((...args: unknown[]) => TCompilerOptions<T>))[]) => TCompilerOptions<T>[]): TCompilerOptions<T>[];
|
|
1
|
+
import type { ECompilerType, ITestContext, TCompilerOptions } from "../type";
|
|
2
|
+
export declare function readConfigFile<T extends ECompilerType>(files: string[], context: ITestContext, prevOption?: TCompilerOptions<T>, functionApply?: (config: (TCompilerOptions<T> | ((...args: unknown[]) => TCompilerOptions<T>))[]) => TCompilerOptions<T>[]): TCompilerOptions<T>[];
|
|
@@ -5,9 +5,12 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
exports.readConfigFile = readConfigFile;
|
|
7
7
|
const fs_extra_1 = __importDefault(require("fs-extra"));
|
|
8
|
-
function readConfigFile(files, functionApply) {
|
|
8
|
+
function readConfigFile(files, context, prevOption, functionApply) {
|
|
9
9
|
const existsFile = files.find(i => fs_extra_1.default.existsSync(i));
|
|
10
|
-
|
|
10
|
+
let fileConfig = existsFile ? require(existsFile) : {};
|
|
11
|
+
if (typeof fileConfig === "function") {
|
|
12
|
+
fileConfig = fileConfig({ config: prevOption }, { testPath: context.getDist(), tempPath: context.getTemp() });
|
|
13
|
+
}
|
|
11
14
|
const configArr = Array.isArray(fileConfig) ? fileConfig : [fileConfig];
|
|
12
15
|
return functionApply ? functionApply(configArr) : configArr;
|
|
13
16
|
}
|
|
@@ -164,6 +164,7 @@ class NodeRunner {
|
|
|
164
164
|
Symbol,
|
|
165
165
|
Buffer,
|
|
166
166
|
setImmediate,
|
|
167
|
+
self: this.globalContext,
|
|
167
168
|
__MODE__: this._options.compilerOptions.mode,
|
|
168
169
|
__SNAPSHOT__: node_path_1.default.join(this._options.source, "__snapshot__"),
|
|
169
170
|
Worker: (0, createFakeWorker_1.default)(this._options.env, {
|
package/dist/runner/web/fake.js
CHANGED
|
@@ -123,7 +123,6 @@ class FakeDocumentWebRunner extends node_1.NodeRunner {
|
|
|
123
123
|
createBaseModuleScope() {
|
|
124
124
|
const moduleScope = super.createBaseModuleScope();
|
|
125
125
|
moduleScope.window = this.globalContext;
|
|
126
|
-
moduleScope.self = this.globalContext;
|
|
127
126
|
moduleScope.globalThis = this.globalContext;
|
|
128
127
|
moduleScope.document = this.globalContext.document;
|
|
129
128
|
moduleScope.getComputedStyle = this.globalContext.getComputedStyle.bind(this.globalContext);
|
|
@@ -11,9 +11,9 @@ export declare class JSDOMWebRunner<T extends ECompilerType = ECompilerType.Rspa
|
|
|
11
11
|
element: HTMLScriptElement;
|
|
12
12
|
}): any;
|
|
13
13
|
};
|
|
14
|
+
private urlToPath;
|
|
14
15
|
protected createBaseModuleScope(): import("../../type").IModuleScope;
|
|
15
16
|
protected getModuleContent(file: TRunnerFile): [
|
|
16
|
-
Record<string, unknown>,
|
|
17
17
|
{
|
|
18
18
|
exports: Record<string, unknown>;
|
|
19
19
|
},
|
package/dist/runner/web/jsdom.js
CHANGED
|
@@ -17,8 +17,10 @@ class JSDOMWebRunner extends node_1.NodeRunner {
|
|
|
17
17
|
constructor(_webOptions) {
|
|
18
18
|
super(_webOptions);
|
|
19
19
|
this._webOptions = _webOptions;
|
|
20
|
-
const virtualConsole = new jsdom_1.VirtualConsole();
|
|
21
|
-
virtualConsole.sendTo(console
|
|
20
|
+
const virtualConsole = new jsdom_1.VirtualConsole({});
|
|
21
|
+
virtualConsole.sendTo(console, {
|
|
22
|
+
omitJSDOMErrors: true
|
|
23
|
+
});
|
|
22
24
|
this.dom = new jsdom_1.JSDOM(`
|
|
23
25
|
<!doctype html>
|
|
24
26
|
<html>
|
|
@@ -67,18 +69,13 @@ class JSDOMWebRunner extends node_1.NodeRunner {
|
|
|
67
69
|
return super.run(file);
|
|
68
70
|
}
|
|
69
71
|
getGlobal(name) {
|
|
70
|
-
return this.
|
|
72
|
+
return this.globalContext[name];
|
|
71
73
|
}
|
|
72
74
|
createResourceLoader() {
|
|
73
|
-
const urlToPath = (url) => {
|
|
74
|
-
return node_path_1.default
|
|
75
|
-
.resolve(this._webOptions.dist, `./${url.startsWith("https://test.cases/path/") ? url.slice(24) : url}`)
|
|
76
|
-
.split("?")[0];
|
|
77
|
-
};
|
|
78
75
|
const that = this;
|
|
79
76
|
class CustomResourceLoader extends jsdom_1.ResourceLoader {
|
|
80
77
|
fetch(url, _) {
|
|
81
|
-
const filePath = urlToPath(url);
|
|
78
|
+
const filePath = that.urlToPath(url);
|
|
82
79
|
let finalCode;
|
|
83
80
|
if (node_path_1.default.extname(filePath) === ".js") {
|
|
84
81
|
const currentDirectory = node_path_1.default.dirname(filePath);
|
|
@@ -86,13 +83,15 @@ class JSDOMWebRunner extends node_1.NodeRunner {
|
|
|
86
83
|
if (!file) {
|
|
87
84
|
throw new Error(`File not found: ${filePath}`);
|
|
88
85
|
}
|
|
89
|
-
const [
|
|
86
|
+
const [_m, code] = that.getModuleContent(file);
|
|
90
87
|
finalCode = code;
|
|
91
88
|
}
|
|
92
89
|
else {
|
|
93
90
|
finalCode = node_fs_1.default.readFileSync(filePath);
|
|
94
91
|
}
|
|
95
92
|
try {
|
|
93
|
+
that.dom.window["__LINK_SHEET__"] ??= {};
|
|
94
|
+
that.dom.window["__LINK_SHEET__"][url] = finalCode.toString();
|
|
96
95
|
return Promise.resolve(finalCode);
|
|
97
96
|
}
|
|
98
97
|
catch (err) {
|
|
@@ -106,15 +105,17 @@ class JSDOMWebRunner extends node_1.NodeRunner {
|
|
|
106
105
|
}
|
|
107
106
|
return new CustomResourceLoader();
|
|
108
107
|
}
|
|
108
|
+
urlToPath(url) {
|
|
109
|
+
return node_path_1.default
|
|
110
|
+
.resolve(this._webOptions.dist, `./${url.startsWith("https://test.cases/path/") ? url.slice(24) : url.startsWith("https://example.com/public/path/") ? url.slice(32) : url}`)
|
|
111
|
+
.split("?")[0];
|
|
112
|
+
}
|
|
109
113
|
createBaseModuleScope() {
|
|
110
114
|
const moduleScope = super.createBaseModuleScope();
|
|
111
115
|
moduleScope.EventSource = EventSourceForNode_1.default;
|
|
112
|
-
const urlToPath = (url) => {
|
|
113
|
-
return node_path_1.default.resolve(this._webOptions.dist, `./${url.startsWith("https://test.cases/path/") ? url.slice(24) : url}`);
|
|
114
|
-
};
|
|
115
116
|
moduleScope.fetch = async (url) => {
|
|
116
117
|
try {
|
|
117
|
-
const buffer = await new Promise((resolve, reject) => node_fs_1.default.readFile(urlToPath(url), (err, b) => err ? reject(err) : resolve(b)));
|
|
118
|
+
const buffer = await new Promise((resolve, reject) => node_fs_1.default.readFile(this.urlToPath(url), (err, b) => err ? reject(err) : resolve(b)));
|
|
118
119
|
return {
|
|
119
120
|
status: 200,
|
|
120
121
|
ok: true,
|
|
@@ -136,8 +137,8 @@ class JSDOMWebRunner extends node_1.NodeRunner {
|
|
|
136
137
|
this._options.env.expect(url).toMatch(/^https:\/\/test\.cases\/path\//);
|
|
137
138
|
this.requirers.get("entry")(this._options.dist, (0, urlToRelativePath_1.default)(url));
|
|
138
139
|
};
|
|
139
|
-
moduleScope.getComputedStyle =
|
|
140
|
-
const computedStyle = this.dom.window.getComputedStyle(
|
|
140
|
+
moduleScope.getComputedStyle = (element) => {
|
|
141
|
+
const computedStyle = this.dom.window.getComputedStyle(element);
|
|
141
142
|
const getPropertyValue = computedStyle.getPropertyValue.bind(computedStyle);
|
|
142
143
|
return {
|
|
143
144
|
...computedStyle,
|
|
@@ -146,6 +147,8 @@ class JSDOMWebRunner extends node_1.NodeRunner {
|
|
|
146
147
|
}
|
|
147
148
|
};
|
|
148
149
|
};
|
|
150
|
+
moduleScope.window = this.dom.window;
|
|
151
|
+
moduleScope.document = this.dom.window.document;
|
|
149
152
|
return moduleScope;
|
|
150
153
|
}
|
|
151
154
|
getModuleContent(file) {
|
|
@@ -156,14 +159,23 @@ class JSDOMWebRunner extends node_1.NodeRunner {
|
|
|
156
159
|
if (this._options.testConfig.moduleScope) {
|
|
157
160
|
this._options.testConfig.moduleScope(currentModuleScope, this._options.stats, this._options.compilerOptions);
|
|
158
161
|
}
|
|
162
|
+
if (file.content.includes("__STATS__")) {
|
|
163
|
+
currentModuleScope.__STATS__ = this._options.stats?.();
|
|
164
|
+
}
|
|
165
|
+
if (file.content.includes("__STATS_I__")) {
|
|
166
|
+
const statsIndex = this._options.stats?.()?.__index__;
|
|
167
|
+
if (typeof statsIndex === "number") {
|
|
168
|
+
currentModuleScope.__STATS_I__ = statsIndex;
|
|
169
|
+
}
|
|
170
|
+
}
|
|
159
171
|
const scopeKey = (0, helper_1.escapeSep)(file.path);
|
|
160
172
|
const args = Object.keys(currentModuleScope).filter(arg => !["window", "self", "globalThis", "console"].includes(arg));
|
|
161
173
|
const argValues = args
|
|
162
174
|
.map(arg => `window["${scopeKey}"]["${arg}"]`)
|
|
163
175
|
.join(", ");
|
|
164
176
|
this.dom.window[scopeKey] = currentModuleScope;
|
|
177
|
+
this.dom.window["__GLOBAL_SHARED__"] = this.globalContext;
|
|
165
178
|
return [
|
|
166
|
-
this.dom.window[scopeKey],
|
|
167
179
|
m,
|
|
168
180
|
`
|
|
169
181
|
// hijack document.currentScript for auto public path
|
|
@@ -182,11 +194,25 @@ class JSDOMWebRunner extends node_1.NodeRunner {
|
|
|
182
194
|
});
|
|
183
195
|
}
|
|
184
196
|
return Reflect.get(target, prop, receiver);
|
|
197
|
+
},
|
|
198
|
+
});
|
|
199
|
+
var $$self$$ = new Proxy(window, {
|
|
200
|
+
get(target, prop, receiver) {
|
|
201
|
+
if (prop === "__HMR_UPDATED_RUNTIME__") {
|
|
202
|
+
return window["__GLOBAL_SHARED__"]["__HMR_UPDATED_RUNTIME__"];
|
|
203
|
+
}
|
|
204
|
+
return Reflect.get(target, prop, receiver);
|
|
205
|
+
},
|
|
206
|
+
set(target, prop, value, receiver) {
|
|
207
|
+
if (prop === "__HMR_UPDATED_RUNTIME__") {
|
|
208
|
+
window["__GLOBAL_SHARED__"]["__HMR_UPDATED_RUNTIME__"] = value;
|
|
209
|
+
}
|
|
210
|
+
return Reflect.set(target, prop, value, receiver);
|
|
185
211
|
}
|
|
186
212
|
});
|
|
187
213
|
(function(window, self, globalThis, console, ${args.join(", ")}) {
|
|
188
214
|
${file.content}
|
|
189
|
-
})($$g$$, $$
|
|
215
|
+
})($$g$$, $$self$$, $$g$$, window["console"], ${argValues});
|
|
190
216
|
`
|
|
191
217
|
];
|
|
192
218
|
}
|
|
@@ -199,16 +225,7 @@ class JSDOMWebRunner extends node_1.NodeRunner {
|
|
|
199
225
|
if (file.path in this.requireCache) {
|
|
200
226
|
return this.requireCache[file.path].exports;
|
|
201
227
|
}
|
|
202
|
-
const [
|
|
203
|
-
if (code.includes("__STATS__")) {
|
|
204
|
-
scope.__STATS__ = this._options.stats?.();
|
|
205
|
-
}
|
|
206
|
-
if (code.includes("__STATS_I__")) {
|
|
207
|
-
const statsIndex = this._options.stats?.()?.__index__;
|
|
208
|
-
if (typeof statsIndex === "number") {
|
|
209
|
-
scope.__STATS_I__ = statsIndex;
|
|
210
|
-
}
|
|
211
|
-
}
|
|
228
|
+
const [m, code] = this.getModuleContent(file);
|
|
212
229
|
this.preExecute(code, file);
|
|
213
230
|
this.dom.window.eval(code);
|
|
214
231
|
this.postExecute(m, file);
|
package/dist/test/tester.js
CHANGED
|
@@ -73,7 +73,12 @@ class Tester {
|
|
|
73
73
|
await i.afterAll(this.context);
|
|
74
74
|
}
|
|
75
75
|
}
|
|
76
|
-
|
|
76
|
+
try {
|
|
77
|
+
await this.context.closeCompiler(this.config.name);
|
|
78
|
+
}
|
|
79
|
+
catch (e) {
|
|
80
|
+
console.warn(`Error occured while closing compilers of '${this.config.name}':\n${e.stack}`);
|
|
81
|
+
}
|
|
77
82
|
}
|
|
78
83
|
async runStepMethods(step, methods, force = false) {
|
|
79
84
|
for (const i of methods) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rspack-canary/test-tools",
|
|
3
|
-
"version": "1.6.0-canary-
|
|
3
|
+
"version": "1.6.0-canary-beafb11e-20251017173713",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"description": "Test tools for rspack",
|
|
6
6
|
"main": "dist/index.js",
|
|
@@ -72,7 +72,7 @@
|
|
|
72
72
|
"terser": "5.43.1",
|
|
73
73
|
"typescript": "^5.9.3",
|
|
74
74
|
"wast-loader": "^1.14.1",
|
|
75
|
-
"@rspack/core": "npm:@rspack-canary/core@1.6.0-canary-
|
|
75
|
+
"@rspack/core": "npm:@rspack-canary/core@1.6.0-canary-beafb11e-20251017173713"
|
|
76
76
|
},
|
|
77
77
|
"peerDependencies": {
|
|
78
78
|
"@rspack/core": ">=1.0.0"
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export default function update(done: any, options: any, callback: any): (err: any, stats: any) => any;
|
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.default = update;
|
|
4
|
-
// @ts-nocheck
|
|
5
|
-
function update(done, options, callback) {
|
|
6
|
-
return function (err, stats) {
|
|
7
|
-
if (err)
|
|
8
|
-
return done(err);
|
|
9
|
-
import.meta.webpackHot
|
|
10
|
-
.check(options || true)
|
|
11
|
-
.then(updatedModules => {
|
|
12
|
-
if (!updatedModules) {
|
|
13
|
-
return done(new Error("No update available"));
|
|
14
|
-
}
|
|
15
|
-
if (callback)
|
|
16
|
-
callback(stats);
|
|
17
|
-
})
|
|
18
|
-
.catch(err => {
|
|
19
|
-
done(err);
|
|
20
|
-
});
|
|
21
|
-
};
|
|
22
|
-
}
|
|
23
|
-
;
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
// @ts-nocheck
|
|
3
|
-
module.exports = function (done, options, callback) {
|
|
4
|
-
return function (err, stats) {
|
|
5
|
-
if (err)
|
|
6
|
-
return done(err);
|
|
7
|
-
module.hot
|
|
8
|
-
.check(options || true)
|
|
9
|
-
.then(updatedModules => {
|
|
10
|
-
if (!updatedModules)
|
|
11
|
-
return done(new Error("No update available"));
|
|
12
|
-
if (callback)
|
|
13
|
-
callback(stats);
|
|
14
|
-
})
|
|
15
|
-
.catch(err => {
|
|
16
|
-
done(err);
|
|
17
|
-
});
|
|
18
|
-
};
|
|
19
|
-
};
|