@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/builtin.js
CHANGED
|
@@ -1,57 +1,88 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
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
|
+
createBuiltinCase: ()=>createBuiltinCase,
|
|
37
|
+
defaultOptions: ()=>builtin_defaultOptions
|
|
38
|
+
});
|
|
39
|
+
const external_node_path_namespaceObject = require("node:path");
|
|
40
|
+
var external_node_path_default = /*#__PURE__*/ __webpack_require__.n(external_node_path_namespaceObject);
|
|
41
|
+
const external_fs_extra_namespaceObject = require("fs-extra");
|
|
42
|
+
var external_fs_extra_default = /*#__PURE__*/ __webpack_require__.n(external_fs_extra_namespaceObject);
|
|
43
|
+
const external_rspack_merge_namespaceObject = require("rspack-merge");
|
|
44
|
+
const index_js_namespaceObject = require("../helper/index.js");
|
|
45
|
+
const creator_js_namespaceObject = require("../test/creator.js");
|
|
46
|
+
const external_common_js_namespaceObject = require("./common.js");
|
|
47
|
+
const creator = new creator_js_namespaceObject.BasicCaseCreator({
|
|
15
48
|
clean: true,
|
|
16
49
|
describe: false,
|
|
17
|
-
description(name) {
|
|
50
|
+
description (name) {
|
|
18
51
|
return `${name} should match snapshot`;
|
|
19
52
|
},
|
|
20
|
-
steps: ({ name, src })
|
|
21
|
-
const cat =
|
|
53
|
+
steps: ({ name, src })=>{
|
|
54
|
+
const cat = external_node_path_default().basename(external_node_path_default().dirname(src));
|
|
22
55
|
const filter = FILTERS[cat];
|
|
23
56
|
return [
|
|
24
57
|
{
|
|
25
|
-
config:
|
|
58
|
+
config: (context)=>{
|
|
26
59
|
const compiler = context.getCompiler();
|
|
27
|
-
compiler.setOptions(
|
|
60
|
+
compiler.setOptions(builtin_defaultOptions(context));
|
|
28
61
|
},
|
|
29
|
-
compiler: async (context)
|
|
30
|
-
await (0,
|
|
62
|
+
compiler: async (context)=>{
|
|
63
|
+
await (0, external_common_js_namespaceObject.compiler)(context, name);
|
|
31
64
|
},
|
|
32
|
-
build: async (context)
|
|
33
|
-
await (0,
|
|
65
|
+
build: async (context)=>{
|
|
66
|
+
await (0, external_common_js_namespaceObject.build)(context, name);
|
|
34
67
|
},
|
|
35
|
-
run: async (env, context)
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
},
|
|
41
|
-
},
|
|
68
|
+
run: async (env, context)=>{},
|
|
69
|
+
check: async (env, context)=>{
|
|
70
|
+
await (0, external_common_js_namespaceObject.checkSnapshot)(env, context, name, 'output.snap.txt', filter);
|
|
71
|
+
}
|
|
72
|
+
}
|
|
42
73
|
];
|
|
43
74
|
},
|
|
44
|
-
concurrent: true
|
|
75
|
+
concurrent: true
|
|
45
76
|
});
|
|
46
77
|
function createBuiltinCase(name, src, dist) {
|
|
47
78
|
creator.create(name, src, dist);
|
|
48
79
|
}
|
|
49
|
-
function
|
|
80
|
+
function builtin_defaultOptions(context) {
|
|
50
81
|
let defaultOptions = {
|
|
51
82
|
entry: {
|
|
52
83
|
main: {
|
|
53
|
-
import: './index'
|
|
54
|
-
}
|
|
84
|
+
import: './index'
|
|
85
|
+
}
|
|
55
86
|
},
|
|
56
87
|
output: {
|
|
57
88
|
publicPath: '/',
|
|
@@ -66,7 +97,9 @@ function defaultOptions(context) {
|
|
|
66
97
|
chunkLoadingGlobal: 'rspackChunk',
|
|
67
98
|
chunkLoading: 'jsonp',
|
|
68
99
|
uniqueName: '__rspack_test__',
|
|
69
|
-
enabledLibraryTypes: [
|
|
100
|
+
enabledLibraryTypes: [
|
|
101
|
+
'system'
|
|
102
|
+
],
|
|
70
103
|
strictModuleErrorHandling: false,
|
|
71
104
|
iife: true,
|
|
72
105
|
module: false,
|
|
@@ -76,48 +109,48 @@ function defaultOptions(context) {
|
|
|
76
109
|
importFunctionName: 'import',
|
|
77
110
|
wasmLoading: 'fetch',
|
|
78
111
|
webassemblyModuleFilename: '[hash].module.wasm',
|
|
79
|
-
workerChunkLoading:
|
|
112
|
+
workerChunkLoading: "import-scripts",
|
|
80
113
|
workerWasmLoading: 'fetch',
|
|
81
114
|
bundlerInfo: {
|
|
82
|
-
force: false
|
|
83
|
-
}
|
|
115
|
+
force: false
|
|
116
|
+
}
|
|
84
117
|
},
|
|
85
118
|
module: {
|
|
86
119
|
rules: [
|
|
87
120
|
{
|
|
88
121
|
test: /\.json$/,
|
|
89
|
-
type: 'json'
|
|
122
|
+
type: 'json'
|
|
90
123
|
},
|
|
91
124
|
{
|
|
92
125
|
test: /\.mjs$/,
|
|
93
|
-
type:
|
|
126
|
+
type: "javascript/esm"
|
|
94
127
|
},
|
|
95
128
|
{
|
|
96
129
|
test: /\.cjs$/,
|
|
97
|
-
type:
|
|
130
|
+
type: "javascript/dynamic"
|
|
98
131
|
},
|
|
99
132
|
{
|
|
100
133
|
test: /\.js$/,
|
|
101
|
-
type:
|
|
134
|
+
type: "javascript/auto"
|
|
102
135
|
},
|
|
103
136
|
{
|
|
104
137
|
test: /\.css$/,
|
|
105
|
-
type: 'css'
|
|
138
|
+
type: 'css'
|
|
106
139
|
},
|
|
107
140
|
{
|
|
108
141
|
test: /\.wasm$/,
|
|
109
|
-
type: 'webassembly/async'
|
|
110
|
-
}
|
|
111
|
-
]
|
|
142
|
+
type: 'webassembly/async'
|
|
143
|
+
}
|
|
144
|
+
]
|
|
112
145
|
},
|
|
113
146
|
node: {
|
|
114
147
|
__dirname: 'mock',
|
|
115
148
|
__filename: 'mock',
|
|
116
|
-
global: 'warn'
|
|
149
|
+
global: 'warn'
|
|
117
150
|
},
|
|
118
151
|
optimization: {
|
|
119
152
|
runtimeChunk: {
|
|
120
|
-
name: 'runtime'
|
|
153
|
+
name: 'runtime'
|
|
121
154
|
},
|
|
122
155
|
minimize: false,
|
|
123
156
|
removeEmptyChunks: true,
|
|
@@ -128,7 +161,7 @@ function defaultOptions(context) {
|
|
|
128
161
|
inlineExports: false,
|
|
129
162
|
usedExports: false,
|
|
130
163
|
concatenateModules: false,
|
|
131
|
-
nodeEnv: false
|
|
164
|
+
nodeEnv: false
|
|
132
165
|
},
|
|
133
166
|
resolve: {
|
|
134
167
|
extensions: [
|
|
@@ -139,36 +172,43 @@ function defaultOptions(context) {
|
|
|
139
172
|
'.json',
|
|
140
173
|
'.d.ts',
|
|
141
174
|
'.css',
|
|
142
|
-
'.wasm'
|
|
143
|
-
]
|
|
175
|
+
'.wasm'
|
|
176
|
+
]
|
|
144
177
|
},
|
|
145
178
|
resolveLoader: {
|
|
146
|
-
extensions: [
|
|
179
|
+
extensions: [
|
|
180
|
+
'.js'
|
|
181
|
+
]
|
|
147
182
|
},
|
|
148
183
|
experiments: {
|
|
149
|
-
futureDefaults: true
|
|
184
|
+
futureDefaults: true
|
|
150
185
|
},
|
|
151
186
|
devtool: false,
|
|
152
187
|
context: context.getSource(),
|
|
153
|
-
plugins: []
|
|
188
|
+
plugins: []
|
|
154
189
|
};
|
|
155
190
|
const testConfigFile = context.getSource('rspack.config.js');
|
|
156
|
-
if (
|
|
191
|
+
if (external_fs_extra_default().existsSync(testConfigFile)) {
|
|
157
192
|
const caseOptions = require(testConfigFile);
|
|
158
|
-
if (caseOptions.entry)
|
|
159
|
-
|
|
160
|
-
}
|
|
161
|
-
defaultOptions = (0, webpack_merge_1.merge)(defaultOptions, caseOptions);
|
|
162
|
-
}
|
|
163
|
-
if (!global.printLogger) {
|
|
164
|
-
defaultOptions.infrastructureLogging = {
|
|
165
|
-
level: 'error',
|
|
166
|
-
};
|
|
193
|
+
if (caseOptions.entry) delete defaultOptions.entry;
|
|
194
|
+
defaultOptions = (0, external_rspack_merge_namespaceObject.merge)(defaultOptions, caseOptions);
|
|
167
195
|
}
|
|
196
|
+
if (!global.printLogger) defaultOptions.infrastructureLogging = {
|
|
197
|
+
level: 'error'
|
|
198
|
+
};
|
|
168
199
|
return defaultOptions;
|
|
169
200
|
}
|
|
170
201
|
const FILTERS = {
|
|
171
|
-
'plugin-css': (file)
|
|
172
|
-
'plugin-css-modules': (file)
|
|
173
|
-
'plugin-html': (file)
|
|
202
|
+
'plugin-css': (file)=>file.endsWith('.css'),
|
|
203
|
+
'plugin-css-modules': (file)=>file.endsWith('.css') || (0, index_js_namespaceObject.isJavaScript)(file) && !file.includes('runtime'),
|
|
204
|
+
'plugin-html': (file)=>file.endsWith('.html')
|
|
174
205
|
};
|
|
206
|
+
exports.createBuiltinCase = __webpack_exports__.createBuiltinCase;
|
|
207
|
+
exports.defaultOptions = __webpack_exports__.defaultOptions;
|
|
208
|
+
for(var __rspack_i in __webpack_exports__)if (-1 === [
|
|
209
|
+
"createBuiltinCase",
|
|
210
|
+
"defaultOptions"
|
|
211
|
+
].indexOf(__rspack_i)) exports[__rspack_i] = __webpack_exports__[__rspack_i];
|
|
212
|
+
Object.defineProperty(exports, '__esModule', {
|
|
213
|
+
value: true
|
|
214
|
+
});
|
package/dist/case/cache.js
CHANGED
|
@@ -1,70 +1,102 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
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
|
+
createCacheCase: ()=>createCacheCase
|
|
37
|
+
});
|
|
38
|
+
const external_node_path_namespaceObject = require("node:path");
|
|
39
|
+
var external_node_path_default = /*#__PURE__*/ __webpack_require__.n(external_node_path_namespaceObject);
|
|
40
|
+
const core_namespaceObject = require("@rspack/core");
|
|
41
|
+
var core_default = /*#__PURE__*/ __webpack_require__.n(core_namespaceObject);
|
|
42
|
+
const index_js_namespaceObject = require("../helper/index.js");
|
|
43
|
+
const placeholder_js_namespaceObject = require("../helper/expect/placeholder.js");
|
|
44
|
+
const hot_update_index_js_namespaceObject = require("../helper/hot-update/index.js");
|
|
45
|
+
const checkArrayExpectation_js_namespaceObject = require("../helper/legacy/checkArrayExpectation.js");
|
|
46
|
+
const external_runner_index_js_namespaceObject = require("../runner/index.js");
|
|
47
|
+
const creator_js_namespaceObject = require("../test/creator.js");
|
|
48
|
+
const external_common_js_namespaceObject = require("./common.js");
|
|
49
|
+
const external_runner_js_namespaceObject = require("./runner.js");
|
|
16
50
|
function createCacheProcessor(name, src, temp, target) {
|
|
17
|
-
const updatePlugin = new
|
|
51
|
+
const updatePlugin = new hot_update_index_js_namespaceObject.HotUpdatePlugin(src, temp);
|
|
18
52
|
return {
|
|
19
|
-
before: async (context)
|
|
53
|
+
before: async (context)=>{
|
|
20
54
|
await updatePlugin.initialize();
|
|
21
55
|
context.setValue('hotUpdateContext', updatePlugin);
|
|
22
56
|
},
|
|
23
|
-
config: async (context)
|
|
57
|
+
config: async (context)=>{
|
|
24
58
|
const compiler = context.getCompiler();
|
|
25
59
|
const options = await generateOptions(context, temp, target, updatePlugin);
|
|
26
60
|
compiler.setOptions(options);
|
|
27
61
|
},
|
|
28
|
-
compiler: async (context)
|
|
29
|
-
await (0,
|
|
62
|
+
compiler: async (context)=>{
|
|
63
|
+
await (0, external_common_js_namespaceObject.compiler)(context, name);
|
|
30
64
|
},
|
|
31
|
-
build: async (context)
|
|
32
|
-
await (0,
|
|
65
|
+
build: async (context)=>{
|
|
66
|
+
await (0, external_common_js_namespaceObject.build)(context, name);
|
|
33
67
|
},
|
|
34
|
-
run: async (env, context)
|
|
35
|
-
await (0,
|
|
68
|
+
run: async (env, context)=>{
|
|
69
|
+
await (0, external_common_js_namespaceObject.run)(env, context, name, (context)=>findBundle(name, target, context));
|
|
36
70
|
},
|
|
37
|
-
check: async (env, context)
|
|
38
|
-
await (0,
|
|
71
|
+
check: async (env, context)=>{
|
|
72
|
+
await (0, external_common_js_namespaceObject.check)(env, context, name);
|
|
73
|
+
const stats = context.getCompiler().getStats();
|
|
74
|
+
if (stats) matchStatsSnapshot(env, context.getSource(), updatePlugin.getUpdateIndex(), stats);
|
|
39
75
|
},
|
|
40
|
-
after: async (context)
|
|
41
|
-
await (0,
|
|
76
|
+
after: async (context)=>{
|
|
77
|
+
await (0, external_common_js_namespaceObject.afterExecute)(context, name);
|
|
42
78
|
},
|
|
43
|
-
afterAll:
|
|
79
|
+
afterAll: (context)=>{
|
|
44
80
|
const updateIndex = updatePlugin.getUpdateIndex();
|
|
45
81
|
const totalUpdates = updatePlugin.getTotalUpdates();
|
|
46
|
-
if (updateIndex + 1 !== totalUpdates) {
|
|
47
|
-
|
|
48
|
-
}
|
|
49
|
-
},
|
|
82
|
+
if (updateIndex + 1 !== totalUpdates) throw new Error(`Should run all hot steps (${updateIndex + 1} / ${totalUpdates}): ${name}`);
|
|
83
|
+
}
|
|
50
84
|
};
|
|
51
85
|
}
|
|
52
86
|
function getCreator(target) {
|
|
53
|
-
if (!creators.has(target)) {
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
createCacheProcessor(name, src, temp, target),
|
|
87
|
+
if (!creators.has(target)) creators.set(target, new creator_js_namespaceObject.BasicCaseCreator({
|
|
88
|
+
clean: true,
|
|
89
|
+
describe: true,
|
|
90
|
+
target,
|
|
91
|
+
steps: ({ name, src, target, temp })=>[
|
|
92
|
+
createCacheProcessor(name, src, temp, target)
|
|
60
93
|
],
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
}
|
|
94
|
+
runner: {
|
|
95
|
+
key: (context, name, file)=>name,
|
|
96
|
+
runner: createRunner
|
|
97
|
+
},
|
|
98
|
+
concurrent: true
|
|
99
|
+
}));
|
|
68
100
|
return creators.get(target);
|
|
69
101
|
}
|
|
70
102
|
function createCacheCase(name, src, dist, target, temp) {
|
|
@@ -72,6 +104,15 @@ function createCacheCase(name, src, dist, target, temp) {
|
|
|
72
104
|
creator.create(name, src, dist, temp);
|
|
73
105
|
}
|
|
74
106
|
const creators = new Map();
|
|
107
|
+
function matchStatsSnapshot(env, source, updateIndex, stats) {
|
|
108
|
+
const content = (0, placeholder_js_namespaceObject.normalizePlaceholder)(stats.toString({
|
|
109
|
+
all: false,
|
|
110
|
+
logging: 'info',
|
|
111
|
+
colors: false
|
|
112
|
+
})).trim();
|
|
113
|
+
if (!content.includes('rspack.persistentCache')) return;
|
|
114
|
+
env.expect(content).toMatchFileSnapshotSync(external_node_path_default().resolve(source, '__snapshots__', `stats-${updateIndex}.txt`));
|
|
115
|
+
}
|
|
75
116
|
async function generateOptions(context, temp, target, updatePlugin) {
|
|
76
117
|
let options = {
|
|
77
118
|
context: temp,
|
|
@@ -82,70 +123,65 @@ async function generateOptions(context, temp, target, updatePlugin) {
|
|
|
82
123
|
filename: 'bundle.js',
|
|
83
124
|
chunkFilename: '[name].chunk.[fullhash].js',
|
|
84
125
|
publicPath: 'https://test.cases/path/',
|
|
85
|
-
library: {
|
|
86
|
-
|
|
87
|
-
force: false,
|
|
126
|
+
library: {
|
|
127
|
+
type: 'commonjs2'
|
|
88
128
|
},
|
|
129
|
+
bundlerInfo: {
|
|
130
|
+
force: false
|
|
131
|
+
}
|
|
89
132
|
},
|
|
90
133
|
optimization: {
|
|
91
134
|
moduleIds: 'named',
|
|
92
|
-
emitOnErrors: true
|
|
135
|
+
emitOnErrors: true
|
|
93
136
|
},
|
|
94
|
-
target
|
|
137
|
+
target
|
|
95
138
|
};
|
|
96
139
|
options.plugins ??= [];
|
|
97
|
-
options.plugins.push(new
|
|
98
|
-
options = await (0,
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
// rewrite context to temp dir
|
|
140
|
+
options.plugins.push(new (core_default()).HotModuleReplacementPlugin());
|
|
141
|
+
options = await (0, external_common_js_namespaceObject.config)(context, 'cacheCase', [
|
|
142
|
+
'rspack.config.js',
|
|
143
|
+
'webpack.config.js'
|
|
144
|
+
].map((i)=>external_node_path_default().resolve(temp, i)), options);
|
|
145
|
+
if (!options.entry) options.entry = './index.js';
|
|
104
146
|
options.context = temp;
|
|
105
147
|
options.module ??= {};
|
|
106
|
-
for (const cssModuleType of [
|
|
148
|
+
for (const cssModuleType of [
|
|
149
|
+
'css/auto',
|
|
150
|
+
'css/module',
|
|
151
|
+
'css'
|
|
152
|
+
]){
|
|
107
153
|
options.module.generator ??= {};
|
|
108
154
|
options.module.generator[cssModuleType] ??= {};
|
|
109
|
-
options.module.generator[cssModuleType].exportsOnly ??=
|
|
110
|
-
target === 'async-node';
|
|
155
|
+
options.module.generator[cssModuleType].exportsOnly ??= 'async-node' === target;
|
|
111
156
|
}
|
|
112
157
|
options.plugins ??= [];
|
|
113
158
|
options.plugins.push(updatePlugin);
|
|
114
|
-
if (!global.printLogger) {
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
};
|
|
118
|
-
}
|
|
159
|
+
if (!global.printLogger) options.infrastructureLogging = {
|
|
160
|
+
level: 'error'
|
|
161
|
+
};
|
|
119
162
|
return options;
|
|
120
163
|
}
|
|
121
164
|
function findBundle(name, target, context) {
|
|
122
165
|
const files = [];
|
|
123
166
|
const prefiles = [];
|
|
124
167
|
const compiler = context.getCompiler();
|
|
125
|
-
if (!compiler)
|
|
126
|
-
throw new Error('Compiler should exists when find bundle');
|
|
168
|
+
if (!compiler) throw new Error('Compiler should exists when find bundle');
|
|
127
169
|
const stats = compiler.getStats();
|
|
128
|
-
if (!stats)
|
|
129
|
-
throw new Error('Stats should exists when find bundle');
|
|
170
|
+
if (!stats) throw new Error('Stats should exists when find bundle');
|
|
130
171
|
const info = stats.toJson({
|
|
131
172
|
all: false,
|
|
132
|
-
entrypoints: true
|
|
173
|
+
entrypoints: true
|
|
133
174
|
});
|
|
134
|
-
if (
|
|
135
|
-
|
|
136
|
-
if ((0, helper_1.isJavaScript)(file.name)) {
|
|
137
|
-
files.push(file.name);
|
|
138
|
-
}
|
|
139
|
-
else {
|
|
140
|
-
prefiles.push(file.name);
|
|
141
|
-
}
|
|
142
|
-
}
|
|
143
|
-
}
|
|
175
|
+
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);
|
|
176
|
+
else prefiles.push(file.name);
|
|
144
177
|
else {
|
|
145
|
-
const assets = info.entrypoints.main.assets.filter((s)
|
|
178
|
+
const assets = info.entrypoints.main.assets.filter((s)=>(0, index_js_namespaceObject.isJavaScript)(s.name));
|
|
146
179
|
files.push(assets[assets.length - 1].name);
|
|
147
180
|
}
|
|
148
|
-
return [
|
|
181
|
+
return [
|
|
182
|
+
...prefiles,
|
|
183
|
+
...files
|
|
184
|
+
];
|
|
149
185
|
}
|
|
150
186
|
function createRunner(context, name, file, env) {
|
|
151
187
|
const compiler = context.getCompiler();
|
|
@@ -155,76 +191,62 @@ function createRunner(context, name, file, env) {
|
|
|
155
191
|
const source = context.getSource();
|
|
156
192
|
const dist = context.getDist();
|
|
157
193
|
const updatePlugin = context.getValue('hotUpdateContext');
|
|
158
|
-
const getWebRunner = ()
|
|
159
|
-
return new runner_1.NodeRunner({
|
|
194
|
+
const getWebRunner = ()=>new external_runner_index_js_namespaceObject.NodeRunner({
|
|
160
195
|
env,
|
|
161
|
-
stats: (0,
|
|
196
|
+
stats: (0, external_runner_js_namespaceObject.cachedStats)(context, name),
|
|
162
197
|
cachable: false,
|
|
163
198
|
name: name,
|
|
164
199
|
runInNewContext: false,
|
|
165
200
|
testConfig: {
|
|
166
201
|
...testConfig,
|
|
167
|
-
moduleScope(ms, stats, options) {
|
|
168
|
-
const moduleScope = typeof testConfig.moduleScope
|
|
169
|
-
? testConfig.moduleScope(ms, stats, options)
|
|
170
|
-
: ms;
|
|
202
|
+
moduleScope (ms, stats, options) {
|
|
203
|
+
const moduleScope = 'function' == typeof testConfig.moduleScope ? testConfig.moduleScope(ms, stats, options) : ms;
|
|
171
204
|
moduleScope.COMPILER_INDEX = compilerIndex;
|
|
172
205
|
moduleScope.NEXT_HMR = nextHmr;
|
|
173
206
|
moduleScope.NEXT_START = nextStart;
|
|
174
207
|
moduleScope.NEXT_MOVE_DIR_START = nextMoveDirStart;
|
|
175
208
|
return moduleScope;
|
|
176
|
-
}
|
|
209
|
+
}
|
|
177
210
|
},
|
|
178
211
|
source,
|
|
179
212
|
dist,
|
|
180
|
-
compilerOptions: options
|
|
213
|
+
compilerOptions: options
|
|
181
214
|
});
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
const compilerOptions = compiler.getOptions();
|
|
185
|
-
const updateIndex = updatePlugin.getUpdateIndex();
|
|
186
|
-
await (0, checkArrayExpectation_1.default)(source, stats, 'error', `errors${updateIndex}`, 'Error', compilerOptions);
|
|
187
|
-
await (0, checkArrayExpectation_1.default)(source, stats, 'warning', `warnings${updateIndex}`, 'Warning', compilerOptions);
|
|
188
|
-
};
|
|
189
|
-
const nextHmr = async (m, options) => {
|
|
190
|
-
await updatePlugin.goNext();
|
|
191
|
-
const stats = await compiler.build();
|
|
215
|
+
const checkStats = async (stats)=>{
|
|
216
|
+
matchStatsSnapshot(env, source, updatePlugin.getUpdateIndex(), stats);
|
|
192
217
|
const jsonStats = stats.toJson({
|
|
193
218
|
assets: true,
|
|
194
219
|
chunks: true,
|
|
195
220
|
chunkModules: true,
|
|
196
221
|
modules: true,
|
|
197
222
|
entrypoints: true,
|
|
198
|
-
chunkGroups: true
|
|
199
|
-
// errorDetails: true
|
|
223
|
+
chunkGroups: true
|
|
200
224
|
});
|
|
201
|
-
|
|
225
|
+
const compilerOptions = compiler.getOptions();
|
|
226
|
+
const updateIndex = updatePlugin.getUpdateIndex();
|
|
227
|
+
await (0, checkArrayExpectation_js_namespaceObject.checkArrayExpectation)(source, jsonStats, 'error', `errors${updateIndex}`, 'Error', compilerOptions);
|
|
228
|
+
await (0, checkArrayExpectation_js_namespaceObject.checkArrayExpectation)(source, jsonStats, 'warning', `warnings${updateIndex}`, 'Warning', compilerOptions);
|
|
229
|
+
return jsonStats;
|
|
230
|
+
};
|
|
231
|
+
const nextHmr = async (m, options)=>{
|
|
232
|
+
await updatePlugin.goNext();
|
|
233
|
+
const stats = await compiler.build();
|
|
234
|
+
const jsonStats = await checkStats(stats);
|
|
202
235
|
const updatedModules = await m.hot.check(options || true);
|
|
203
|
-
if (!updatedModules)
|
|
204
|
-
throw new Error('No update available');
|
|
205
|
-
}
|
|
236
|
+
if (!updatedModules) throw new Error('No update available');
|
|
206
237
|
return jsonStats;
|
|
207
238
|
};
|
|
208
|
-
const nextStart = async ()
|
|
239
|
+
const nextStart = async ()=>{
|
|
209
240
|
await compiler.close();
|
|
210
241
|
await updatePlugin.goNext();
|
|
211
242
|
compilerIndex++;
|
|
212
243
|
compiler.createCompiler();
|
|
213
244
|
const stats = await compiler.build();
|
|
214
|
-
const jsonStats = stats
|
|
215
|
-
|
|
216
|
-
chunks: true,
|
|
217
|
-
entrypoints: true,
|
|
218
|
-
chunkGroups: true,
|
|
219
|
-
// errorDetails: true
|
|
220
|
-
});
|
|
221
|
-
await checkStats(jsonStats);
|
|
222
|
-
env.it(`NEXT_START run with compilerIndex==${compilerIndex}`, async () => {
|
|
223
|
-
return getWebRunner().run(file);
|
|
224
|
-
});
|
|
245
|
+
const jsonStats = await checkStats(stats);
|
|
246
|
+
env.it(`NEXT_START run with compilerIndex==${compilerIndex}`, async ()=>getWebRunner().run(file));
|
|
225
247
|
return jsonStats;
|
|
226
248
|
};
|
|
227
|
-
const nextMoveDirStart = async ()
|
|
249
|
+
const nextMoveDirStart = async ()=>{
|
|
228
250
|
await compiler.close();
|
|
229
251
|
const tempDir = await updatePlugin.moveTempDir();
|
|
230
252
|
const options = await generateOptions(context, tempDir, compiler.getOptions().target, updatePlugin);
|
|
@@ -233,18 +255,16 @@ function createRunner(context, name, file, env) {
|
|
|
233
255
|
compilerIndex++;
|
|
234
256
|
compiler.createCompiler();
|
|
235
257
|
const stats = await compiler.build();
|
|
236
|
-
const jsonStats = stats
|
|
237
|
-
|
|
238
|
-
chunks: true,
|
|
239
|
-
entrypoints: true,
|
|
240
|
-
chunkGroups: true,
|
|
241
|
-
// errorDetails: true
|
|
242
|
-
});
|
|
243
|
-
await checkStats(jsonStats);
|
|
244
|
-
env.it(`NEXT_MOVE_DIR_START run with compilerIndex==${compilerIndex}`, async () => {
|
|
245
|
-
return getWebRunner().run(file);
|
|
246
|
-
});
|
|
258
|
+
const jsonStats = await checkStats(stats);
|
|
259
|
+
env.it(`NEXT_MOVE_DIR_START run with compilerIndex==${compilerIndex}`, async ()=>getWebRunner().run(file));
|
|
247
260
|
return jsonStats;
|
|
248
261
|
};
|
|
249
262
|
return getWebRunner();
|
|
250
263
|
}
|
|
264
|
+
exports.createCacheCase = __webpack_exports__.createCacheCase;
|
|
265
|
+
for(var __rspack_i in __webpack_exports__)if (-1 === [
|
|
266
|
+
"createCacheCase"
|
|
267
|
+
].indexOf(__rspack_i)) exports[__rspack_i] = __webpack_exports__[__rspack_i];
|
|
268
|
+
Object.defineProperty(exports, '__esModule', {
|
|
269
|
+
value: true
|
|
270
|
+
});
|