@rspack-debug/test-tools 1.4.11 → 1.6.4
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/README.md +1 -1
- package/dist/case/builtin.d.ts +3 -0
- package/dist/case/builtin.js +152 -14
- package/dist/case/cache.d.ts +2 -2
- package/dist/case/cache.js +214 -12
- package/dist/case/common.d.ts +11 -0
- package/dist/case/common.js +249 -0
- package/dist/case/compiler.d.ts +17 -4
- package/dist/case/compiler.js +149 -12
- package/dist/case/config.d.ts +7 -2
- package/dist/case/config.js +106 -18
- package/dist/case/defaults.d.ts +13 -4
- package/dist/case/defaults.js +73 -18
- package/dist/case/diagnostic.d.ts +6 -0
- package/dist/case/diagnostic.js +121 -14
- package/dist/case/error.d.ts +15 -4
- package/dist/case/error.js +137 -12
- package/dist/case/esm-output.d.ts +1 -0
- package/dist/case/esm-output.js +117 -0
- package/dist/case/example.d.ts +1 -0
- package/dist/case/example.js +57 -0
- package/dist/case/hash.d.ts +2 -2
- package/dist/case/hash.js +72 -9
- package/dist/case/hook.d.ts +36 -4
- package/dist/case/hook.js +209 -20
- package/dist/case/hot-step.d.ts +2 -2
- package/dist/case/hot-step.js +309 -13
- package/dist/case/hot.d.ts +11 -2
- package/dist/case/hot.js +217 -12
- package/dist/case/incremental.d.ts +2 -2
- package/dist/case/incremental.js +24 -45
- package/dist/case/index.d.ts +31 -20
- package/dist/case/index.js +50 -34
- package/dist/case/multi-compiler.d.ts +19 -0
- package/dist/case/multi-compiler.js +97 -0
- package/dist/case/{nativeWatcher.js → native-watcher.js} +11 -23
- package/dist/case/normal.d.ts +3 -0
- package/dist/case/normal.js +202 -18
- package/dist/case/runner.d.ts +19 -0
- package/dist/case/runner.js +113 -0
- package/dist/case/serial.d.ts +2 -2
- package/dist/case/serial.js +10 -14
- package/dist/case/stats-api.d.ts +8 -3
- package/dist/case/stats-api.js +69 -10
- package/dist/case/stats-output.d.ts +11 -0
- package/dist/case/stats-output.js +199 -8
- package/dist/case/treeshaking.js +34 -7
- package/dist/case/watch.d.ts +27 -0
- package/dist/case/watch.js +318 -22
- package/dist/compiler.d.ts +16 -16
- package/dist/compiler.js +120 -15
- package/dist/helper/directory.d.ts +1 -1
- package/dist/helper/directory.js +6 -2
- package/dist/helper/disable-iconv-lite-warning.d.ts +1 -0
- package/dist/helper/disable-iconv-lite-warning.js +12 -0
- package/dist/helper/expect/error.js +1 -1
- package/dist/helper/expect/placeholder.js +7 -7
- package/dist/helper/expect/to-match-file-snapshot.d.ts +1 -2
- package/dist/helper/expect/to-match-file-snapshot.js +3 -3
- package/dist/helper/hot-update/loader.d.ts +2 -1
- package/dist/helper/hot-update/loader.js +5 -30
- package/dist/helper/hot-update/plugin.d.ts +1 -1
- package/dist/helper/hot-update/plugin.js +14 -13
- package/dist/helper/index.d.ts +2 -1
- package/dist/helper/index.js +2 -1
- package/dist/helper/is.d.ts +2 -0
- package/dist/helper/is.js +15 -0
- package/dist/helper/legacy/LogTestPlugin.d.ts +6 -0
- package/dist/helper/legacy/LogTestPlugin.js +35 -0
- package/dist/helper/legacy/asModule.js +0 -2
- package/dist/helper/legacy/checkArrayExpectation.d.ts +1 -1
- package/dist/helper/legacy/checkArrayExpectation.js +8 -8
- package/dist/helper/legacy/createFakeWorker.d.ts +2 -2
- package/dist/helper/legacy/createFakeWorker.js +44 -20
- package/dist/helper/legacy/createLazyTestEnv.d.ts +3 -2
- package/dist/helper/legacy/createLazyTestEnv.js +3 -3
- package/dist/helper/legacy/deprecationTracking.d.ts +1 -0
- package/dist/helper/legacy/deprecationTracking.js +41 -0
- package/dist/helper/legacy/expectSource.d.ts +10 -0
- package/dist/helper/legacy/expectSource.js +23 -0
- package/dist/helper/legacy/findOutputFiles.d.ts +6 -0
- package/dist/helper/legacy/findOutputFiles.js +14 -0
- package/dist/helper/legacy/regexEscape.d.ts +2 -0
- package/dist/helper/legacy/regexEscape.js +5 -0
- package/dist/helper/legacy/supportDefaultAssignment.js +13 -0
- package/dist/helper/legacy/supportsTextDecoder.d.ts +2 -0
- package/dist/helper/legacy/supportsTextDecoder.js +9 -0
- package/dist/helper/legacy/supportsUsing.d.ts +2 -0
- package/dist/helper/legacy/supportsUsing.js +26 -0
- package/dist/helper/legacy/urlToRelativePath.js +5 -2
- package/dist/helper/read-config-file.d.ts +3 -2
- package/dist/helper/read-config-file.js +12 -2
- package/dist/helper/setup-env.js +26 -4
- package/dist/helper/setup-expect.js +2 -2
- package/dist/helper/setup-wasm.js +2 -2
- package/dist/helper/stringify-config.d.ts +2 -0
- package/dist/helper/stringify-config.js +43 -0
- package/dist/helper/util/checkStats.d.ts +0 -1
- package/dist/helper/util/checkStats.js +0 -18
- package/dist/helper/util/expectWarningFactory.js +2 -4
- package/dist/index.d.ts +0 -4
- package/dist/index.js +1 -4
- package/dist/plugin/index.d.ts +0 -3
- package/dist/plugin/index.js +0 -3
- package/dist/plugin/lazy-compilation-test-plugin.js +4 -4
- package/dist/runner/index.d.ts +2 -9
- package/dist/runner/index.js +2 -9
- package/dist/runner/node/index.d.ts +41 -0
- package/dist/runner/node/index.js +450 -0
- package/dist/runner/web/index.d.ts +30 -0
- package/dist/runner/web/index.js +343 -0
- package/dist/test/context.d.ts +15 -18
- package/dist/test/context.js +52 -57
- package/dist/test/creator.d.ts +20 -19
- package/dist/test/creator.js +69 -57
- package/dist/test/debug.d.ts +15 -0
- package/dist/test/debug.js +205 -0
- package/dist/test/tester.d.ts +1 -0
- package/dist/test/tester.js +44 -6
- package/dist/type.d.ts +94 -64
- package/dist/type.js +8 -12
- package/package.json +22 -61
- package/rstest.d.ts +24 -0
- package/dist/case/diff.d.ts +0 -3
- package/dist/case/diff.js +0 -126
- package/dist/compare/comparator.d.ts +0 -17
- package/dist/compare/comparator.js +0 -52
- package/dist/compare/compare.d.ts +0 -17
- package/dist/compare/compare.js +0 -175
- package/dist/compare/format-code.d.ts +0 -16
- package/dist/compare/format-code.js +0 -239
- package/dist/compare/index.d.ts +0 -5
- package/dist/compare/index.js +0 -21
- package/dist/compare/replace-module-argument.d.ts +0 -1
- package/dist/compare/replace-module-argument.js +0 -8
- package/dist/compare/replace-runtime-module-name.d.ts +0 -1
- package/dist/compare/replace-runtime-module-name.js +0 -71
- package/dist/helper/legacy/FakeDocument.d.ts +0 -54
- package/dist/helper/legacy/FakeDocument.js +0 -278
- package/dist/helper/legacy/createLogger.d.ts +0 -23
- package/dist/helper/legacy/createLogger.js +0 -20
- package/dist/helper/legacy/supportsImportFn.d.ts +0 -1
- package/dist/helper/legacy/supportsImportFn.js +0 -15
- package/dist/helper/legacy/supportsWorker.js +0 -17
- package/dist/helper/legacy/walkCssTokens.d.ts +0 -40
- package/dist/helper/legacy/walkCssTokens.js +0 -761
- package/dist/helper/legacy/warmup-webpack.d.ts +0 -1
- package/dist/helper/legacy/warmup-webpack.js +0 -26
- package/dist/helper/loaders/hot-update.d.ts +0 -1
- package/dist/helper/loaders/hot-update.js +0 -40
- package/dist/helper/plugins/hot-update.d.ts +0 -7
- package/dist/helper/plugins/hot-update.js +0 -40
- package/dist/helper/plugins/index.d.ts +0 -1
- package/dist/helper/plugins/index.js +0 -17
- package/dist/helper/util/currentWatchStep.d.ts +0 -1
- package/dist/helper/util/currentWatchStep.js +0 -2
- package/dist/helper/util/identifier.d.ts +0 -76
- package/dist/helper/util/identifier.js +0 -339
- package/dist/helper/util/replaceMitteDiagnostic.d.ts +0 -2
- package/dist/helper/util/replaceMitteDiagnostic.js +0 -17
- package/dist/plugin/rspack-diff-config-plugin.d.ts +0 -7
- package/dist/plugin/rspack-diff-config-plugin.js +0 -42
- package/dist/plugin/webpack-diff-config-plugin.d.ts +0 -7
- package/dist/plugin/webpack-diff-config-plugin.js +0 -41
- package/dist/plugin/webpack-module-placeholder-plugin.d.ts +0 -3
- package/dist/plugin/webpack-module-placeholder-plugin.js +0 -106
- package/dist/processor/basic.d.ts +0 -24
- package/dist/processor/basic.js +0 -146
- package/dist/processor/builtin.d.ts +0 -9
- package/dist/processor/builtin.js +0 -171
- package/dist/processor/cache.d.ts +0 -20
- package/dist/processor/cache.js +0 -128
- package/dist/processor/config.d.ts +0 -11
- package/dist/processor/config.js +0 -81
- package/dist/processor/defaults.d.ts +0 -30
- package/dist/processor/defaults.js +0 -72
- package/dist/processor/diagnostic.d.ts +0 -15
- package/dist/processor/diagnostic.js +0 -102
- package/dist/processor/diff.d.ts +0 -30
- package/dist/processor/diff.js +0 -140
- package/dist/processor/error.d.ts +0 -23
- package/dist/processor/error.js +0 -95
- package/dist/processor/hash.d.ts +0 -10
- package/dist/processor/hash.js +0 -63
- package/dist/processor/hook.d.ts +0 -44
- package/dist/processor/hook.js +0 -204
- package/dist/processor/hot-incremental.d.ts +0 -14
- package/dist/processor/hot-incremental.js +0 -43
- package/dist/processor/hot-step.d.ts +0 -18
- package/dist/processor/hot-step.js +0 -304
- package/dist/processor/hot.d.ts +0 -17
- package/dist/processor/hot.js +0 -140
- package/dist/processor/index.d.ts +0 -20
- package/dist/processor/index.js +0 -36
- package/dist/processor/multi.d.ts +0 -17
- package/dist/processor/multi.js +0 -73
- package/dist/processor/normal.d.ts +0 -12
- package/dist/processor/normal.js +0 -150
- package/dist/processor/simple.d.ts +0 -23
- package/dist/processor/simple.js +0 -49
- package/dist/processor/snapshot.d.ts +0 -12
- package/dist/processor/snapshot.js +0 -66
- package/dist/processor/stats-api.d.ts +0 -18
- package/dist/processor/stats-api.js +0 -48
- package/dist/processor/stats.d.ts +0 -18
- package/dist/processor/stats.js +0 -206
- package/dist/processor/treeshaking.d.ts +0 -10
- package/dist/processor/treeshaking.js +0 -33
- package/dist/processor/watch.d.ts +0 -30
- package/dist/processor/watch.js +0 -241
- package/dist/reporter/diff-html.d.ts +0 -15
- package/dist/reporter/diff-html.js +0 -69
- package/dist/reporter/diff-stats.d.ts +0 -24
- package/dist/reporter/diff-stats.js +0 -131
- package/dist/reporter/index.d.ts +0 -2
- package/dist/reporter/index.js +0 -18
- package/dist/runner/basic.d.ts +0 -10
- package/dist/runner/basic.js +0 -63
- package/dist/runner/cache.d.ts +0 -5
- package/dist/runner/cache.js +0 -90
- package/dist/runner/hot-step.d.ts +0 -5
- package/dist/runner/hot-step.js +0 -87
- package/dist/runner/hot.d.ts +0 -5
- package/dist/runner/hot.js +0 -83
- package/dist/runner/multiple.d.ts +0 -11
- package/dist/runner/multiple.js +0 -38
- package/dist/runner/normal.d.ts +0 -5
- package/dist/runner/normal.js +0 -20
- package/dist/runner/runner/basic.d.ts +0 -30
- package/dist/runner/runner/basic.js +0 -107
- package/dist/runner/runner/cjs.d.ts +0 -14
- package/dist/runner/runner/cjs.js +0 -151
- package/dist/runner/runner/esm.d.ts +0 -7
- package/dist/runner/runner/esm.js +0 -125
- package/dist/runner/runner/index.d.ts +0 -8
- package/dist/runner/runner/index.js +0 -24
- package/dist/runner/runner/normal.d.ts +0 -9
- package/dist/runner/runner/normal.js +0 -23
- package/dist/runner/runner/watch.d.ts +0 -16
- package/dist/runner/runner/watch.js +0 -27
- package/dist/runner/runner/web/fake.d.ts +0 -18
- package/dist/runner/runner/web/fake.js +0 -143
- package/dist/runner/runner/web/jsdom.d.ts +0 -26
- package/dist/runner/runner/web/jsdom.js +0 -219
- package/dist/runner/runner/web.d.ts +0 -15
- package/dist/runner/runner/web.js +0 -32
- package/dist/runner/type.d.ts +0 -42
- package/dist/runner/type.js +0 -9
- package/dist/runner/watch.d.ts +0 -7
- package/dist/runner/watch.js +0 -60
- package/dist/test/simple.d.ts +0 -5
- package/dist/test/simple.js +0 -43
- package/jest.d.ts +0 -25
- package/template/diff.bundle.css +0 -1
- package/template/diff.bundle.js +0 -144
- package/template/diff.html +0 -14
- package/template/editor.worker.js +0 -1
- /package/dist/case/{nativeWatcher.d.ts → native-watcher.d.ts} +0 -0
- /package/dist/helper/legacy/{supportsWorker.d.ts → supportDefaultAssignment.d.ts} +0 -0
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
// @ts-nocheck
|
|
2
|
+
"use strict";
|
|
3
|
+
module.exports = function supportsUsing() {
|
|
4
|
+
try {
|
|
5
|
+
const f = eval(`(function f() {
|
|
6
|
+
let disposed = false;
|
|
7
|
+
|
|
8
|
+
{
|
|
9
|
+
const getResource = () => {
|
|
10
|
+
return {
|
|
11
|
+
[Symbol.dispose]: () => {
|
|
12
|
+
disposed = true;
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
using resource = getResource();
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
return disposed;
|
|
20
|
+
})`);
|
|
21
|
+
return f() === true;
|
|
22
|
+
}
|
|
23
|
+
catch (_err) {
|
|
24
|
+
return false;
|
|
25
|
+
}
|
|
26
|
+
};
|
|
@@ -1,7 +1,10 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
// @ts-nocheck
|
|
3
|
+
const URL = require("url").URL;
|
|
3
4
|
module.exports = function urlToRelativePath(url) {
|
|
4
|
-
if (url.startsWith("https://
|
|
5
|
-
|
|
5
|
+
if (url.startsWith("https://") || url.startsWith("file://")) {
|
|
6
|
+
const urlObj = new URL(url);
|
|
7
|
+
return `./${urlObj.pathname.split("/").pop()}`;
|
|
8
|
+
}
|
|
6
9
|
return `./${url}`;
|
|
7
10
|
};
|
|
@@ -1,2 +1,3 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
|
|
1
|
+
import type { RspackOptions } from "@rspack/core";
|
|
2
|
+
import type { ITestContext } from "../type";
|
|
3
|
+
export declare function readConfigFile(files: string[], context: ITestContext, prevOption?: RspackOptions, functionApply?: (config: (RspackOptions | ((...args: unknown[]) => RspackOptions))[]) => RspackOptions[]): RspackOptions[];
|
|
@@ -5,9 +5,19 @@ 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
|
-
|
|
8
|
+
const debug_1 = require("../test/debug");
|
|
9
|
+
function readConfigFile(files, context, prevOption, functionApply) {
|
|
9
10
|
const existsFile = files.find(i => fs_extra_1.default.existsSync(i));
|
|
10
|
-
|
|
11
|
+
let fileConfig = existsFile ? require(existsFile) : {};
|
|
12
|
+
if (typeof fileConfig === "function") {
|
|
13
|
+
fileConfig = fileConfig({ config: prevOption }, { testPath: context.getDist(), tempPath: context.getTemp() });
|
|
14
|
+
}
|
|
11
15
|
const configArr = Array.isArray(fileConfig) ? fileConfig : [fileConfig];
|
|
16
|
+
if (existsFile) {
|
|
17
|
+
context.setValue(debug_1.DEBUG_SCOPES.CompilerOptionsReadConfigFile, {
|
|
18
|
+
file: existsFile,
|
|
19
|
+
config: fileConfig
|
|
20
|
+
});
|
|
21
|
+
}
|
|
12
22
|
return functionApply ? functionApply(configArr) : configArr;
|
|
13
23
|
}
|
package/dist/helper/setup-env.js
CHANGED
|
@@ -6,6 +6,18 @@ const path = require("node:path");
|
|
|
6
6
|
if (process.env.RSPACK_BINDING_BUILDER_TESTING) {
|
|
7
7
|
process.env.RSPACK_BINDING = path.resolve(__dirname, "../../node_modules/@rspack/binding-testing");
|
|
8
8
|
}
|
|
9
|
+
if (process.env.RSTEST) {
|
|
10
|
+
global.printLogger ??= process.env.printLogger === "true";
|
|
11
|
+
global.__TEST_FIXTURES_PATH__ ??= process.env.__TEST_FIXTURES_PATH__;
|
|
12
|
+
global.updateSnapshot ??= process.env.updateSnapshot === "true";
|
|
13
|
+
global.testFilter ??= process.env.testFilter;
|
|
14
|
+
global.__TEST_PATH__ ??= process.env.__TEST_PATH__;
|
|
15
|
+
global.__TEST_DIST_PATH__ ??= process.env.__TEST_DIST_PATH__;
|
|
16
|
+
global.__ROOT_PATH__ ??= process.env.__ROOT_PATH__;
|
|
17
|
+
global.__RSPACK_PATH__ ??= process.env.__RSPACK_PATH__;
|
|
18
|
+
global.__RSPACK_TEST_TOOLS_PATH__ ??= process.env.__RSPACK_TEST_TOOLS_PATH__;
|
|
19
|
+
global.__DEBUG__ ??= process.env.DEBUG === "test";
|
|
20
|
+
}
|
|
9
21
|
if (process.env.ALTERNATIVE_SORT) {
|
|
10
22
|
const oldSort = Array.prototype.sort;
|
|
11
23
|
Array.prototype.sort = function (cmp) {
|
|
@@ -58,7 +70,8 @@ if (process.env.DEBUG_INFO) {
|
|
|
58
70
|
}, timeout);
|
|
59
71
|
}
|
|
60
72
|
else {
|
|
61
|
-
it(name,
|
|
73
|
+
it(name, () => new Promise((resolve, reject) => {
|
|
74
|
+
const done = err => (err ? reject(err) : resolve());
|
|
62
75
|
process.stdout.write(`START2 ${name}\n`);
|
|
63
76
|
return fn(err => {
|
|
64
77
|
if (err) {
|
|
@@ -69,17 +82,26 @@ if (process.env.DEBUG_INFO) {
|
|
|
69
82
|
}
|
|
70
83
|
return done(err);
|
|
71
84
|
});
|
|
72
|
-
}, timeout);
|
|
85
|
+
}), timeout);
|
|
73
86
|
}
|
|
74
87
|
};
|
|
75
88
|
};
|
|
76
89
|
// eslint-disable-next-line no-global-assign
|
|
77
90
|
it = addDebugInfo(it);
|
|
78
91
|
}
|
|
92
|
+
const uncaughtExceptionListenersLength = process.listeners("uncaughtException").length;
|
|
93
|
+
const unhandledRejectionListenersLength = process.listeners("unhandledRejection").length;
|
|
79
94
|
// cspell:word wabt
|
|
80
95
|
// Workaround for a memory leak in wabt
|
|
81
96
|
// It leaks an Error object on construction
|
|
82
97
|
// so it leaks the whole stack trace
|
|
83
98
|
require("wast-loader");
|
|
84
|
-
|
|
85
|
-
process.
|
|
99
|
+
// remove the last uncaughtException / unhandledRejection listener added by wast-loader
|
|
100
|
+
const listeners = process.listeners("uncaughtException");
|
|
101
|
+
if (listeners.length > uncaughtExceptionListenersLength) {
|
|
102
|
+
process.off("uncaughtException", listeners[listeners.length - 1]);
|
|
103
|
+
}
|
|
104
|
+
const listeners1 = process.listeners("unhandledRejection");
|
|
105
|
+
if (listeners1.length > unhandledRejectionListenersLength) {
|
|
106
|
+
process.off("unhandledRejection", listeners1[listeners1.length - 1]);
|
|
107
|
+
}
|
|
@@ -6,8 +6,8 @@ const to_match_file_snapshot_1 = require("./expect/to-match-file-snapshot");
|
|
|
6
6
|
const serializers_1 = require("./serializers");
|
|
7
7
|
expect.extend({
|
|
8
8
|
// CHANGE: new test matcher for `rspack-test-tools`
|
|
9
|
-
// @ts-
|
|
10
|
-
|
|
9
|
+
// @ts-expect-error
|
|
10
|
+
toMatchFileSnapshotSync: to_match_file_snapshot_1.toMatchFileSnapshotSync,
|
|
11
11
|
toBeTypeOf: to_be_typeof_1.toBeTypeOf,
|
|
12
12
|
toEndWith: to_end_with_1.toEndWith
|
|
13
13
|
});
|
|
@@ -9,11 +9,11 @@ function toMatchSnapshot() {
|
|
|
9
9
|
function toMatchInlineSnapshot() {
|
|
10
10
|
return { pass: true, message: () => "" };
|
|
11
11
|
}
|
|
12
|
-
function
|
|
12
|
+
function toMatchFileSnapshotSync() {
|
|
13
13
|
return { pass: true, message: () => "" };
|
|
14
14
|
}
|
|
15
15
|
expect.extend({
|
|
16
16
|
toMatchSnapshot,
|
|
17
17
|
toMatchInlineSnapshot,
|
|
18
|
-
|
|
18
|
+
toMatchFileSnapshotSync
|
|
19
19
|
});
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.default = stringifyConfig;
|
|
4
|
+
const javascript_stringify_1 = require("javascript-stringify");
|
|
5
|
+
function stringifyConfig(config, verbose = false) {
|
|
6
|
+
return (0, javascript_stringify_1.stringify)(config, (value, indent, stringify) => {
|
|
7
|
+
// improve plugin output
|
|
8
|
+
if (value?.__pluginName) {
|
|
9
|
+
const prefix = `/* config.${value.__pluginType}('${value.__pluginName}') */\n`;
|
|
10
|
+
const constructorExpression = value.__pluginPath
|
|
11
|
+
? // The path is stringified to ensure special characters are escaped
|
|
12
|
+
// (such as the backslashes in Windows-style paths).
|
|
13
|
+
`(require(${stringify(value.__pluginPath)}))`
|
|
14
|
+
: value.__pluginConstructorName;
|
|
15
|
+
if (constructorExpression) {
|
|
16
|
+
// get correct indentation for args by stringifying the args array and
|
|
17
|
+
// discarding the square brackets.
|
|
18
|
+
const args = stringify(value.__pluginArgs)?.slice(1, -1);
|
|
19
|
+
return `${prefix}new ${constructorExpression}(${args})`;
|
|
20
|
+
}
|
|
21
|
+
return (prefix +
|
|
22
|
+
stringify(value.__pluginArgs?.length ? { args: value.__pluginArgs } : {}));
|
|
23
|
+
}
|
|
24
|
+
// improve rule/use output
|
|
25
|
+
if (value?.__ruleNames) {
|
|
26
|
+
const ruleTypes = value.__ruleTypes;
|
|
27
|
+
const prefix = `/* config.module${value.__ruleNames
|
|
28
|
+
.map((r, index) => `.${ruleTypes ? ruleTypes[index] : "rule"}('${r}')`)
|
|
29
|
+
.join("")}${value.__useName ? `.use('${value.__useName}')` : ``} */\n`;
|
|
30
|
+
return prefix + stringify(value);
|
|
31
|
+
}
|
|
32
|
+
if (value?.__expression) {
|
|
33
|
+
return value.__expression;
|
|
34
|
+
}
|
|
35
|
+
// shorten long functions
|
|
36
|
+
if (typeof value === "function") {
|
|
37
|
+
if (!verbose && value.toString().length > 100) {
|
|
38
|
+
return `function () { /* omitted long function */ }`;
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
return stringify(value);
|
|
42
|
+
}, 2);
|
|
43
|
+
}
|
|
@@ -16,24 +16,6 @@ exports.checkChunkModules = function checkChunkModules(statsJson, chunkModulesMa
|
|
|
16
16
|
}
|
|
17
17
|
return true;
|
|
18
18
|
};
|
|
19
|
-
exports.checkChunkRuntime = function checkChunkModules(statsJson, chunkModulesMap, strict = true) {
|
|
20
|
-
for (const chunkId of Reflect.ownKeys(chunkModulesMap)) {
|
|
21
|
-
const chunk = getChunk(statsJson, chunkId);
|
|
22
|
-
const expectedRuntime = chunkModulesMap[chunkId];
|
|
23
|
-
const chunkRuntime = chunk.runtime;
|
|
24
|
-
if (strict) {
|
|
25
|
-
expectedRuntime.length === chunkRuntime.length;
|
|
26
|
-
}
|
|
27
|
-
for (let i = 0; i < expectedRuntime.length; i++) {
|
|
28
|
-
const expected = expectedRuntime[i];
|
|
29
|
-
const rt = chunkRuntime[i];
|
|
30
|
-
if (expected !== rt) {
|
|
31
|
-
throw new Error(`chunk ${chunkId} runtime not equal, expected: ${expectedRuntime}, but got: ${chunkRuntime}`);
|
|
32
|
-
}
|
|
33
|
-
}
|
|
34
|
-
}
|
|
35
|
-
return true;
|
|
36
|
-
};
|
|
37
19
|
function getChunk(statsJson, id) {
|
|
38
20
|
const chunk = statsJson.chunks.find(chunk => chunk.id.includes(id));
|
|
39
21
|
if (!chunk) {
|
|
@@ -3,15 +3,13 @@
|
|
|
3
3
|
module.exports = () => {
|
|
4
4
|
const warnings = [];
|
|
5
5
|
let oldWarn;
|
|
6
|
-
beforeEach(
|
|
6
|
+
beforeEach(() => {
|
|
7
7
|
oldWarn = console.warn;
|
|
8
8
|
console.warn = m => warnings.push(m);
|
|
9
|
-
done();
|
|
10
9
|
});
|
|
11
|
-
afterEach(
|
|
10
|
+
afterEach(() => {
|
|
12
11
|
expectWarning();
|
|
13
12
|
console.warn = oldWarn;
|
|
14
|
-
done();
|
|
15
13
|
});
|
|
16
14
|
const expectWarning = (...regexp) => {
|
|
17
15
|
expect(warnings).toEqual(regexp.map(r => expect.stringMatching(r)));
|
package/dist/index.d.ts
CHANGED
|
@@ -1,12 +1,8 @@
|
|
|
1
1
|
export * from "./case";
|
|
2
|
-
export * from "./compare";
|
|
3
2
|
export * from "./helper";
|
|
4
3
|
export * from "./plugin";
|
|
5
|
-
export * from "./processor";
|
|
6
|
-
export * from "./reporter";
|
|
7
4
|
export * from "./runner";
|
|
8
5
|
export * from "./test/context";
|
|
9
6
|
export * from "./test/creator";
|
|
10
|
-
export * from "./test/simple";
|
|
11
7
|
export * from "./test/tester";
|
|
12
8
|
export * from "./type";
|
package/dist/index.js
CHANGED
|
@@ -15,14 +15,11 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
15
15
|
};
|
|
16
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
17
|
__exportStar(require("./case"), exports);
|
|
18
|
-
__exportStar(require("./compare"), exports);
|
|
19
18
|
__exportStar(require("./helper"), exports);
|
|
20
19
|
__exportStar(require("./plugin"), exports);
|
|
21
|
-
__exportStar(require("./processor"), exports);
|
|
22
|
-
__exportStar(require("./reporter"), exports);
|
|
23
20
|
__exportStar(require("./runner"), exports);
|
|
24
21
|
__exportStar(require("./test/context"), exports);
|
|
25
22
|
__exportStar(require("./test/creator"), exports);
|
|
26
|
-
__exportStar(require("./test/simple"), exports);
|
|
27
23
|
__exportStar(require("./test/tester"), exports);
|
|
28
24
|
__exportStar(require("./type"), exports);
|
|
25
|
+
require("./helper/disable-iconv-lite-warning").disableIconvLiteWarning();
|
package/dist/plugin/index.d.ts
CHANGED
package/dist/plugin/index.js
CHANGED
|
@@ -15,6 +15,3 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
15
15
|
};
|
|
16
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
17
|
__exportStar(require("./lazy-compilation-test-plugin"), exports);
|
|
18
|
-
__exportStar(require("./rspack-diff-config-plugin"), exports);
|
|
19
|
-
__exportStar(require("./webpack-diff-config-plugin"), exports);
|
|
20
|
-
__exportStar(require("./webpack-module-placeholder-plugin"), exports);
|
|
@@ -21,13 +21,13 @@ class LazyCompilationTestPlugin {
|
|
|
21
21
|
: `${protocol}://${addr.address}:${addr.port}`;
|
|
22
22
|
if (compiler instanceof core_1.MultiCompiler) {
|
|
23
23
|
for (const c of compiler.compilers) {
|
|
24
|
-
if (c.options.
|
|
25
|
-
c.options.
|
|
24
|
+
if (c.options.lazyCompilation) {
|
|
25
|
+
c.options.lazyCompilation.serverUrl = urlBase;
|
|
26
26
|
}
|
|
27
27
|
}
|
|
28
28
|
}
|
|
29
|
-
else if (compiler.options.
|
|
30
|
-
compiler.options.
|
|
29
|
+
else if (compiler.options.lazyCompilation) {
|
|
30
|
+
compiler.options.lazyCompilation.serverUrl = urlBase;
|
|
31
31
|
}
|
|
32
32
|
middleware = core_1.experiments.lazyCompilationMiddleware(compiler);
|
|
33
33
|
resolve(null);
|
package/dist/runner/index.d.ts
CHANGED
|
@@ -1,9 +1,2 @@
|
|
|
1
|
-
export * from "./
|
|
2
|
-
export * from "./
|
|
3
|
-
export * from "./hot";
|
|
4
|
-
export * from "./hot-step";
|
|
5
|
-
export * from "./multiple";
|
|
6
|
-
export * from "./normal";
|
|
7
|
-
export * from "./runner";
|
|
8
|
-
export * from "./type";
|
|
9
|
-
export * from "./watch";
|
|
1
|
+
export * from "./node";
|
|
2
|
+
export * from "./web";
|
package/dist/runner/index.js
CHANGED
|
@@ -14,12 +14,5 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
14
14
|
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
15
|
};
|
|
16
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
-
__exportStar(require("./
|
|
18
|
-
__exportStar(require("./
|
|
19
|
-
__exportStar(require("./hot"), exports);
|
|
20
|
-
__exportStar(require("./hot-step"), exports);
|
|
21
|
-
__exportStar(require("./multiple"), exports);
|
|
22
|
-
__exportStar(require("./normal"), exports);
|
|
23
|
-
__exportStar(require("./runner"), exports);
|
|
24
|
-
__exportStar(require("./type"), exports);
|
|
25
|
-
__exportStar(require("./watch"), exports);
|
|
17
|
+
__exportStar(require("./node"), exports);
|
|
18
|
+
__exportStar(require("./web"), exports);
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import type { RspackOptions, StatsCompilation } from "@rspack/core";
|
|
2
|
+
import { type IGlobalContext, type IModuleScope, type ITestEnv, type ITestRunner, type TModuleObject, type TRunnerFile, type TRunnerRequirer, type TTestConfig } from "../../type";
|
|
3
|
+
declare global {
|
|
4
|
+
var printLogger: boolean;
|
|
5
|
+
}
|
|
6
|
+
export interface INodeRunnerOptions {
|
|
7
|
+
env: ITestEnv;
|
|
8
|
+
stats?: () => StatsCompilation;
|
|
9
|
+
name: string;
|
|
10
|
+
runInNewContext?: boolean;
|
|
11
|
+
testConfig: TTestConfig;
|
|
12
|
+
source: string;
|
|
13
|
+
dist: string;
|
|
14
|
+
compilerOptions: RspackOptions;
|
|
15
|
+
cachable?: boolean;
|
|
16
|
+
logs?: string[];
|
|
17
|
+
errors?: Error[];
|
|
18
|
+
}
|
|
19
|
+
export declare class NodeRunner implements ITestRunner {
|
|
20
|
+
protected _options: INodeRunnerOptions;
|
|
21
|
+
protected requireCache: any;
|
|
22
|
+
protected globalContext: IGlobalContext | null;
|
|
23
|
+
protected baseModuleScope: IModuleScope | null;
|
|
24
|
+
protected requirers: Map<string, TRunnerRequirer>;
|
|
25
|
+
constructor(_options: INodeRunnerOptions);
|
|
26
|
+
protected log(message: string): void;
|
|
27
|
+
run(file: string): Promise<unknown>;
|
|
28
|
+
getRequire(): TRunnerRequirer;
|
|
29
|
+
getGlobal(name: string): unknown;
|
|
30
|
+
protected createGlobalContext(): IGlobalContext;
|
|
31
|
+
protected createBaseModuleScope(): IModuleScope;
|
|
32
|
+
protected createModuleScope(requireFn: TRunnerRequirer, m: TModuleObject, file: TRunnerFile): IModuleScope;
|
|
33
|
+
protected getFile(modulePath: string[] | string, currentDirectory: string): TRunnerFile | null;
|
|
34
|
+
protected preExecute(code: string, file: TRunnerFile): void;
|
|
35
|
+
protected postExecute(m: Object, file: TRunnerFile): void;
|
|
36
|
+
protected createRunner(): void;
|
|
37
|
+
protected createMissRequirer(): TRunnerRequirer;
|
|
38
|
+
protected createJsonRequirer(): TRunnerRequirer;
|
|
39
|
+
protected createCjsRequirer(): TRunnerRequirer;
|
|
40
|
+
protected createEsmRequirer(): TRunnerRequirer;
|
|
41
|
+
}
|