@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-step.js
CHANGED
|
@@ -1,20 +1,53 @@
|
|
|
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
|
+
createHotStepCase: ()=>createHotStepCase
|
|
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 external_fs_extra_namespaceObject = require("fs-extra");
|
|
41
|
+
var external_fs_extra_default = /*#__PURE__*/ __webpack_require__.n(external_fs_extra_namespaceObject);
|
|
42
|
+
const index_js_namespaceObject = require("../helper/index.js");
|
|
43
|
+
const placeholder_js_namespaceObject = require("../helper/expect/placeholder.js");
|
|
44
|
+
const creator_js_namespaceObject = require("../test/creator.js");
|
|
45
|
+
const external_hot_js_namespaceObject = require("./hot.js");
|
|
13
46
|
const NOOP_SET = new Set();
|
|
14
|
-
const escapeLocalName = (str)
|
|
15
|
-
const SELF_HANDLER = (file, options)
|
|
47
|
+
const escapeLocalName = (str)=>str.split(/[-<>:"/|?*.]/).join('_');
|
|
48
|
+
const SELF_HANDLER = (file, options)=>{
|
|
16
49
|
let res = [];
|
|
17
|
-
const hotUpdateGlobal = (_, modules)
|
|
50
|
+
const hotUpdateGlobal = (_, modules)=>{
|
|
18
51
|
res = Object.keys(modules);
|
|
19
52
|
};
|
|
20
53
|
const hotUpdateGlobalKey = escapeLocalName(`${options.output?.hotUpdateGlobal || 'rspackHotUpdate'}${options.output?.uniqueName || ''}`);
|
|
@@ -24,18 +57,16 @@ const SELF_HANDLER = (file, options) => {
|
|
|
24
57
|
delete global.self[hotUpdateGlobalKey];
|
|
25
58
|
return res;
|
|
26
59
|
};
|
|
27
|
-
const NODE_HANDLER = (file)
|
|
28
|
-
return Object.keys(require(file).modules) || [];
|
|
29
|
-
};
|
|
60
|
+
const NODE_HANDLER = (file)=>Object.keys(require(file).modules) || [];
|
|
30
61
|
const GET_MODULE_HANDLER = {
|
|
31
62
|
web: SELF_HANDLER,
|
|
32
63
|
webworker: SELF_HANDLER,
|
|
33
64
|
'async-node': NODE_HANDLER,
|
|
34
|
-
node: NODE_HANDLER
|
|
65
|
+
node: NODE_HANDLER
|
|
35
66
|
};
|
|
36
67
|
const creators = new Map();
|
|
37
68
|
function createHotStepProcessor(name, src, temp, target) {
|
|
38
|
-
const processor = (0,
|
|
69
|
+
const processor = (0, external_hot_js_namespaceObject.createHotProcessor)(name, src, temp, target);
|
|
39
70
|
const entries = {};
|
|
40
71
|
const hashes = [];
|
|
41
72
|
function matchStepSnapshot(env, context, step, options, stats, runtime) {
|
|
@@ -43,78 +74,47 @@ function createHotStepProcessor(name, src, temp, target) {
|
|
|
43
74
|
env.expect(typeof getModuleHandler).toBe('function');
|
|
44
75
|
const lastHash = hashes[hashes.length - 1];
|
|
45
76
|
const snapshotPath = context.getSource(`__snapshots__/${options.target}/${step}.snap.txt`);
|
|
46
|
-
const title = `Case ${
|
|
77
|
+
const title = `Case ${external_node_path_default().basename(name)}: Step ${step}`;
|
|
47
78
|
const hotUpdateFile = [];
|
|
48
79
|
const hotUpdateManifest = [];
|
|
49
|
-
const changedFiles =
|
|
50
|
-
? []
|
|
51
|
-
: processor.updatePlugin
|
|
52
|
-
.getModifiedFiles()
|
|
53
|
-
.map((i) => (0, helper_1.escapeSep)(node_path_1.default.relative(temp, i)));
|
|
80
|
+
const changedFiles = 0 === step ? [] : processor.updatePlugin.getModifiedFiles().map((i)=>(0, index_js_namespaceObject.escapeSep)(external_node_path_default().relative(temp, i)));
|
|
54
81
|
changedFiles.sort();
|
|
55
82
|
const resultHashes = {
|
|
56
83
|
[lastHash || 'LAST_HASH']: 'LAST_HASH',
|
|
57
|
-
[stats.hash]: 'CURRENT_HASH'
|
|
84
|
+
[stats.hash]: 'CURRENT_HASH'
|
|
58
85
|
};
|
|
59
|
-
// TODO: find a better way
|
|
60
|
-
// replace [runtime] to [runtime of id] to prevent worker hash
|
|
61
86
|
const runtimes = {};
|
|
62
|
-
for (const [id, runtime] of Object.entries(entries)) {
|
|
63
|
-
if (
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
}
|
|
67
|
-
}
|
|
68
|
-
else if (Array.isArray(runtime)) {
|
|
69
|
-
for (const r of runtime) {
|
|
70
|
-
if (r !== id) {
|
|
71
|
-
runtimes[r] = `[runtime of ${id}]`;
|
|
72
|
-
}
|
|
73
|
-
}
|
|
74
|
-
}
|
|
87
|
+
for (const [id, runtime] of Object.entries(entries))if ('string' == typeof runtime) {
|
|
88
|
+
if (runtime !== id) runtimes[runtime] = `[runtime of ${id}]`;
|
|
89
|
+
} else if (Array.isArray(runtime)) {
|
|
90
|
+
for (const r of runtime)if (r !== id) runtimes[r] = `[runtime of ${id}]`;
|
|
75
91
|
}
|
|
76
|
-
const replaceContent = (rawStr)
|
|
92
|
+
const replaceContent = (rawStr)=>{
|
|
77
93
|
let str = rawStr;
|
|
78
94
|
const replaceContentConfig = context.getTestConfig().snapshotContent;
|
|
79
|
-
if (replaceContentConfig)
|
|
80
|
-
|
|
81
|
-
}
|
|
82
|
-
return (0, placeholder_1.normalizePlaceholder)(Object.entries(resultHashes)
|
|
83
|
-
.reduce((str, [raw, replacement]) => {
|
|
84
|
-
return str.split(raw).join(replacement);
|
|
85
|
-
}, str)
|
|
86
|
-
.replace(/\/\/ (\d+)\s+(?=var cssReload)/, '')
|
|
87
|
-
.replaceAll(/var data = "(?:.*)"/g, (match) => {
|
|
88
|
-
return decodeURIComponent(match).replaceAll(/\\/g, '/');
|
|
89
|
-
}));
|
|
95
|
+
if (replaceContentConfig) str = replaceContentConfig(str);
|
|
96
|
+
return (0, placeholder_js_namespaceObject.normalizePlaceholder)(Object.entries(resultHashes).reduce((str, [raw, replacement])=>str.split(raw).join(replacement), str).replace(/\/\/ (\d+)\s+(?=var cssReload)/, '').replaceAll(/var data = "(?:.*)"/g, (match)=>decodeURIComponent(match).replaceAll(/\\/g, '/')));
|
|
90
97
|
};
|
|
91
|
-
const replaceFileName = (str)
|
|
92
|
-
return Object.entries({
|
|
98
|
+
const replaceFileName = (str)=>Object.entries({
|
|
93
99
|
...resultHashes,
|
|
94
|
-
...runtimes
|
|
95
|
-
}).reduce((str, [raw, replacement])
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
};
|
|
99
|
-
const assets = stats.assets.sort((a, b) => a.name.localeCompare(b.name));
|
|
100
|
-
const fileList = assets
|
|
101
|
-
.map((i) => {
|
|
100
|
+
...runtimes
|
|
101
|
+
}).reduce((str, [raw, replacement])=>str.split(raw).join(replacement), str);
|
|
102
|
+
const assets = stats.assets.sort((a, b)=>a.name.localeCompare(b.name));
|
|
103
|
+
const fileList = assets.map((i)=>{
|
|
102
104
|
const fileName = i.name;
|
|
103
105
|
const renderName = replaceFileName(fileName);
|
|
104
|
-
const content = replaceContent(
|
|
106
|
+
const content = replaceContent(external_fs_extra_default().readFileSync(context.getDist(fileName), 'utf-8'));
|
|
105
107
|
if (fileName.endsWith('hot-update.js')) {
|
|
106
108
|
const modules = getModuleHandler(context.getDist(fileName), options);
|
|
107
109
|
const runtime = [];
|
|
108
|
-
for (const i of content.matchAll(/\/\/ (webpack\/runtime\/[\w_-]+)\s*\n/g))
|
|
109
|
-
runtime.push(i[1]);
|
|
110
|
-
}
|
|
110
|
+
for (const i of content.matchAll(/\/\/ (webpack\/runtime\/[\w_-]+)\s*\n/g))runtime.push(i[1]);
|
|
111
111
|
modules.sort();
|
|
112
112
|
runtime.sort();
|
|
113
113
|
hotUpdateFile.push({
|
|
114
114
|
name: renderName,
|
|
115
115
|
content,
|
|
116
116
|
modules,
|
|
117
|
-
runtime
|
|
117
|
+
runtime
|
|
118
118
|
});
|
|
119
119
|
return `- Update: ${renderName}, size: ${content.length}`;
|
|
120
120
|
}
|
|
@@ -125,70 +125,60 @@ function createHotStepProcessor(name, src, temp, target) {
|
|
|
125
125
|
manifest.m?.sort();
|
|
126
126
|
hotUpdateManifest.push({
|
|
127
127
|
name: renderName,
|
|
128
|
-
content: JSON.stringify(manifest)
|
|
128
|
+
content: JSON.stringify(manifest)
|
|
129
129
|
});
|
|
130
130
|
return `- Manifest: ${renderName}, size: ${i.size}`;
|
|
131
131
|
}
|
|
132
|
-
if (fileName.endsWith('.js')) {
|
|
133
|
-
|
|
134
|
-
}
|
|
135
|
-
})
|
|
136
|
-
.filter(Boolean);
|
|
132
|
+
if (fileName.endsWith('.js')) return `- Bundle: ${renderName}`;
|
|
133
|
+
}).filter(Boolean);
|
|
137
134
|
fileList.sort();
|
|
138
|
-
hotUpdateManifest.sort((a, b)
|
|
139
|
-
hotUpdateFile.sort((a, b)
|
|
135
|
+
hotUpdateManifest.sort((a, b)=>a.name > b.name ? 1 : -1);
|
|
136
|
+
hotUpdateFile.sort((a, b)=>a.name > b.name ? 1 : -1);
|
|
140
137
|
if (runtime?.javascript) {
|
|
141
138
|
runtime.javascript.outdatedModules.sort();
|
|
142
139
|
runtime.javascript.updatedModules.sort();
|
|
143
140
|
runtime.javascript.updatedRuntime.sort();
|
|
144
141
|
runtime.javascript.acceptedModules.sort();
|
|
145
142
|
runtime.javascript.disposedModules.sort();
|
|
146
|
-
for (const value of Object.values(runtime.javascript.outdatedDependencies))
|
|
147
|
-
value.sort();
|
|
148
|
-
}
|
|
143
|
+
for (const value of Object.values(runtime.javascript.outdatedDependencies))value.sort();
|
|
149
144
|
}
|
|
150
145
|
const content = `
|
|
151
146
|
# ${title}
|
|
152
147
|
|
|
153
148
|
## Changed Files
|
|
154
|
-
${changedFiles.map((i)
|
|
149
|
+
${changedFiles.map((i)=>`- ${i}`).join('\n')}
|
|
155
150
|
|
|
156
151
|
## Asset Files
|
|
157
152
|
${fileList.join('\n')}
|
|
158
153
|
|
|
159
154
|
## Manifest
|
|
160
|
-
${hotUpdateManifest
|
|
161
|
-
.map((i) => `
|
|
155
|
+
${hotUpdateManifest.map((i)=>`
|
|
162
156
|
### ${i.name}
|
|
163
157
|
|
|
164
158
|
\`\`\`json
|
|
165
159
|
${i.content}
|
|
166
160
|
\`\`\`
|
|
167
|
-
`)
|
|
168
|
-
.join('\n\n')}
|
|
161
|
+
`).join('\n\n')}
|
|
169
162
|
|
|
170
163
|
## Update
|
|
171
164
|
|
|
172
|
-
${hotUpdateFile
|
|
173
|
-
.map((i) => `
|
|
165
|
+
${hotUpdateFile.map((i)=>`
|
|
174
166
|
### ${i.name}
|
|
175
167
|
|
|
176
168
|
#### Changed Modules
|
|
177
|
-
${i.modules.map((i)
|
|
169
|
+
${i.modules.map((i)=>`- ${i}`).join('\n')}
|
|
178
170
|
|
|
179
171
|
#### Changed Runtime Modules
|
|
180
|
-
${i.runtime.map((i)
|
|
172
|
+
${i.runtime.map((i)=>`- ${i}`).join('\n')}
|
|
181
173
|
|
|
182
174
|
#### Changed Content
|
|
183
175
|
\`\`\`js
|
|
184
176
|
${i.content}
|
|
185
177
|
\`\`\`
|
|
186
|
-
`)
|
|
187
|
-
.join('\n\n')}
|
|
178
|
+
`).join('\n\n')}
|
|
188
179
|
|
|
189
180
|
|
|
190
|
-
${runtime
|
|
191
|
-
? `
|
|
181
|
+
${runtime ? `
|
|
192
182
|
## Runtime
|
|
193
183
|
### Status
|
|
194
184
|
|
|
@@ -196,15 +186,14 @@ ${runtime
|
|
|
196
186
|
${runtime.statusPath.join(' => ')}
|
|
197
187
|
\`\`\`
|
|
198
188
|
|
|
199
|
-
${runtime.javascript
|
|
200
|
-
? `
|
|
189
|
+
${runtime.javascript ? `
|
|
201
190
|
|
|
202
191
|
### JavaScript
|
|
203
192
|
|
|
204
193
|
#### Outdated
|
|
205
194
|
|
|
206
195
|
Outdated Modules:
|
|
207
|
-
${runtime.javascript.outdatedModules.map((i)
|
|
196
|
+
${runtime.javascript.outdatedModules.map((i)=>`- ${i}`).join('\n')}
|
|
208
197
|
|
|
209
198
|
|
|
210
199
|
Outdated Dependencies:
|
|
@@ -215,114 +204,94 @@ ${JSON.stringify(runtime.javascript.outdatedDependencies || {}, null, 2)}
|
|
|
215
204
|
#### Updated
|
|
216
205
|
|
|
217
206
|
Updated Modules:
|
|
218
|
-
${runtime.javascript.updatedModules.map((i)
|
|
207
|
+
${runtime.javascript.updatedModules.map((i)=>`- ${i}`).join('\n')}
|
|
219
208
|
|
|
220
209
|
Updated Runtime:
|
|
221
|
-
${runtime.javascript.updatedRuntime.map((i)
|
|
210
|
+
${runtime.javascript.updatedRuntime.map((i)=>`- \`${i}\``).join('\n')}
|
|
222
211
|
|
|
223
212
|
|
|
224
213
|
#### Callback
|
|
225
214
|
|
|
226
215
|
Accepted Callback:
|
|
227
|
-
${runtime.javascript.acceptedModules.map((i)
|
|
216
|
+
${runtime.javascript.acceptedModules.map((i)=>`- ${i}`).join('\n')}
|
|
228
217
|
|
|
229
218
|
Disposed Callback:
|
|
230
|
-
${runtime.javascript.disposedModules.map((i)
|
|
231
|
-
`
|
|
232
|
-
: ''}
|
|
219
|
+
${runtime.javascript.disposedModules.map((i)=>`- ${i}`).join('\n')}
|
|
220
|
+
` : ''}
|
|
233
221
|
|
|
234
|
-
`
|
|
235
|
-
: ''}
|
|
222
|
+
` : ''}
|
|
236
223
|
|
|
237
|
-
|
|
238
|
-
.replaceAll(/%3A(\d+)%2F/g, (match, capture) => {
|
|
239
|
-
return match.replace(capture, 'PORT');
|
|
240
|
-
})
|
|
241
|
-
.trim();
|
|
224
|
+
`.replaceAll(/%3A(\d+)%2F/g, (match, capture)=>match.replace(capture, 'PORT')).trim();
|
|
242
225
|
env.expect(content).toMatchFileSnapshotSync(snapshotPath);
|
|
243
226
|
}
|
|
244
227
|
const originRun = processor.run;
|
|
245
|
-
processor.run = async function
|
|
246
|
-
context.setValue('hotUpdateStepChecker', (updateIndex, stats, runtime)
|
|
228
|
+
processor.run = async function(env, context) {
|
|
229
|
+
context.setValue('hotUpdateStepChecker', (updateIndex, stats, runtime)=>{
|
|
247
230
|
const statsJson = stats.toJson({
|
|
248
231
|
assets: true,
|
|
249
|
-
chunks: true
|
|
232
|
+
chunks: true
|
|
250
233
|
});
|
|
251
|
-
const chunks = Array.from(
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
if (!entries[entry.id] && entry.runtime) {
|
|
256
|
-
entries[entry.id] =
|
|
257
|
-
// Webpack uses `string | SortableSet<string>` for `entry.runtime`
|
|
258
|
-
typeof entry.runtime === 'string'
|
|
259
|
-
? [entry.runtime]
|
|
260
|
-
: Array.from(entry.runtime);
|
|
261
|
-
}
|
|
262
|
-
}
|
|
234
|
+
const chunks = Array.from(stats?.compilation.chunks || NOOP_SET);
|
|
235
|
+
for (const entry of chunks.filter((i)=>i.hasRuntime()))if (!entries[entry.id] && entry.runtime) entries[entry.id] = 'string' == typeof entry.runtime ? [
|
|
236
|
+
entry.runtime
|
|
237
|
+
] : Array.from(entry.runtime);
|
|
263
238
|
const compiler = context.getCompiler();
|
|
264
239
|
const compilerOptions = compiler.getOptions();
|
|
265
240
|
matchStepSnapshot(env, context, updateIndex, compilerOptions, statsJson, runtime);
|
|
266
241
|
hashes.push(stats.hash);
|
|
267
242
|
});
|
|
268
|
-
context.setValue('hotUpdateStepErrorChecker', (updateIndex, stats, runtime)
|
|
243
|
+
context.setValue('hotUpdateStepErrorChecker', (updateIndex, stats, runtime)=>{
|
|
269
244
|
hashes.push(stats.hash);
|
|
270
245
|
});
|
|
271
246
|
await originRun(env, context);
|
|
272
247
|
};
|
|
273
|
-
processor.check =
|
|
248
|
+
processor.check = function(env, context) {
|
|
274
249
|
const compiler = context.getCompiler();
|
|
275
250
|
const stats = compiler.getStats();
|
|
276
|
-
if (!stats || !stats.hash)
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
const chunks = Array.from(
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
if (entry.runtime) {
|
|
286
|
-
entries[entry.id] =
|
|
287
|
-
// Webpack uses `string | SortableSet<string>` for `entry.runtime`
|
|
288
|
-
typeof entry.runtime === 'string'
|
|
289
|
-
? [entry.runtime]
|
|
290
|
-
: Array.from(entry.runtime);
|
|
291
|
-
}
|
|
292
|
-
}
|
|
251
|
+
if (!stats || !stats.hash) return void env.expect(false);
|
|
252
|
+
const statsJson = stats.toJson({
|
|
253
|
+
assets: true,
|
|
254
|
+
chunks: true
|
|
255
|
+
});
|
|
256
|
+
const chunks = Array.from(stats?.compilation.chunks || NOOP_SET);
|
|
257
|
+
for (const entry of chunks.filter((i)=>i.hasRuntime()))if (entry.runtime) entries[entry.id] = 'string' == typeof entry.runtime ? [
|
|
258
|
+
entry.runtime
|
|
259
|
+
] : Array.from(entry.runtime);
|
|
293
260
|
let matchFailed = null;
|
|
294
261
|
try {
|
|
295
262
|
matchStepSnapshot(env, context, 0, compiler.getOptions(), statsJson);
|
|
296
|
-
}
|
|
297
|
-
catch (e) {
|
|
263
|
+
} catch (e) {
|
|
298
264
|
matchFailed = e;
|
|
299
265
|
}
|
|
300
266
|
hashes.push(stats.hash);
|
|
301
|
-
if (matchFailed)
|
|
302
|
-
throw matchFailed;
|
|
303
|
-
}
|
|
267
|
+
if (matchFailed) throw matchFailed;
|
|
304
268
|
};
|
|
305
269
|
return processor;
|
|
306
270
|
}
|
|
307
271
|
function getCreator(target) {
|
|
308
|
-
if (!creators.has(target)) {
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
createHotStepProcessor(name, src, temp || node_path_1.default.resolve(dist, 'temp'), target),
|
|
272
|
+
if (!creators.has(target)) creators.set(target, new creator_js_namespaceObject.BasicCaseCreator({
|
|
273
|
+
clean: true,
|
|
274
|
+
describe: false,
|
|
275
|
+
target,
|
|
276
|
+
steps: ({ name, target, src, temp, dist })=>[
|
|
277
|
+
createHotStepProcessor(name, src, temp || external_node_path_default().resolve(dist, 'temp'), target)
|
|
315
278
|
],
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
}
|
|
279
|
+
runner: {
|
|
280
|
+
key: (context, name, file)=>name,
|
|
281
|
+
runner: external_hot_js_namespaceObject.createHotRunner
|
|
282
|
+
},
|
|
283
|
+
concurrent: true
|
|
284
|
+
}));
|
|
323
285
|
return creators.get(target);
|
|
324
286
|
}
|
|
325
287
|
function createHotStepCase(name, src, dist, temp, target) {
|
|
326
288
|
const creator = getCreator(target);
|
|
327
289
|
creator.create(name, src, dist, temp);
|
|
328
290
|
}
|
|
291
|
+
exports.createHotStepCase = __webpack_exports__.createHotStepCase;
|
|
292
|
+
for(var __rspack_i in __webpack_exports__)if (-1 === [
|
|
293
|
+
"createHotStepCase"
|
|
294
|
+
].indexOf(__rspack_i)) exports[__rspack_i] = __webpack_exports__[__rspack_i];
|
|
295
|
+
Object.defineProperty(exports, '__esModule', {
|
|
296
|
+
value: true
|
|
297
|
+
});
|