@rspack/test-tools 1.7.0-beta.0 → 1.7.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.d.ts +2 -2
- package/dist/case/builtin.js +58 -58
- package/dist/case/cache.d.ts +2 -2
- package/dist/case/cache.js +34 -34
- package/dist/case/common.d.ts +2 -2
- package/dist/case/common.js +45 -45
- package/dist/case/compiler.d.ts +3 -3
- package/dist/case/compiler.js +21 -21
- package/dist/case/config.d.ts +3 -3
- package/dist/case/config.js +19 -19
- package/dist/case/defaults.d.ts +2 -2
- package/dist/case/defaults.js +10 -10
- package/dist/case/diagnostic.js +29 -29
- package/dist/case/error.d.ts +2 -2
- package/dist/case/error.js +21 -21
- package/dist/case/esm-output.js +30 -26
- package/dist/case/example.js +7 -7
- package/dist/case/hash.d.ts +2 -2
- package/dist/case/hash.js +16 -16
- package/dist/case/hook.d.ts +3 -3
- package/dist/case/hook.js +42 -42
- package/dist/case/hot-step.d.ts +2 -2
- package/dist/case/hot-step.js +46 -46
- package/dist/case/hot.d.ts +5 -5
- package/dist/case/hot.js +43 -43
- package/dist/case/incremental.d.ts +2 -2
- package/dist/case/incremental.js +9 -9
- package/dist/case/index.d.ts +31 -31
- package/dist/case/multi-compiler.d.ts +3 -3
- package/dist/case/multi-compiler.js +15 -15
- package/dist/case/native-watcher.js +6 -6
- package/dist/case/normal.js +46 -46
- package/dist/case/runner.d.ts +2 -2
- package/dist/case/runner.js +22 -15
- package/dist/case/serial.d.ts +2 -2
- package/dist/case/serial.js +4 -4
- package/dist/case/stats-api.d.ts +2 -2
- package/dist/case/stats-api.js +7 -7
- package/dist/case/stats-output.d.ts +2 -2
- package/dist/case/stats-output.js +45 -45
- package/dist/case/treeshaking.js +6 -6
- package/dist/case/watch.d.ts +1 -1
- package/dist/case/watch.js +59 -59
- package/dist/compiler.d.ts +3 -3
- package/dist/compiler.js +31 -31
- package/dist/helper/directory.d.ts +1 -1
- package/dist/helper/directory.js +15 -15
- package/dist/helper/disable-iconv-lite-warning.js +3 -3
- package/dist/helper/expect/diff.js +8 -8
- package/dist/helper/expect/error.js +9 -9
- package/dist/helper/expect/placeholder.js +9 -9
- package/dist/helper/expect/rspack.js +5 -5
- package/dist/helper/expect/to-be-typeof.js +2 -2
- package/dist/helper/expect/to-end-with.js +3 -3
- package/dist/helper/expect/to-match-file-snapshot.d.ts +1 -1
- package/dist/helper/expect/to-match-file-snapshot.js +23 -23
- package/dist/helper/hot-update/index.d.ts +1 -1
- package/dist/helper/hot-update/loader.js +1 -1
- package/dist/helper/hot-update/plugin.d.ts +1 -1
- package/dist/helper/hot-update/plugin.js +15 -15
- package/dist/helper/index.d.ts +8 -8
- package/dist/helper/is.js +2 -2
- package/dist/helper/legacy/EventSourceForNode.js +8 -8
- package/dist/helper/legacy/LogTestPlugin.js +18 -18
- package/dist/helper/legacy/asModule.js +6 -6
- package/dist/helper/legacy/captureStdio.js +6 -6
- package/dist/helper/legacy/checkArrayExpectation.js +26 -23
- package/dist/helper/legacy/copyDiff.js +5 -5
- package/dist/helper/legacy/createFakeWorker.js +13 -13
- package/dist/helper/legacy/createLazyTestEnv.js +11 -11
- package/dist/helper/legacy/currentScript.js +1 -1
- package/dist/helper/legacy/deprecationTracking.js +13 -19
- package/dist/helper/legacy/expectSource.js +5 -5
- package/dist/helper/legacy/fakeSystem.js +14 -14
- package/dist/helper/legacy/findOutputFiles.js +4 -4
- package/dist/helper/legacy/parseResource.js +4 -4
- package/dist/helper/legacy/regexEscape.js +2 -2
- package/dist/helper/legacy/supportDefaultAssignment.js +2 -2
- package/dist/helper/legacy/supportsTextDecoder.js +2 -2
- package/dist/helper/legacy/supportsUsing.js +1 -1
- package/dist/helper/legacy/urlToRelativePath.js +3 -3
- package/dist/helper/parse-modules.js +13 -13
- package/dist/helper/read-config-file.d.ts +2 -2
- package/dist/helper/read-config-file.js +3 -3
- package/dist/helper/serializers.d.ts +1 -1
- package/dist/helper/serializers.js +11 -11
- package/dist/helper/setup-env.js +17 -17
- package/dist/helper/setup-expect.js +1 -1
- package/dist/helper/setup-wasm.js +4 -4
- package/dist/helper/stringify-config.d.ts +1 -1
- package/dist/helper/stringify-config.js +3 -3
- package/dist/helper/update-snapshot.js +1 -1
- package/dist/helper/util/checkSourceMap.js +16 -17
- package/dist/helper/util/checkStats.js +3 -3
- package/dist/helper/util/expectWarningFactory.js +2 -2
- package/dist/helper/util/filterUtil.js +9 -9
- package/dist/index.d.ts +8 -8
- package/dist/index.js +1 -1
- package/dist/plugin/index.d.ts +1 -1
- package/dist/plugin/lazy-compilation-test-plugin.d.ts +1 -1
- package/dist/plugin/lazy-compilation-test-plugin.js +13 -13
- package/dist/runner/index.d.ts +2 -2
- package/dist/runner/node/index.d.ts +2 -2
- package/dist/runner/node/index.js +75 -74
- package/dist/runner/web/index.d.ts +2 -2
- package/dist/runner/web/index.js +45 -45
- package/dist/test/context.d.ts +2 -2
- package/dist/test/context.js +4 -4
- package/dist/test/creator.d.ts +1 -1
- package/dist/test/creator.js +28 -28
- package/dist/test/debug.d.ts +1 -1
- package/dist/test/debug.js +31 -31
- package/dist/test/tester.d.ts +1 -1
- package/dist/test/tester.js +11 -11
- package/dist/type.d.ts +3 -3
- package/package.json +7 -7
- package/rstest.d.ts +12 -12
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import type { Compilation, Compiler, RspackOptions, Stats, StatsCompilation } from
|
|
2
|
-
import type { ITestContext } from
|
|
1
|
+
import type { Compilation, Compiler, RspackOptions, Stats, StatsCompilation } from '@rspack/core';
|
|
2
|
+
import type { ITestContext } from '../type';
|
|
3
3
|
export declare function createMultiCompilerCase(name: string, src: string, dist: string, testConfig: string): void;
|
|
4
4
|
export type TMultiCompilerCaseConfig = {
|
|
5
5
|
description: string;
|
|
@@ -8,7 +8,7 @@ export type TMultiCompilerCaseConfig = {
|
|
|
8
8
|
options?: (context: ITestContext) => RspackOptions;
|
|
9
9
|
compiler?: (context: ITestContext, compiler: Compiler) => Promise<void>;
|
|
10
10
|
build?: (context: ITestContext, compiler: Compiler) => Promise<void>;
|
|
11
|
-
check?: ({ context, stats, files, compiler, compilation }: {
|
|
11
|
+
check?: ({ context, stats, files, compiler, compilation, }: {
|
|
12
12
|
context: ITestContext;
|
|
13
13
|
stats?: StatsCompilation;
|
|
14
14
|
files?: Record<string, string>;
|
|
@@ -13,15 +13,15 @@ function createMultiCompilerProcessor(name, caseConfig) {
|
|
|
13
13
|
const compiler = context.getCompiler();
|
|
14
14
|
const options = Object.assign([
|
|
15
15
|
{
|
|
16
|
-
name:
|
|
17
|
-
context: node_path_1.default.join(__dirname,
|
|
18
|
-
entry:
|
|
16
|
+
name: 'a',
|
|
17
|
+
context: node_path_1.default.join(__dirname, 'fixtures'),
|
|
18
|
+
entry: './a.js',
|
|
19
19
|
},
|
|
20
20
|
{
|
|
21
|
-
name:
|
|
22
|
-
context: node_path_1.default.join(__dirname,
|
|
23
|
-
entry:
|
|
24
|
-
}
|
|
21
|
+
name: 'b',
|
|
22
|
+
context: node_path_1.default.join(__dirname, 'fixtures'),
|
|
23
|
+
entry: './b.js',
|
|
24
|
+
},
|
|
25
25
|
], caseConfig.options?.(context) || {});
|
|
26
26
|
compiler.setOptions(options);
|
|
27
27
|
},
|
|
@@ -47,17 +47,17 @@ function createMultiCompilerProcessor(name, caseConfig) {
|
|
|
47
47
|
changes: new Set(),
|
|
48
48
|
removals: new Set(),
|
|
49
49
|
fileTimeInfoEntries: new Map(),
|
|
50
|
-
directoryTimeInfoEntries: new Map()
|
|
50
|
+
directoryTimeInfoEntries: new Map(),
|
|
51
51
|
};
|
|
52
|
-
}
|
|
52
|
+
},
|
|
53
53
|
};
|
|
54
|
-
}
|
|
54
|
+
},
|
|
55
55
|
};
|
|
56
56
|
await caseConfig.compiler?.(context, c);
|
|
57
57
|
},
|
|
58
58
|
build: async (context) => {
|
|
59
59
|
const compiler = context.getCompiler();
|
|
60
|
-
if (typeof caseConfig.build ===
|
|
60
|
+
if (typeof caseConfig.build === 'function') {
|
|
61
61
|
await caseConfig.build?.(context, compiler.getCompiler());
|
|
62
62
|
}
|
|
63
63
|
else {
|
|
@@ -65,7 +65,7 @@ function createMultiCompilerProcessor(name, caseConfig) {
|
|
|
65
65
|
}
|
|
66
66
|
},
|
|
67
67
|
run: async (env, context) => { },
|
|
68
|
-
check: async (env, context) => { }
|
|
68
|
+
check: async (env, context) => { },
|
|
69
69
|
};
|
|
70
70
|
}
|
|
71
71
|
const creator = new creator_1.BasicCaseCreator({
|
|
@@ -73,10 +73,10 @@ const creator = new creator_1.BasicCaseCreator({
|
|
|
73
73
|
describe: false,
|
|
74
74
|
steps: ({ name, caseConfig }) => {
|
|
75
75
|
return [
|
|
76
|
-
createMultiCompilerProcessor(name, caseConfig)
|
|
76
|
+
createMultiCompilerProcessor(name, caseConfig),
|
|
77
77
|
];
|
|
78
78
|
},
|
|
79
|
-
concurrent: false
|
|
79
|
+
concurrent: false,
|
|
80
80
|
});
|
|
81
81
|
function createMultiCompilerCase(name, src, dist, testConfig) {
|
|
82
82
|
let caseConfigList = require(testConfig);
|
|
@@ -91,7 +91,7 @@ function createMultiCompilerCase(name, src, dist, testConfig) {
|
|
|
91
91
|
}
|
|
92
92
|
creator.create(`${name}[${i}]`, src, dist, undefined, {
|
|
93
93
|
caseConfig,
|
|
94
|
-
description: () => caseConfig.description
|
|
94
|
+
description: () => caseConfig.description,
|
|
95
95
|
});
|
|
96
96
|
}
|
|
97
97
|
}
|
|
@@ -12,7 +12,7 @@ const creator = new creator_1.BasicCaseCreator({
|
|
|
12
12
|
clean: true,
|
|
13
13
|
runner: {
|
|
14
14
|
key: watch_1.getWatchRunnerKey,
|
|
15
|
-
runner: watch_1.createWatchRunner
|
|
15
|
+
runner: watch_1.createWatchRunner,
|
|
16
16
|
},
|
|
17
17
|
description: (name, index) => {
|
|
18
18
|
return index === 0
|
|
@@ -25,17 +25,17 @@ const creator = new creator_1.BasicCaseCreator({
|
|
|
25
25
|
const runs = node_fs_1.default
|
|
26
26
|
.readdirSync(src)
|
|
27
27
|
.sort()
|
|
28
|
-
.filter(name => node_fs_1.default.statSync(node_path_1.default.join(src, name)).isDirectory())
|
|
29
|
-
.map(name => ({ name }));
|
|
28
|
+
.filter((name) => node_fs_1.default.statSync(node_path_1.default.join(src, name)).isDirectory())
|
|
29
|
+
.map((name) => ({ name }));
|
|
30
30
|
return runs.map((run, index) => index === 0
|
|
31
31
|
? (0, watch_1.createWatchInitialProcessor)(name, temp, run.name, watchState, {
|
|
32
|
-
nativeWatcher: true
|
|
32
|
+
nativeWatcher: true,
|
|
33
33
|
})
|
|
34
34
|
: (0, watch_1.createWatchStepProcessor)(name, temp, run.name, watchState, {
|
|
35
|
-
nativeWatcher: true
|
|
35
|
+
nativeWatcher: true,
|
|
36
36
|
}));
|
|
37
37
|
},
|
|
38
|
-
concurrent: true
|
|
38
|
+
concurrent: true,
|
|
39
39
|
});
|
|
40
40
|
function createNativeWatcher(name, src, dist, temp) {
|
|
41
41
|
creator.create(name, src, dist, temp);
|
package/dist/case/normal.js
CHANGED
|
@@ -13,7 +13,7 @@ const core_1 = require("@rspack/core");
|
|
|
13
13
|
const creator_1 = require("../test/creator");
|
|
14
14
|
const common_1 = require("./common");
|
|
15
15
|
const runner_1 = require("./runner");
|
|
16
|
-
const NORMAL_CASES_ROOT = node_path_1.default.resolve(__TEST_PATH__,
|
|
16
|
+
const NORMAL_CASES_ROOT = node_path_1.default.resolve(__TEST_PATH__, 'normalCases');
|
|
17
17
|
const createCaseOptions = (hot, mode) => {
|
|
18
18
|
return {
|
|
19
19
|
clean: true,
|
|
@@ -23,9 +23,9 @@ const createCaseOptions = (hot, mode) => {
|
|
|
23
23
|
config: async (context) => {
|
|
24
24
|
const compiler = context.getCompiler();
|
|
25
25
|
let options = defaultOptions(context, {
|
|
26
|
-
plugins: hot ? [new core_1.HotModuleReplacementPlugin()] : []
|
|
26
|
+
plugins: hot ? [new core_1.HotModuleReplacementPlugin()] : [],
|
|
27
27
|
}, mode);
|
|
28
|
-
options = await (0, common_1.config)(context, name, [
|
|
28
|
+
options = await (0, common_1.config)(context, name, ['rspack.config.js', 'webpack.config.js'], options);
|
|
29
29
|
overrideOptions(context, options);
|
|
30
30
|
compiler.setOptions(options);
|
|
31
31
|
},
|
|
@@ -43,14 +43,14 @@ const createCaseOptions = (hot, mode) => {
|
|
|
43
43
|
},
|
|
44
44
|
after: async (context) => {
|
|
45
45
|
await (0, common_1.afterExecute)(context, name);
|
|
46
|
-
}
|
|
47
|
-
}
|
|
46
|
+
},
|
|
47
|
+
},
|
|
48
48
|
],
|
|
49
49
|
runner: {
|
|
50
50
|
key: (context, name, file) => name,
|
|
51
|
-
runner: runner_1.createRunner
|
|
51
|
+
runner: runner_1.createRunner,
|
|
52
52
|
},
|
|
53
|
-
concurrent: true
|
|
53
|
+
concurrent: true,
|
|
54
54
|
};
|
|
55
55
|
};
|
|
56
56
|
const creator = new creator_1.BasicCaseCreator(createCaseOptions(false));
|
|
@@ -61,45 +61,45 @@ const hotCreator = new creator_1.BasicCaseCreator(createCaseOptions(true));
|
|
|
61
61
|
function createHotNormalCase(name, src, dist) {
|
|
62
62
|
hotCreator.create(name, src, dist);
|
|
63
63
|
}
|
|
64
|
-
const devCreator = new creator_1.BasicCaseCreator(createCaseOptions(false,
|
|
64
|
+
const devCreator = new creator_1.BasicCaseCreator(createCaseOptions(false, 'development'));
|
|
65
65
|
function createDevNormalCase(name, src, dist) {
|
|
66
66
|
devCreator.create(name, src, dist);
|
|
67
67
|
}
|
|
68
|
-
const prodCreator = new creator_1.BasicCaseCreator(createCaseOptions(false,
|
|
68
|
+
const prodCreator = new creator_1.BasicCaseCreator(createCaseOptions(false, 'production'));
|
|
69
69
|
function createProdNormalCase(name, src, dist) {
|
|
70
70
|
prodCreator.create(name, src, dist);
|
|
71
71
|
}
|
|
72
72
|
function findBundle(context, options) {
|
|
73
73
|
const testConfig = context.getTestConfig();
|
|
74
|
-
if (typeof testConfig.findBundle ===
|
|
74
|
+
if (typeof testConfig.findBundle === 'function') {
|
|
75
75
|
return testConfig.findBundle(0, options);
|
|
76
76
|
}
|
|
77
77
|
const filename = options.output?.filename;
|
|
78
|
-
return typeof filename ===
|
|
78
|
+
return typeof filename === 'string' ? filename : undefined;
|
|
79
79
|
}
|
|
80
80
|
function defaultOptions(context, compilerOptions, mode) {
|
|
81
81
|
let testConfig = {};
|
|
82
|
-
const testConfigPath = node_path_1.default.join(context.getSource(),
|
|
82
|
+
const testConfigPath = node_path_1.default.join(context.getSource(), 'test.config.js');
|
|
83
83
|
if (node_fs_1.default.existsSync(testConfigPath)) {
|
|
84
84
|
testConfig = require(testConfigPath);
|
|
85
85
|
}
|
|
86
|
-
const TerserPlugin = require(
|
|
86
|
+
const TerserPlugin = require('terser-webpack-plugin');
|
|
87
87
|
const terserForTesting = new TerserPlugin({
|
|
88
|
-
parallel: false
|
|
88
|
+
parallel: false,
|
|
89
89
|
});
|
|
90
90
|
return {
|
|
91
91
|
amd: {},
|
|
92
92
|
context: NORMAL_CASES_ROOT,
|
|
93
93
|
entry: `./${node_path_1.default.relative(NORMAL_CASES_ROOT, context.getSource())}/`,
|
|
94
|
-
target: compilerOptions?.target ||
|
|
95
|
-
devtool: mode ===
|
|
96
|
-
mode: compilerOptions?.mode || mode ||
|
|
94
|
+
target: compilerOptions?.target || 'async-node',
|
|
95
|
+
devtool: mode === 'development' ? false : compilerOptions?.devtool,
|
|
96
|
+
mode: compilerOptions?.mode || mode || 'none',
|
|
97
97
|
optimization: compilerOptions?.mode
|
|
98
98
|
? {
|
|
99
99
|
emitOnErrors: true,
|
|
100
100
|
minimizer: [terserForTesting],
|
|
101
101
|
minimize: false,
|
|
102
|
-
...testConfig.optimization
|
|
102
|
+
...testConfig.optimization,
|
|
103
103
|
}
|
|
104
104
|
: {
|
|
105
105
|
removeAvailableModules: true,
|
|
@@ -119,61 +119,61 @@ function defaultOptions(context, compilerOptions, mode) {
|
|
|
119
119
|
// CHANGE: size is not supported yet
|
|
120
120
|
// moduleIds: "size",
|
|
121
121
|
// chunkIds: "size",
|
|
122
|
-
moduleIds:
|
|
123
|
-
chunkIds:
|
|
122
|
+
moduleIds: 'named',
|
|
123
|
+
chunkIds: 'named',
|
|
124
124
|
minimize: false,
|
|
125
125
|
minimizer: [terserForTesting],
|
|
126
|
-
...compilerOptions?.optimization
|
|
126
|
+
...compilerOptions?.optimization,
|
|
127
127
|
},
|
|
128
128
|
// CHANGE: rspack does not support `performance` yet.
|
|
129
129
|
// performance: {
|
|
130
130
|
// hints: false
|
|
131
131
|
// },
|
|
132
132
|
node: {
|
|
133
|
-
__dirname:
|
|
134
|
-
__filename:
|
|
133
|
+
__dirname: 'mock',
|
|
134
|
+
__filename: 'mock',
|
|
135
135
|
},
|
|
136
136
|
cache: compilerOptions?.cache && {
|
|
137
137
|
// cacheDirectory,
|
|
138
|
-
...compilerOptions.cache
|
|
138
|
+
...compilerOptions.cache,
|
|
139
139
|
},
|
|
140
140
|
output: {
|
|
141
|
-
pathinfo:
|
|
141
|
+
pathinfo: 'verbose',
|
|
142
142
|
path: context.getDist(),
|
|
143
|
-
filename: compilerOptions?.module ?
|
|
143
|
+
filename: compilerOptions?.module ? 'bundle.mjs' : 'bundle.js',
|
|
144
144
|
},
|
|
145
145
|
resolve: {
|
|
146
|
-
modules: [
|
|
147
|
-
mainFields: [
|
|
148
|
-
aliasFields: [
|
|
149
|
-
extensions: [
|
|
146
|
+
modules: ['web_modules', 'node_modules'],
|
|
147
|
+
mainFields: ['webpack', 'browser', 'web', 'browserify', 'main'],
|
|
148
|
+
aliasFields: ['browser'],
|
|
149
|
+
extensions: ['.webpack.js', '.web.js', '.js', '.json'],
|
|
150
150
|
},
|
|
151
151
|
resolveLoader: {
|
|
152
|
-
modules: [
|
|
153
|
-
mainFields: [
|
|
154
|
-
extensions: [
|
|
152
|
+
modules: ['web_loaders', 'web_modules', 'node_loaders', 'node_modules'],
|
|
153
|
+
mainFields: ['webpackLoader', 'webLoader', 'loader', 'main'],
|
|
154
|
+
extensions: ['.webpack-loader.js', '.web-loader.js', '.loader.js', '.js'],
|
|
155
155
|
},
|
|
156
156
|
module: {
|
|
157
157
|
rules: [
|
|
158
158
|
{
|
|
159
159
|
test: /\.coffee$/,
|
|
160
|
-
loader:
|
|
160
|
+
loader: 'coffee-loader',
|
|
161
161
|
},
|
|
162
162
|
{
|
|
163
163
|
test: /\.pug/,
|
|
164
|
-
loader:
|
|
164
|
+
loader: '@webdiscus/pug-loader',
|
|
165
165
|
},
|
|
166
166
|
{
|
|
167
167
|
test: /\.wat$/i,
|
|
168
|
-
loader:
|
|
169
|
-
type:
|
|
170
|
-
}
|
|
171
|
-
]
|
|
168
|
+
loader: 'wast-loader',
|
|
169
|
+
type: 'webassembly/async',
|
|
170
|
+
},
|
|
171
|
+
],
|
|
172
172
|
},
|
|
173
173
|
plugins: (compilerOptions?.plugins || [])
|
|
174
174
|
.concat(testConfig.plugins || [])
|
|
175
175
|
.concat(function () {
|
|
176
|
-
this.hooks.compilation.tap(
|
|
176
|
+
this.hooks.compilation.tap('TestCasesTest', (compilation) => {
|
|
177
177
|
const hooks = [
|
|
178
178
|
// CHANGE: the following hooks are not supported yet, so comment it out
|
|
179
179
|
// "optimize",
|
|
@@ -183,7 +183,7 @@ function defaultOptions(context, compilerOptions, mode) {
|
|
|
183
183
|
// "afterOptimizeAssets"
|
|
184
184
|
];
|
|
185
185
|
for (const hook of hooks) {
|
|
186
|
-
compilation.hooks[hook].tap(
|
|
186
|
+
compilation.hooks[hook].tap('TestCasesTest', () => compilation.checkConstraints());
|
|
187
187
|
}
|
|
188
188
|
});
|
|
189
189
|
}),
|
|
@@ -191,8 +191,8 @@ function defaultOptions(context, compilerOptions, mode) {
|
|
|
191
191
|
css: false,
|
|
192
192
|
rspackFuture: {
|
|
193
193
|
bundlerInfo: {
|
|
194
|
-
force: false
|
|
195
|
-
}
|
|
194
|
+
force: false,
|
|
195
|
+
},
|
|
196
196
|
},
|
|
197
197
|
asyncWebAssembly: true,
|
|
198
198
|
topLevelAwait: true,
|
|
@@ -200,14 +200,14 @@ function defaultOptions(context, compilerOptions, mode) {
|
|
|
200
200
|
// backCompat: false,
|
|
201
201
|
// CHANGE: Rspack enables `css` by default.
|
|
202
202
|
// Turning off here to fallback to webpack's default css processing logic.
|
|
203
|
-
...(compilerOptions?.module ? { outputModule: true } : {})
|
|
204
|
-
}
|
|
203
|
+
...(compilerOptions?.module ? { outputModule: true } : {}),
|
|
204
|
+
},
|
|
205
205
|
};
|
|
206
206
|
}
|
|
207
207
|
function overrideOptions(context, options) {
|
|
208
208
|
if (!global.printLogger) {
|
|
209
209
|
options.infrastructureLogging = {
|
|
210
|
-
level:
|
|
210
|
+
level: 'error',
|
|
211
211
|
};
|
|
212
212
|
}
|
|
213
213
|
}
|
package/dist/case/runner.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import type { StatsCompilation } from
|
|
2
|
-
import type { ITestContext, ITestEnv, ITestRunner } from
|
|
1
|
+
import type { StatsCompilation } from '@rspack/core';
|
|
2
|
+
import type { ITestContext, ITestEnv, ITestRunner } from '../type';
|
|
3
3
|
export type THotStepRuntimeLangData = {
|
|
4
4
|
outdatedModules: string[];
|
|
5
5
|
outdatedDependencies: Record<string, string[]>;
|
package/dist/case/runner.js
CHANGED
|
@@ -6,6 +6,13 @@ exports.getMultiCompilerRunnerKey = getMultiCompilerRunnerKey;
|
|
|
6
6
|
exports.createMultiCompilerRunner = createMultiCompilerRunner;
|
|
7
7
|
const runner_1 = require("../runner");
|
|
8
8
|
const debug_1 = require("../test/debug");
|
|
9
|
+
const isWebTarget = (compilerOptions) => {
|
|
10
|
+
const target = compilerOptions.target;
|
|
11
|
+
if (Array.isArray(target)) {
|
|
12
|
+
return target.some((t) => t === 'web' || t === 'webworker');
|
|
13
|
+
}
|
|
14
|
+
return target === 'web' || target === 'webworker';
|
|
15
|
+
};
|
|
9
16
|
function cachedStats(context, name) {
|
|
10
17
|
const compiler = context.getCompiler();
|
|
11
18
|
const statsGetter = (() => {
|
|
@@ -15,7 +22,7 @@ function cachedStats(context, name) {
|
|
|
15
22
|
return cached;
|
|
16
23
|
}
|
|
17
24
|
cached = compiler.getStats().toJson({
|
|
18
|
-
errorDetails: true
|
|
25
|
+
errorDetails: true,
|
|
19
26
|
});
|
|
20
27
|
return cached;
|
|
21
28
|
};
|
|
@@ -35,23 +42,23 @@ function createRunner(context, name, file, env) {
|
|
|
35
42
|
testConfig: context.getTestConfig(),
|
|
36
43
|
source: context.getSource(),
|
|
37
44
|
dist: context.getDist(),
|
|
38
|
-
compilerOptions
|
|
45
|
+
compilerOptions,
|
|
39
46
|
};
|
|
40
|
-
|
|
41
|
-
|
|
47
|
+
const isWeb = isWebTarget(compilerOptions);
|
|
48
|
+
if (isWeb) {
|
|
42
49
|
return new runner_1.WebRunner({
|
|
43
50
|
...runnerOptions,
|
|
44
51
|
runInNewContext: true,
|
|
45
|
-
location: testConfig.location ||
|
|
52
|
+
location: testConfig.location || 'https://test.cases/path/index.html',
|
|
46
53
|
});
|
|
47
54
|
}
|
|
48
55
|
return new runner_1.NodeRunner(runnerOptions);
|
|
49
56
|
}
|
|
50
57
|
function getFileIndexHandler(context, name, file) {
|
|
51
|
-
const multiFileIndexMap = context.getValue(
|
|
52
|
-
const runned = context.getValue(
|
|
53
|
-
if (typeof multiFileIndexMap[file] ===
|
|
54
|
-
throw new Error(
|
|
58
|
+
const multiFileIndexMap = context.getValue('multiFileIndexMap') || {};
|
|
59
|
+
const runned = context.getValue('runned') || new Set();
|
|
60
|
+
if (typeof multiFileIndexMap[file] === 'undefined') {
|
|
61
|
+
throw new Error('Unexpect file in multiple runner');
|
|
55
62
|
}
|
|
56
63
|
const indexList = multiFileIndexMap[file];
|
|
57
64
|
const seq = indexList.findIndex((index, n) => !runned.has(`${name}:${file}[${n}]`));
|
|
@@ -60,7 +67,7 @@ function getFileIndexHandler(context, name, file) {
|
|
|
60
67
|
}
|
|
61
68
|
const getIndex = () => [indexList[seq], seq];
|
|
62
69
|
const flagIndex = () => runned.add(`${name}:${file}[${seq}]`);
|
|
63
|
-
context.setValue(
|
|
70
|
+
context.setValue('runned', runned);
|
|
64
71
|
return { getIndex, flagIndex };
|
|
65
72
|
}
|
|
66
73
|
function getMultiCompilerRunnerKey(context, name, file) {
|
|
@@ -71,7 +78,7 @@ function getMultiCompilerRunnerKey(context, name, file) {
|
|
|
71
78
|
function createMultiCompilerRunner(context, name, file, env) {
|
|
72
79
|
const testConfig = context.getTestConfig();
|
|
73
80
|
const { getIndex, flagIndex } = getFileIndexHandler(context, name, file);
|
|
74
|
-
const multiCompilerOptions = context.getValue(
|
|
81
|
+
const multiCompilerOptions = context.getValue('multiCompilerOptions') || [];
|
|
75
82
|
const [index] = getIndex();
|
|
76
83
|
const compilerOptions = multiCompilerOptions[index];
|
|
77
84
|
const logs = context.getValue(debug_1.DEBUG_SCOPES.RunLogs);
|
|
@@ -95,14 +102,14 @@ function createMultiCompilerRunner(context, name, file, env) {
|
|
|
95
102
|
dist: context.getDist(),
|
|
96
103
|
compilerOptions,
|
|
97
104
|
logs,
|
|
98
|
-
errors
|
|
105
|
+
errors,
|
|
99
106
|
};
|
|
100
|
-
|
|
101
|
-
|
|
107
|
+
const isWeb = isWebTarget(compilerOptions);
|
|
108
|
+
if (isWeb) {
|
|
102
109
|
runner = new runner_1.WebRunner({
|
|
103
110
|
...runnerOptions,
|
|
104
111
|
runInNewContext: true,
|
|
105
|
-
location: testConfig.location ||
|
|
112
|
+
location: testConfig.location || 'https://test.cases/path/index.html',
|
|
106
113
|
});
|
|
107
114
|
}
|
|
108
115
|
else {
|
package/dist/case/serial.d.ts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import type { TTestConfig } from
|
|
2
|
-
export type TSerialCaseConfig = Omit<TTestConfig,
|
|
1
|
+
import type { TTestConfig } from '../type';
|
|
2
|
+
export type TSerialCaseConfig = Omit<TTestConfig, 'validate'>;
|
|
3
3
|
export declare function createSerialCase(name: string, src: string, dist: string): void;
|
package/dist/case/serial.js
CHANGED
|
@@ -7,12 +7,12 @@ const runner_1 = require("./runner");
|
|
|
7
7
|
const creator = new creator_1.BasicCaseCreator({
|
|
8
8
|
clean: true,
|
|
9
9
|
describe: false,
|
|
10
|
-
testConfig: testConfig => {
|
|
10
|
+
testConfig: (testConfig) => {
|
|
11
11
|
const oldModuleScope = testConfig.moduleScope;
|
|
12
12
|
testConfig.moduleScope = (ms, stats, compilerOptions) => {
|
|
13
13
|
let res = ms;
|
|
14
14
|
// TODO: modify runner module scope based on stats here
|
|
15
|
-
if (typeof oldModuleScope ===
|
|
15
|
+
if (typeof oldModuleScope === 'function') {
|
|
16
16
|
res = oldModuleScope(ms, stats, compilerOptions);
|
|
17
17
|
}
|
|
18
18
|
return res;
|
|
@@ -21,9 +21,9 @@ const creator = new creator_1.BasicCaseCreator({
|
|
|
21
21
|
steps: ({ name }) => [(0, config_1.createConfigProcessor)(name)],
|
|
22
22
|
runner: {
|
|
23
23
|
key: runner_1.getMultiCompilerRunnerKey,
|
|
24
|
-
runner: runner_1.createMultiCompilerRunner
|
|
24
|
+
runner: runner_1.createMultiCompilerRunner,
|
|
25
25
|
},
|
|
26
|
-
concurrent: 1
|
|
26
|
+
concurrent: 1,
|
|
27
27
|
});
|
|
28
28
|
function createSerialCase(name, src, dist) {
|
|
29
29
|
creator.create(name, src, dist);
|
package/dist/case/stats-api.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import type { Compiler, RspackOptions, Stats } from
|
|
2
|
-
import type { ITestContext } from
|
|
1
|
+
import type { Compiler, RspackOptions, Stats } from '@rspack/core';
|
|
2
|
+
import type { ITestContext } from '../type';
|
|
3
3
|
export type TStatsAPICaseConfig = {
|
|
4
4
|
description: string;
|
|
5
5
|
options?: (context: ITestContext) => RspackOptions;
|
package/dist/case/stats-api.js
CHANGED
|
@@ -22,7 +22,7 @@ const creator = new creator_1.BasicCaseCreator({
|
|
|
22
22
|
},
|
|
23
23
|
build: async (context) => {
|
|
24
24
|
const compiler = context.getCompiler();
|
|
25
|
-
if (typeof config.build ===
|
|
25
|
+
if (typeof config.build === 'function') {
|
|
26
26
|
await config.build(context, compiler.getCompiler());
|
|
27
27
|
}
|
|
28
28
|
else {
|
|
@@ -34,11 +34,11 @@ const creator = new creator_1.BasicCaseCreator({
|
|
|
34
34
|
},
|
|
35
35
|
check: async (env, context) => {
|
|
36
36
|
await check(env, context, name, config.check);
|
|
37
|
-
}
|
|
38
|
-
}
|
|
37
|
+
},
|
|
38
|
+
},
|
|
39
39
|
];
|
|
40
40
|
},
|
|
41
|
-
concurrent: true
|
|
41
|
+
concurrent: true,
|
|
42
42
|
});
|
|
43
43
|
function createStatsAPICase(name, src, dist, testConfig) {
|
|
44
44
|
if (!addedSerializer) {
|
|
@@ -47,7 +47,7 @@ function createStatsAPICase(name, src, dist, testConfig) {
|
|
|
47
47
|
const caseConfig = require(testConfig);
|
|
48
48
|
creator.create(name, src, dist, undefined, {
|
|
49
49
|
caseConfig,
|
|
50
|
-
description: () => caseConfig.description
|
|
50
|
+
description: () => caseConfig.description,
|
|
51
51
|
});
|
|
52
52
|
}
|
|
53
53
|
function options(context, custom) {
|
|
@@ -59,7 +59,7 @@ function options(context, custom) {
|
|
|
59
59
|
res.experiments.rspackFuture.bundlerInfo.force ??= false;
|
|
60
60
|
if (!global.printLogger) {
|
|
61
61
|
res.infrastructureLogging = {
|
|
62
|
-
level:
|
|
62
|
+
level: 'error',
|
|
63
63
|
};
|
|
64
64
|
}
|
|
65
65
|
return res;
|
|
@@ -75,6 +75,6 @@ async function compiler(context, compiler, custom) {
|
|
|
75
75
|
async function check(env, context, name, custom) {
|
|
76
76
|
const manager = context.getCompiler();
|
|
77
77
|
const stats = manager.getStats();
|
|
78
|
-
env.expect(typeof stats).toBe(
|
|
78
|
+
env.expect(typeof stats).toBe('object');
|
|
79
79
|
await custom?.(stats, manager.getCompiler());
|
|
80
80
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import type { RspackOptions } from
|
|
2
|
-
import type { ITestContext, ITestEnv } from
|
|
1
|
+
import type { RspackOptions } from '@rspack/core';
|
|
2
|
+
import type { ITestContext, ITestEnv } from '../type';
|
|
3
3
|
export declare function createStatsProcessor(name: string, defaultOptions: (index: number, context: ITestContext) => RspackOptions, overrideOptions: (index: number, context: ITestContext, options: RspackOptions) => void): {
|
|
4
4
|
before: (context: ITestContext) => Promise<void>;
|
|
5
5
|
config: (context: ITestContext) => Promise<void>;
|