@rspack/test-tools 2.0.1 → 2.0.3
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 +106 -66
- package/dist/case/cache.js +152 -132
- package/dist/case/common.d.ts +4 -4
- package/dist/case/common.js +162 -157
- package/dist/case/compiler.d.ts +4 -4
- package/dist/case/compiler.js +75 -64
- package/dist/case/config.js +112 -74
- package/dist/case/defaults.js +136 -83
- package/dist/case/diagnostic.js +112 -84
- package/dist/case/error.d.ts +4 -4
- package/dist/case/error.js +105 -89
- package/dist/case/esm-output.js +118 -87
- package/dist/case/example.js +73 -35
- package/dist/case/hash.js +74 -59
- package/dist/case/hook.js +151 -138
- package/dist/case/hot-step.js +130 -161
- package/dist/case/hot.js +148 -134
- package/dist/case/incremental.js +91 -58
- package/dist/case/index.js +134 -51
- package/dist/case/multi-compiler.d.ts +4 -4
- package/dist/case/multi-compiler.js +81 -56
- package/dist/case/native-watcher.js +62 -30
- package/dist/case/normal.js +253 -185
- package/dist/case/runner.js +80 -51
- package/dist/case/serial.js +47 -16
- package/dist/case/stats-api.d.ts +4 -4
- package/dist/case/stats-api.js +63 -43
- package/dist/case/stats-output.d.ts +3 -3
- package/dist/case/stats-output.js +147 -152
- package/dist/case/treeshaking.js +66 -35
- package/dist/case/watch.d.ts +3 -19
- package/dist/case/watch.js +204 -224
- package/dist/compiler.js +222 -195
- package/dist/helper/directory.js +83 -71
- package/dist/helper/disable-iconv-lite-warning.js +35 -9
- package/dist/helper/expect/diff.js +39 -10
- package/dist/helper/expect/error.js +62 -30
- package/dist/helper/expect/placeholder.js +47 -21
- package/dist/helper/expect/rspack.js +35 -13
- package/dist/helper/expect/to-be-typeof.js +39 -7
- package/dist/helper/expect/to-end-with.js +40 -8
- package/dist/helper/expect/to-match-file-snapshot.js +103 -80
- package/dist/helper/hot-update/index.js +35 -4
- package/dist/helper/hot-update/loader.d.ts +1 -0
- package/dist/helper/hot-update/loader.js +39 -4
- package/dist/helper/hot-update/plugin.d.ts +1 -1
- package/dist/helper/hot-update/plugin.js +87 -74
- package/dist/helper/index.js +138 -24
- package/dist/helper/is.js +51 -10
- package/dist/helper/legacy/EventSourceForNode.d.ts +11 -3
- package/dist/helper/legacy/EventSourceForNode.js +83 -37
- package/dist/helper/legacy/LogTestPlugin.d.ts +2 -3
- package/dist/helper/legacy/LogTestPlugin.js +39 -6
- package/dist/helper/legacy/asModule.d.ts +3 -3
- package/dist/helper/legacy/asModule.js +68 -19
- package/dist/helper/legacy/captureStdio.d.ts +1 -2
- package/dist/helper/legacy/captureStdio.js +69 -29
- package/dist/helper/legacy/checkArrayExpectation.d.ts +1 -2
- package/dist/helper/legacy/checkArrayExpectation.js +132 -121
- package/dist/helper/legacy/copyDiff.d.ts +1 -2
- package/dist/helper/legacy/copyDiff.js +86 -42
- package/dist/helper/legacy/createFakeWorker.d.ts +2 -3
- package/dist/helper/legacy/createFakeWorker.js +90 -47
- package/dist/helper/legacy/createLazyTestEnv.d.ts +2 -3
- package/dist/helper/legacy/createLazyTestEnv.js +70 -59
- package/dist/helper/legacy/currentScript.d.ts +2 -2
- package/dist/helper/legacy/currentScript.js +35 -2
- package/dist/helper/legacy/deprecationTracking.d.ts +1 -1
- package/dist/helper/legacy/deprecationTracking.js +53 -28
- package/dist/helper/legacy/expectSource.d.ts +3 -2
- package/dist/helper/legacy/expectSource.js +42 -18
- package/dist/helper/legacy/fakeSystem.d.ts +12 -9
- package/dist/helper/legacy/fakeSystem.js +68 -58
- package/dist/helper/legacy/findOutputFiles.d.ts +7 -2
- package/dist/helper/legacy/findOutputFiles.js +60 -13
- package/dist/helper/legacy/parseResource.d.ts +1 -1
- package/dist/helper/legacy/parseResource.js +36 -6
- package/dist/helper/legacy/regexEscape.d.ts +1 -2
- package/dist/helper/legacy/regexEscape.js +39 -5
- package/dist/helper/legacy/supportDefaultAssignment.d.ts +1 -2
- package/dist/helper/legacy/supportDefaultAssignment.js +40 -7
- package/dist/helper/legacy/supportsTextDecoder.d.ts +1 -2
- package/dist/helper/legacy/supportsTextDecoder.js +40 -6
- package/dist/helper/legacy/supportsUsing.d.ts +1 -2
- package/dist/helper/legacy/supportsUsing.js +40 -7
- package/dist/helper/legacy/urlToRelativePath.d.ts +2 -2
- package/dist/helper/legacy/urlToRelativePath.js +56 -7
- package/dist/helper/parse-modules.js +52 -42
- package/dist/helper/read-config-file.js +60 -18
- package/dist/helper/serializers.js +62 -33
- package/dist/helper/setup-env.js +81 -91
- package/dist/helper/setup-expect.js +13 -13
- package/dist/helper/setup-wasm.js +18 -9
- package/dist/helper/stringify-config.js +44 -26
- package/dist/helper/update-snapshot.js +35 -3
- package/dist/helper/util/checkSourceMap.js +119 -80
- package/dist/helper/util/checkStats.d.ts +1 -1
- package/dist/helper/util/checkStats.js +42 -17
- package/dist/helper/util/expectWarningFactory.d.ts +1 -2
- package/dist/helper/util/expectWarningFactory.js +41 -8
- package/dist/helper/util/filterUtil.d.ts +9 -8
- package/dist/helper/util/filterUtil.js +63 -23
- package/dist/helper/win.js +46 -7
- package/dist/index.js +115 -23
- package/dist/plugin/index.js +55 -14
- package/dist/plugin/lazy-compilation-test-plugin.js +55 -41
- package/dist/reporter/index.js +55 -14
- package/dist/reporter/streamed-events-reporter.js +51 -77
- package/dist/runner/index.js +62 -15
- package/dist/runner/node/index.js +365 -431
- package/dist/runner/web/index.js +278 -263
- package/dist/test/context.js +67 -41
- package/dist/test/creator.js +135 -167
- package/dist/test/debug.js +89 -58
- package/dist/test/tester.js +94 -74
- package/dist/type.d.ts +10 -9
- package/dist/type.js +43 -9
- package/package.json +24 -23
package/dist/case/hot.js
CHANGED
|
@@ -1,84 +1,112 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
2
|
+
var __webpack_require__ = {};
|
|
3
|
+
(()=>{
|
|
4
|
+
__webpack_require__.n = (module)=>{
|
|
5
|
+
var getter = module && module.__esModule ? ()=>module['default'] : ()=>module;
|
|
6
|
+
__webpack_require__.d(getter, {
|
|
7
|
+
a: getter
|
|
8
|
+
});
|
|
9
|
+
return getter;
|
|
10
|
+
};
|
|
11
|
+
})();
|
|
12
|
+
(()=>{
|
|
13
|
+
__webpack_require__.d = (exports1, definition)=>{
|
|
14
|
+
for(var key in definition)if (__webpack_require__.o(definition, key) && !__webpack_require__.o(exports1, key)) Object.defineProperty(exports1, key, {
|
|
15
|
+
enumerable: true,
|
|
16
|
+
get: definition[key]
|
|
17
|
+
});
|
|
18
|
+
};
|
|
19
|
+
})();
|
|
20
|
+
(()=>{
|
|
21
|
+
__webpack_require__.o = (obj, prop)=>Object.prototype.hasOwnProperty.call(obj, prop);
|
|
22
|
+
})();
|
|
23
|
+
(()=>{
|
|
24
|
+
__webpack_require__.r = (exports1)=>{
|
|
25
|
+
if ("u" > typeof Symbol && Symbol.toStringTag) Object.defineProperty(exports1, Symbol.toStringTag, {
|
|
26
|
+
value: 'Module'
|
|
27
|
+
});
|
|
28
|
+
Object.defineProperty(exports1, '__esModule', {
|
|
29
|
+
value: true
|
|
30
|
+
});
|
|
31
|
+
};
|
|
32
|
+
})();
|
|
33
|
+
var __webpack_exports__ = {};
|
|
34
|
+
__webpack_require__.r(__webpack_exports__);
|
|
35
|
+
__webpack_require__.d(__webpack_exports__, {
|
|
36
|
+
createHotCase: ()=>createHotCase,
|
|
37
|
+
createHotProcessor: ()=>createHotProcessor,
|
|
38
|
+
createHotRunner: ()=>createHotRunner
|
|
39
|
+
});
|
|
40
|
+
const external_node_path_namespaceObject = require("node:path");
|
|
41
|
+
var external_node_path_default = /*#__PURE__*/ __webpack_require__.n(external_node_path_namespaceObject);
|
|
42
|
+
const core_namespaceObject = require("@rspack/core");
|
|
43
|
+
var core_default = /*#__PURE__*/ __webpack_require__.n(core_namespaceObject);
|
|
44
|
+
const index_js_namespaceObject = require("../helper/index.js");
|
|
45
|
+
const plugin_js_namespaceObject = require("../helper/hot-update/plugin.js");
|
|
46
|
+
const checkArrayExpectation_js_namespaceObject = require("../helper/legacy/checkArrayExpectation.js");
|
|
47
|
+
const external_plugin_index_js_namespaceObject = require("../plugin/index.js");
|
|
48
|
+
const external_runner_index_js_namespaceObject = require("../runner/index.js");
|
|
49
|
+
const creator_js_namespaceObject = require("../test/creator.js");
|
|
50
|
+
const external_common_js_namespaceObject = require("./common.js");
|
|
51
|
+
const external_runner_js_namespaceObject = require("./runner.js");
|
|
19
52
|
const creators = new Map();
|
|
20
53
|
function createHotProcessor(name, src, temp, target, incremental = false) {
|
|
21
|
-
const updatePlugin = new
|
|
54
|
+
const updatePlugin = new plugin_js_namespaceObject.HotUpdatePlugin(src, temp);
|
|
22
55
|
const processor = {
|
|
23
|
-
before: async (context)
|
|
56
|
+
before: async (context)=>{
|
|
24
57
|
await updatePlugin.initialize();
|
|
25
58
|
context.setValue('hotUpdatePlugin', updatePlugin);
|
|
26
59
|
},
|
|
27
|
-
config: async (context)
|
|
60
|
+
config: async (context)=>{
|
|
28
61
|
const compiler = context.getCompiler();
|
|
29
62
|
let options = defaultOptions(context, target);
|
|
30
|
-
options = await (0,
|
|
63
|
+
options = await (0, external_common_js_namespaceObject.config)(context, name, [
|
|
64
|
+
'rspack.config.js',
|
|
65
|
+
'webpack.config.js'
|
|
66
|
+
], options);
|
|
31
67
|
overrideOptions(context, options, target, updatePlugin);
|
|
32
|
-
if (incremental)
|
|
33
|
-
options.incremental ??= 'advance-silent';
|
|
34
|
-
}
|
|
68
|
+
if (incremental) options.incremental ??= 'advance-silent';
|
|
35
69
|
compiler.setOptions(options);
|
|
36
70
|
},
|
|
37
|
-
compiler: async (context)
|
|
38
|
-
await (0,
|
|
71
|
+
compiler: async (context)=>{
|
|
72
|
+
await (0, external_common_js_namespaceObject.compiler)(context, name);
|
|
39
73
|
},
|
|
40
|
-
build: async (context)
|
|
41
|
-
await (0,
|
|
74
|
+
build: async (context)=>{
|
|
75
|
+
await (0, external_common_js_namespaceObject.build)(context, name);
|
|
42
76
|
},
|
|
43
|
-
run: async (env, context)
|
|
44
|
-
await (0,
|
|
77
|
+
run: async (env, context)=>{
|
|
78
|
+
await (0, external_common_js_namespaceObject.run)(env, context, name, (context)=>findBundle(context, name, target, updatePlugin));
|
|
45
79
|
},
|
|
46
|
-
check: async (env, context)
|
|
47
|
-
await (0,
|
|
80
|
+
check: async (env, context)=>{
|
|
81
|
+
await (0, external_common_js_namespaceObject.check)(env, context, name);
|
|
48
82
|
},
|
|
49
|
-
after: async (context)
|
|
50
|
-
await (0,
|
|
83
|
+
after: async (context)=>{
|
|
84
|
+
await (0, external_common_js_namespaceObject.afterExecute)(context, name);
|
|
51
85
|
},
|
|
52
|
-
afterAll:
|
|
53
|
-
if (context.getTestConfig().checkSteps
|
|
54
|
-
return;
|
|
55
|
-
}
|
|
86
|
+
afterAll: (context)=>{
|
|
87
|
+
if (false === context.getTestConfig().checkSteps) return;
|
|
56
88
|
const updateIndex = updatePlugin.getUpdateIndex();
|
|
57
89
|
const totalUpdates = updatePlugin.getTotalUpdates();
|
|
58
|
-
if (updateIndex + 1 !== totalUpdates) {
|
|
59
|
-
|
|
60
|
-
}
|
|
61
|
-
},
|
|
90
|
+
if (updateIndex + 1 !== totalUpdates) throw new Error(`Should run all hot steps (${updateIndex + 1} / ${totalUpdates}): ${name}`);
|
|
91
|
+
}
|
|
62
92
|
};
|
|
63
93
|
processor.updatePlugin = updatePlugin;
|
|
64
94
|
return processor;
|
|
65
95
|
}
|
|
66
96
|
function getCreator(target) {
|
|
67
|
-
if (!creators.has(target)) {
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
createHotProcessor(name, src, temp || node_path_1.default.resolve(dist, 'temp'), target),
|
|
97
|
+
if (!creators.has(target)) creators.set(target, new creator_js_namespaceObject.BasicCaseCreator({
|
|
98
|
+
clean: true,
|
|
99
|
+
describe: true,
|
|
100
|
+
target,
|
|
101
|
+
steps: ({ name, target, src, dist, temp })=>[
|
|
102
|
+
createHotProcessor(name, src, temp || external_node_path_default().resolve(dist, 'temp'), target)
|
|
74
103
|
],
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
}
|
|
104
|
+
runner: {
|
|
105
|
+
key: (context, name, file)=>name,
|
|
106
|
+
runner: createHotRunner
|
|
107
|
+
},
|
|
108
|
+
concurrent: true
|
|
109
|
+
}));
|
|
82
110
|
return creators.get(target);
|
|
83
111
|
}
|
|
84
112
|
function createHotCase(name, src, dist, temp, target) {
|
|
@@ -95,82 +123,74 @@ function defaultOptions(context, target) {
|
|
|
95
123
|
filename: 'bundle.js',
|
|
96
124
|
chunkFilename: '[name].chunk.[fullhash].js',
|
|
97
125
|
publicPath: 'https://test.cases/path/',
|
|
98
|
-
library: {
|
|
99
|
-
|
|
100
|
-
force: false,
|
|
126
|
+
library: {
|
|
127
|
+
type: 'commonjs2'
|
|
101
128
|
},
|
|
129
|
+
bundlerInfo: {
|
|
130
|
+
force: false
|
|
131
|
+
}
|
|
102
132
|
},
|
|
103
133
|
module: {
|
|
104
134
|
defaultRules: [
|
|
105
135
|
'...',
|
|
106
136
|
{
|
|
107
137
|
test: /\.css$/i,
|
|
108
|
-
type: 'css/auto'
|
|
109
|
-
}
|
|
110
|
-
]
|
|
138
|
+
type: 'css/auto'
|
|
139
|
+
}
|
|
140
|
+
]
|
|
111
141
|
},
|
|
112
142
|
optimization: {
|
|
113
|
-
moduleIds: 'named'
|
|
143
|
+
moduleIds: 'named'
|
|
114
144
|
},
|
|
115
145
|
target,
|
|
116
|
-
|
|
117
|
-
incremental: 'safe',
|
|
146
|
+
incremental: 'safe'
|
|
118
147
|
};
|
|
119
148
|
options.plugins ??= [];
|
|
120
|
-
options.plugins.push(new
|
|
149
|
+
options.plugins.push(new (core_default()).HotModuleReplacementPlugin());
|
|
121
150
|
return options;
|
|
122
151
|
}
|
|
123
152
|
function overrideOptions(context, options, target, updatePlugin) {
|
|
124
|
-
if (!options.entry)
|
|
125
|
-
options.entry = './index.js';
|
|
126
|
-
}
|
|
153
|
+
if (!options.entry) options.entry = './index.js';
|
|
127
154
|
options.module ??= {};
|
|
128
|
-
for (const cssModuleType of [
|
|
155
|
+
for (const cssModuleType of [
|
|
156
|
+
'css/auto',
|
|
157
|
+
'css/module',
|
|
158
|
+
'css'
|
|
159
|
+
]){
|
|
129
160
|
options.module.generator ??= {};
|
|
130
161
|
options.module.generator[cssModuleType] ??= {};
|
|
131
|
-
options.module.generator[cssModuleType].exportsOnly ??=
|
|
132
|
-
target === 'async-node';
|
|
162
|
+
options.module.generator[cssModuleType].exportsOnly ??= 'async-node' === target;
|
|
133
163
|
}
|
|
134
164
|
options.plugins ??= [];
|
|
135
165
|
options.plugins.push(updatePlugin);
|
|
136
|
-
if (!global.printLogger) {
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
}
|
|
141
|
-
if (options.lazyCompilation) {
|
|
142
|
-
options.plugins.push(new plugin_2.LazyCompilationTestPlugin());
|
|
143
|
-
}
|
|
166
|
+
if (!global.printLogger) options.infrastructureLogging = {
|
|
167
|
+
level: 'error'
|
|
168
|
+
};
|
|
169
|
+
if (options.lazyCompilation) options.plugins.push(new external_plugin_index_js_namespaceObject.LazyCompilationTestPlugin());
|
|
144
170
|
}
|
|
145
171
|
function findBundle(context, name, target, updatePlugin) {
|
|
146
172
|
const compiler = context.getCompiler();
|
|
147
|
-
if (!compiler)
|
|
148
|
-
throw new Error('Compiler should exists when find bundle');
|
|
173
|
+
if (!compiler) throw new Error('Compiler should exists when find bundle');
|
|
149
174
|
const testConfig = context.getTestConfig();
|
|
150
|
-
if (typeof testConfig.findBundle
|
|
151
|
-
return testConfig.findBundle(updatePlugin.getUpdateIndex(), compiler.getOptions());
|
|
152
|
-
}
|
|
175
|
+
if ('function' == typeof testConfig.findBundle) return testConfig.findBundle(updatePlugin.getUpdateIndex(), compiler.getOptions());
|
|
153
176
|
const files = [];
|
|
154
177
|
const prefiles = [];
|
|
155
178
|
const stats = compiler.getStats();
|
|
156
|
-
if (!stats)
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
}
|
|
164
|
-
else {
|
|
165
|
-
prefiles.push(file.name);
|
|
166
|
-
}
|
|
167
|
-
}
|
|
168
|
-
}
|
|
179
|
+
if (!stats) throw new Error('Stats should exists when find bundle');
|
|
180
|
+
const info = stats.toJson({
|
|
181
|
+
all: false,
|
|
182
|
+
entrypoints: true
|
|
183
|
+
});
|
|
184
|
+
if ('web' === target || 'webworker' === target) for (const file of info.entrypoints.main.assets)if ((0, index_js_namespaceObject.isJavaScript)(file.name)) files.push(file.name);
|
|
185
|
+
else prefiles.push(file.name);
|
|
169
186
|
else {
|
|
170
|
-
const assets = info.entrypoints.main.assets.filter((s)
|
|
187
|
+
const assets = info.entrypoints.main.assets.filter((s)=>(0, index_js_namespaceObject.isJavaScript)(s.name));
|
|
171
188
|
files.push(assets[assets.length - 1].name);
|
|
172
189
|
}
|
|
173
|
-
return [
|
|
190
|
+
return [
|
|
191
|
+
...prefiles,
|
|
192
|
+
...files
|
|
193
|
+
];
|
|
174
194
|
}
|
|
175
195
|
function createHotRunner(context, name, file, env) {
|
|
176
196
|
const compiler = context.getCompiler();
|
|
@@ -179,67 +199,61 @@ function createHotRunner(context, name, file, env) {
|
|
|
179
199
|
const source = context.getSource();
|
|
180
200
|
const dist = context.getDist();
|
|
181
201
|
const updatePlugin = context.getValue('hotUpdatePlugin');
|
|
182
|
-
const nextHMR = async (m, options)
|
|
202
|
+
const nextHMR = async (m, options)=>{
|
|
183
203
|
await updatePlugin.goNext();
|
|
184
204
|
const stats = await compiler.build();
|
|
185
|
-
if (!stats)
|
|
186
|
-
throw new Error('Should generate stats during build');
|
|
187
|
-
}
|
|
205
|
+
if (!stats) throw new Error('Should generate stats during build');
|
|
188
206
|
const jsonStats = stats.toJson({
|
|
189
207
|
assets: true,
|
|
190
208
|
chunks: true,
|
|
191
209
|
chunkModules: true,
|
|
192
210
|
modules: true,
|
|
193
211
|
entrypoints: true,
|
|
194
|
-
chunkGroups: true
|
|
195
|
-
// errorDetails: true
|
|
212
|
+
chunkGroups: true
|
|
196
213
|
});
|
|
197
214
|
const compilerOptions = compiler.getOptions();
|
|
198
|
-
const checker = context.getValue(jsonStats.errors?.length
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
checker(updatePlugin.getUpdateIndex(), stats, runner.getGlobal('__HMR_UPDATED_RUNTIME__'));
|
|
203
|
-
}
|
|
204
|
-
await (0, checkArrayExpectation_1.default)(source, jsonStats, 'error', `errors${updatePlugin.getUpdateIndex()}`, 'Error', compilerOptions);
|
|
205
|
-
await (0, checkArrayExpectation_1.default)(source, jsonStats, 'warning', `warnings${updatePlugin.getUpdateIndex()}`, 'Warning', compilerOptions);
|
|
215
|
+
const checker = context.getValue(jsonStats.errors?.length ? 'hotUpdateStepErrorChecker' : 'hotUpdateStepChecker');
|
|
216
|
+
if (checker) checker(updatePlugin.getUpdateIndex(), stats, runner.getGlobal('__HMR_UPDATED_RUNTIME__'));
|
|
217
|
+
await (0, checkArrayExpectation_js_namespaceObject.checkArrayExpectation)(source, jsonStats, 'error', `errors${updatePlugin.getUpdateIndex()}`, 'Error', compilerOptions);
|
|
218
|
+
await (0, checkArrayExpectation_js_namespaceObject.checkArrayExpectation)(source, jsonStats, 'warning', `warnings${updatePlugin.getUpdateIndex()}`, 'Warning', compilerOptions);
|
|
206
219
|
const updatedModules = await m.hot.check(options || true);
|
|
207
|
-
if (!updatedModules)
|
|
208
|
-
throw new Error('No update available');
|
|
209
|
-
}
|
|
220
|
+
if (!updatedModules) throw new Error('No update available');
|
|
210
221
|
return jsonStats;
|
|
211
222
|
};
|
|
212
223
|
const commonOptions = {
|
|
213
224
|
env,
|
|
214
|
-
stats: (0,
|
|
225
|
+
stats: (0, external_runner_js_namespaceObject.cachedStats)(context, name),
|
|
215
226
|
name: name,
|
|
216
227
|
runInNewContext: false,
|
|
217
228
|
testConfig: {
|
|
218
229
|
...testConfig,
|
|
219
|
-
moduleScope(ms, stats, options) {
|
|
230
|
+
moduleScope (ms, stats, options) {
|
|
220
231
|
const moduleScope = ms;
|
|
221
|
-
if (typeof testConfig.moduleScope
|
|
222
|
-
testConfig.moduleScope(moduleScope, stats, compilerOptions);
|
|
223
|
-
}
|
|
232
|
+
if ('function' == typeof testConfig.moduleScope) testConfig.moduleScope(moduleScope, stats, compilerOptions);
|
|
224
233
|
moduleScope.NEXT_HMR = nextHMR;
|
|
225
234
|
return moduleScope;
|
|
226
|
-
}
|
|
235
|
+
}
|
|
227
236
|
},
|
|
228
237
|
cachable: true,
|
|
229
238
|
source,
|
|
230
239
|
dist,
|
|
231
|
-
compilerOptions
|
|
240
|
+
compilerOptions
|
|
232
241
|
};
|
|
233
242
|
let runner;
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
...commonOptions,
|
|
239
|
-
});
|
|
240
|
-
}
|
|
241
|
-
else {
|
|
242
|
-
runner = new runner_1.NodeRunner(commonOptions);
|
|
243
|
-
}
|
|
243
|
+
runner = 'web' === compilerOptions.target || 'webworker' === compilerOptions.target ? new external_runner_index_js_namespaceObject.WebRunner({
|
|
244
|
+
location: testConfig.location || 'https://test.cases/path/index.html',
|
|
245
|
+
...commonOptions
|
|
246
|
+
}) : new external_runner_index_js_namespaceObject.NodeRunner(commonOptions);
|
|
244
247
|
return runner;
|
|
245
248
|
}
|
|
249
|
+
exports.createHotCase = __webpack_exports__.createHotCase;
|
|
250
|
+
exports.createHotProcessor = __webpack_exports__.createHotProcessor;
|
|
251
|
+
exports.createHotRunner = __webpack_exports__.createHotRunner;
|
|
252
|
+
for(var __rspack_i in __webpack_exports__)if (-1 === [
|
|
253
|
+
"createHotCase",
|
|
254
|
+
"createHotProcessor",
|
|
255
|
+
"createHotRunner"
|
|
256
|
+
].indexOf(__rspack_i)) exports[__rspack_i] = __webpack_exports__[__rspack_i];
|
|
257
|
+
Object.defineProperty(exports, '__esModule', {
|
|
258
|
+
value: true
|
|
259
|
+
});
|
package/dist/case/incremental.js
CHANGED
|
@@ -1,36 +1,70 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
2
|
+
var __webpack_require__ = {};
|
|
3
|
+
(()=>{
|
|
4
|
+
__webpack_require__.n = (module)=>{
|
|
5
|
+
var getter = module && module.__esModule ? ()=>module['default'] : ()=>module;
|
|
6
|
+
__webpack_require__.d(getter, {
|
|
7
|
+
a: getter
|
|
8
|
+
});
|
|
9
|
+
return getter;
|
|
10
|
+
};
|
|
11
|
+
})();
|
|
12
|
+
(()=>{
|
|
13
|
+
__webpack_require__.d = (exports1, definition)=>{
|
|
14
|
+
for(var key in definition)if (__webpack_require__.o(definition, key) && !__webpack_require__.o(exports1, key)) Object.defineProperty(exports1, key, {
|
|
15
|
+
enumerable: true,
|
|
16
|
+
get: definition[key]
|
|
17
|
+
});
|
|
18
|
+
};
|
|
19
|
+
})();
|
|
20
|
+
(()=>{
|
|
21
|
+
__webpack_require__.o = (obj, prop)=>Object.prototype.hasOwnProperty.call(obj, prop);
|
|
22
|
+
})();
|
|
23
|
+
(()=>{
|
|
24
|
+
__webpack_require__.r = (exports1)=>{
|
|
25
|
+
if ("u" > typeof Symbol && Symbol.toStringTag) Object.defineProperty(exports1, Symbol.toStringTag, {
|
|
26
|
+
value: 'Module'
|
|
27
|
+
});
|
|
28
|
+
Object.defineProperty(exports1, '__esModule', {
|
|
29
|
+
value: true
|
|
30
|
+
});
|
|
31
|
+
};
|
|
32
|
+
})();
|
|
33
|
+
var __webpack_exports__ = {};
|
|
34
|
+
__webpack_require__.r(__webpack_exports__);
|
|
35
|
+
__webpack_require__.d(__webpack_exports__, {
|
|
36
|
+
createHotIncrementalCase: ()=>createHotIncrementalCase,
|
|
37
|
+
createWatchIncrementalCase: ()=>createWatchIncrementalCase
|
|
38
|
+
});
|
|
39
|
+
const external_node_fs_namespaceObject = require("node:fs");
|
|
40
|
+
var external_node_fs_default = /*#__PURE__*/ __webpack_require__.n(external_node_fs_namespaceObject);
|
|
41
|
+
const external_node_path_namespaceObject = require("node:path");
|
|
42
|
+
var external_node_path_default = /*#__PURE__*/ __webpack_require__.n(external_node_path_namespaceObject);
|
|
43
|
+
const creator_js_namespaceObject = require("../test/creator.js");
|
|
44
|
+
const external_hot_js_namespaceObject = require("./hot.js");
|
|
45
|
+
const external_watch_js_namespaceObject = require("./watch.js");
|
|
13
46
|
const hotCreators = new Map();
|
|
14
47
|
function createHotIncrementalProcessor(name, src, temp, target, webpackCases) {
|
|
15
|
-
return (0,
|
|
48
|
+
return (0, external_hot_js_namespaceObject.createHotProcessor)(name, src, temp, target, true);
|
|
16
49
|
}
|
|
17
50
|
function getHotCreator(target, webpackCases) {
|
|
18
|
-
const key = JSON.stringify({
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
51
|
+
const key = JSON.stringify({
|
|
52
|
+
target,
|
|
53
|
+
webpackCases
|
|
54
|
+
});
|
|
55
|
+
if (!hotCreators.has(key)) hotCreators.set(key, new creator_js_namespaceObject.BasicCaseCreator({
|
|
56
|
+
clean: true,
|
|
57
|
+
describe: true,
|
|
58
|
+
target,
|
|
59
|
+
steps: ({ name, target, src, temp, dist })=>[
|
|
60
|
+
createHotIncrementalProcessor(name, src, temp || external_node_path_default().resolve(dist, 'temp'), target, webpackCases)
|
|
26
61
|
],
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
}
|
|
62
|
+
runner: {
|
|
63
|
+
key: (context, name, file)=>name,
|
|
64
|
+
runner: external_hot_js_namespaceObject.createHotRunner
|
|
65
|
+
},
|
|
66
|
+
concurrent: true
|
|
67
|
+
}));
|
|
34
68
|
return hotCreators.get(key);
|
|
35
69
|
}
|
|
36
70
|
function createHotIncrementalCase(name, src, dist, temp, target, webpackCases) {
|
|
@@ -40,40 +74,39 @@ function createHotIncrementalCase(name, src, dist, temp, target, webpackCases) {
|
|
|
40
74
|
const watchCreators = new Map();
|
|
41
75
|
function getWatchCreator(options) {
|
|
42
76
|
const key = JSON.stringify(options);
|
|
43
|
-
if (!watchCreators.has(key)) {
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
? (0, watch_1.createWatchInitialProcessor)(name, temp, run.name, watchState, {
|
|
65
|
-
incremental: true,
|
|
66
|
-
})
|
|
67
|
-
: (0, watch_1.createWatchStepProcessor)(name, temp, run.name, watchState, {
|
|
68
|
-
incremental: true,
|
|
69
|
-
}));
|
|
70
|
-
},
|
|
71
|
-
concurrent: true,
|
|
72
|
-
}));
|
|
73
|
-
}
|
|
77
|
+
if (!watchCreators.has(key)) watchCreators.set(key, new creator_js_namespaceObject.BasicCaseCreator({
|
|
78
|
+
clean: true,
|
|
79
|
+
runner: {
|
|
80
|
+
key: external_watch_js_namespaceObject.getWatchRunnerKey,
|
|
81
|
+
runner: external_watch_js_namespaceObject.createWatchRunner
|
|
82
|
+
},
|
|
83
|
+
description: (name, index)=>0 === index ? `${name} should compile` : `should compile step ${index}`,
|
|
84
|
+
describe: false,
|
|
85
|
+
steps: ({ name, src, temp })=>{
|
|
86
|
+
const watchState = {};
|
|
87
|
+
const runs = external_node_fs_default().readdirSync(src).sort().filter((name)=>external_node_fs_default().statSync(external_node_path_default().join(src, name)).isDirectory()).map((name)=>({
|
|
88
|
+
name
|
|
89
|
+
}));
|
|
90
|
+
return runs.map((run, index)=>0 === index ? (0, external_watch_js_namespaceObject.createWatchInitialProcessor)(name, temp, run.name, watchState, {
|
|
91
|
+
incremental: true
|
|
92
|
+
}) : (0, external_watch_js_namespaceObject.createWatchStepProcessor)(name, temp, run.name, watchState, {
|
|
93
|
+
incremental: true
|
|
94
|
+
}));
|
|
95
|
+
},
|
|
96
|
+
concurrent: true
|
|
97
|
+
}));
|
|
74
98
|
return watchCreators.get(key);
|
|
75
99
|
}
|
|
76
100
|
function createWatchIncrementalCase(name, src, dist, temp, options = {}) {
|
|
77
101
|
const creator = getWatchCreator(options);
|
|
78
102
|
creator.create(name, src, dist, temp);
|
|
79
103
|
}
|
|
104
|
+
exports.createHotIncrementalCase = __webpack_exports__.createHotIncrementalCase;
|
|
105
|
+
exports.createWatchIncrementalCase = __webpack_exports__.createWatchIncrementalCase;
|
|
106
|
+
for(var __rspack_i in __webpack_exports__)if (-1 === [
|
|
107
|
+
"createHotIncrementalCase",
|
|
108
|
+
"createWatchIncrementalCase"
|
|
109
|
+
].indexOf(__rspack_i)) exports[__rspack_i] = __webpack_exports__[__rspack_i];
|
|
110
|
+
Object.defineProperty(exports, '__esModule', {
|
|
111
|
+
value: true
|
|
112
|
+
});
|