@rspack-canary/test-tools 1.5.9-canary-a915dabc-20251013174148 → 1.5.9-canary-e259bc79-20251014173821
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/hot-step.d.ts +1 -1
- package/dist/case/hot-step.js +12 -10
- package/dist/case/hot.d.ts +5 -4
- package/dist/case/hot.js +32 -41
- package/dist/case/incremental.d.ts +1 -1
- package/dist/case/incremental.js +8 -6
- package/dist/case/normal.js +0 -4
- package/dist/case/watch.js +0 -7
- package/dist/helper/hot-update/plugin.d.ts +1 -1
- package/dist/helper/hot-update/plugin.js +4 -4
- package/dist/helper/legacy/update.d.ts +2 -0
- package/dist/helper/legacy/update.esm.d.ts +1 -0
- package/dist/helper/legacy/update.esm.js +23 -0
- package/dist/helper/legacy/update.js +19 -0
- package/dist/helper/util/checkStats.d.ts +0 -1
- package/dist/helper/util/checkStats.js +0 -18
- package/dist/index.d.ts +0 -1
- package/dist/index.js +0 -1
- package/dist/jest/ignore-snapshot-default-reporter.d.ts +2 -0
- package/dist/jest/ignore-snapshot-default-reporter.js +57 -0
- package/dist/jest/ignore-snapshot-summary-reporter.d.ts +2 -0
- package/dist/jest/ignore-snapshot-summary-reporter.js +24 -0
- package/dist/jest/patch-node-env.d.ts +5 -0
- package/dist/jest/patch-node-env.js +18 -0
- package/dist/jest/slash.d.ts +2 -0
- package/dist/jest/slash.js +16 -0
- package/package.json +9 -6
- package/dist/helper/legacy/createLogger.d.ts +0 -23
- package/dist/helper/legacy/createLogger.js +0 -20
- package/dist/helper/legacy/diffStats.d.ts +0 -2
- package/dist/helper/legacy/diffStats.js +0 -13
- package/dist/helper/legacy/supportsBlob.d.ts +0 -2
- package/dist/helper/legacy/supportsBlob.js +0 -10
- package/dist/helper/legacy/supportsClassFields.d.ts +0 -2
- package/dist/helper/legacy/supportsClassFields.js +0 -11
- package/dist/helper/legacy/supportsES6.d.ts +0 -2
- package/dist/helper/legacy/supportsES6.js +0 -11
- package/dist/helper/legacy/supportsForOf.d.ts +0 -2
- package/dist/helper/legacy/supportsForOf.js +0 -11
- package/dist/helper/legacy/supportsIteratorDestructuring.d.ts +0 -2
- package/dist/helper/legacy/supportsIteratorDestructuring.js +0 -11
- package/dist/helper/legacy/supportsLogicalAssignment.d.ts +0 -2
- package/dist/helper/legacy/supportsLogicalAssignment.js +0 -11
- package/dist/helper/legacy/supportsObjectDestructuring.d.ts +0 -2
- package/dist/helper/legacy/supportsObjectDestructuring.js +0 -11
- package/dist/helper/legacy/supportsOptionalCatchBinding.d.ts +0 -2
- package/dist/helper/legacy/supportsOptionalCatchBinding.js +0 -11
- package/dist/helper/legacy/supportsOptionalChaining.d.ts +0 -2
- package/dist/helper/legacy/supportsOptionalChaining.js +0 -11
- package/dist/helper/legacy/supportsRequireInModule.d.ts +0 -2
- package/dist/helper/legacy/supportsRequireInModule.js +0 -5
- package/dist/helper/legacy/supportsResponse.d.ts +0 -2
- package/dist/helper/legacy/supportsResponse.js +0 -10
- package/dist/helper/legacy/supportsSpread.d.ts +0 -2
- package/dist/helper/legacy/supportsSpread.js +0 -12
- package/dist/helper/legacy/supportsTemplateStrings.d.ts +0 -2
- package/dist/helper/legacy/supportsTemplateStrings.js +0 -11
- package/dist/helper/legacy/supportsTextDecoder.d.ts +0 -2
- package/dist/helper/legacy/supportsTextDecoder.js +0 -10
- package/dist/helper/legacy/supportsWebAssembly.d.ts +0 -2
- package/dist/helper/legacy/supportsWebAssembly.js +0 -10
- package/dist/helper/legacy/supportsWorker.d.ts +0 -2
- package/dist/helper/legacy/supportsWorker.js +0 -17
- package/dist/helper/legacy/warmup-webpack.d.ts +0 -1
- package/dist/helper/legacy/warmup-webpack.js +0 -26
- package/dist/helper/loaders/hot-update.d.ts +0 -1
- package/dist/helper/loaders/hot-update.js +0 -43
- package/dist/helper/plugins/hot-update.d.ts +0 -7
- package/dist/helper/plugins/hot-update.js +0 -40
- package/dist/helper/plugins/index.d.ts +0 -1
- package/dist/helper/plugins/index.js +0 -17
- package/dist/helper/util/currentWatchStep.d.ts +0 -1
- package/dist/helper/util/currentWatchStep.js +0 -2
- package/dist/helper/util/identifier.d.ts +0 -76
- package/dist/helper/util/identifier.js +0 -339
- package/dist/helper/util/replaceMitteDiagnostic.d.ts +0 -2
- package/dist/helper/util/replaceMitteDiagnostic.js +0 -17
- package/dist/reporter/diff-html.d.ts +0 -15
- package/dist/reporter/diff-html.js +0 -69
- package/dist/reporter/diff-stats.d.ts +0 -24
- package/dist/reporter/diff-stats.js +0 -131
- package/dist/reporter/index.d.ts +0 -2
- package/dist/reporter/index.js +0 -18
package/dist/case/hot-step.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import { ECompilerType, type TCompilerOptions } from "../type";
|
|
2
|
-
export declare function createHotStepCase(name: string, src: string, dist: string, target: TCompilerOptions<ECompilerType.Rspack>["target"]): void;
|
|
2
|
+
export declare function createHotStepCase(name: string, src: string, dist: string, temp: string, target: TCompilerOptions<ECompilerType.Rspack>["target"]): void;
|
package/dist/case/hot-step.js
CHANGED
|
@@ -39,8 +39,8 @@ const GET_MODULE_HANDLER = {
|
|
|
39
39
|
node: NODE_HANDLER
|
|
40
40
|
};
|
|
41
41
|
const creators = new Map();
|
|
42
|
-
function createHotStepProcessor(name, target) {
|
|
43
|
-
const processor = (0, hot_1.createHotProcessor)(name, target);
|
|
42
|
+
function createHotStepProcessor(name, src, temp, target) {
|
|
43
|
+
const processor = (0, hot_1.createHotProcessor)(name, src, temp, target);
|
|
44
44
|
const entries = {};
|
|
45
45
|
const hashes = [];
|
|
46
46
|
function matchStepSnapshot(env, context, step, options, stats, runtime) {
|
|
@@ -53,7 +53,9 @@ function createHotStepProcessor(name, target) {
|
|
|
53
53
|
const hotUpdateManifest = [];
|
|
54
54
|
const changedFiles = step === 0
|
|
55
55
|
? []
|
|
56
|
-
: processor.
|
|
56
|
+
: processor.updatePlugin
|
|
57
|
+
.getModifiedFiles()
|
|
58
|
+
.map((i) => (0, helper_1.escapeSep)(node_path_1.default.relative(temp, i)));
|
|
57
59
|
changedFiles.sort();
|
|
58
60
|
const resultHashes = {
|
|
59
61
|
[lastHash || "LAST_HASH"]: "LAST_HASH",
|
|
@@ -245,7 +247,7 @@ ${runtime.javascript.disposedModules.map(i => `- ${i}`).join("\n")}
|
|
|
245
247
|
}
|
|
246
248
|
const originRun = processor.run;
|
|
247
249
|
processor.run = async function (env, context) {
|
|
248
|
-
context.setValue(name, "hotUpdateStepChecker", (
|
|
250
|
+
context.setValue(name, "hotUpdateStepChecker", (updateIndex, stats, runtime) => {
|
|
249
251
|
const statsJson = stats.toJson({
|
|
250
252
|
assets: true,
|
|
251
253
|
chunks: true
|
|
@@ -264,10 +266,10 @@ ${runtime.javascript.disposedModules.map(i => `- ${i}`).join("\n")}
|
|
|
264
266
|
}
|
|
265
267
|
const compiler = context.getCompiler(name, type_1.ECompilerType.Rspack);
|
|
266
268
|
const compilerOptions = compiler.getOptions();
|
|
267
|
-
matchStepSnapshot(env, context,
|
|
269
|
+
matchStepSnapshot(env, context, updateIndex, compilerOptions, statsJson, runtime);
|
|
268
270
|
hashes.push(stats.hash);
|
|
269
271
|
});
|
|
270
|
-
context.setValue(name, "hotUpdateStepErrorChecker", (
|
|
272
|
+
context.setValue(name, "hotUpdateStepErrorChecker", (updateIndex, stats, runtime) => {
|
|
271
273
|
hashes.push(stats.hash);
|
|
272
274
|
});
|
|
273
275
|
await originRun(env, context);
|
|
@@ -312,8 +314,8 @@ function getCreator(target) {
|
|
|
312
314
|
clean: true,
|
|
313
315
|
describe: false,
|
|
314
316
|
target,
|
|
315
|
-
steps: ({ name, target }) => [
|
|
316
|
-
createHotStepProcessor(name, target)
|
|
317
|
+
steps: ({ name, target, src, temp, dist }) => [
|
|
318
|
+
createHotStepProcessor(name, src, temp || node_path_1.default.resolve(dist, "temp"), target)
|
|
317
319
|
],
|
|
318
320
|
runner: {
|
|
319
321
|
key: (context, name, file) => name,
|
|
@@ -324,7 +326,7 @@ function getCreator(target) {
|
|
|
324
326
|
}
|
|
325
327
|
return creators.get(target);
|
|
326
328
|
}
|
|
327
|
-
function createHotStepCase(name, src, dist, target) {
|
|
329
|
+
function createHotStepCase(name, src, dist, temp, target) {
|
|
328
330
|
const creator = getCreator(target);
|
|
329
|
-
creator.create(name, src, dist);
|
|
331
|
+
creator.create(name, src, dist, temp);
|
|
330
332
|
}
|
package/dist/case/hot.d.ts
CHANGED
|
@@ -1,9 +1,10 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { HotUpdatePlugin } from "../helper/hot-update/plugin";
|
|
2
|
+
import { type ECompilerType, type ITestContext, type ITestEnv, type ITestProcessor, type ITestRunner, type TCompilerOptions } from "../type";
|
|
2
3
|
type TTarget = TCompilerOptions<ECompilerType.Rspack>["target"];
|
|
3
|
-
export declare function createHotProcessor(name: string, target: TTarget, incremental?: boolean): THotProcessor;
|
|
4
|
-
export declare function createHotCase(name: string, src: string, dist: string, target: TCompilerOptions<ECompilerType.Rspack>["target"]): void;
|
|
4
|
+
export declare function createHotProcessor(name: string, src: string, temp: string, target: TTarget, incremental?: boolean): THotProcessor;
|
|
5
|
+
export declare function createHotCase(name: string, src: string, dist: string, temp: string, target: TCompilerOptions<ECompilerType.Rspack>["target"]): void;
|
|
5
6
|
type THotProcessor = ITestProcessor & {
|
|
6
|
-
|
|
7
|
+
updatePlugin: HotUpdatePlugin;
|
|
7
8
|
};
|
|
8
9
|
export declare function createHotRunner<T extends ECompilerType = ECompilerType.Rspack>(context: ITestContext, name: string, file: string, env: ITestEnv): ITestRunner;
|
|
9
10
|
export {};
|
package/dist/case/hot.js
CHANGED
|
@@ -9,27 +9,27 @@ exports.createHotRunner = createHotRunner;
|
|
|
9
9
|
const node_path_1 = __importDefault(require("node:path"));
|
|
10
10
|
const core_1 = __importDefault(require("@rspack/core"));
|
|
11
11
|
const helper_1 = require("../helper");
|
|
12
|
+
const plugin_1 = require("../helper/hot-update/plugin");
|
|
12
13
|
const checkArrayExpectation_1 = __importDefault(require("../helper/legacy/checkArrayExpectation"));
|
|
13
|
-
const
|
|
14
|
-
const plugin_1 = require("../plugin");
|
|
14
|
+
const plugin_2 = require("../plugin");
|
|
15
15
|
const runner_1 = require("../runner");
|
|
16
16
|
const creator_1 = require("../test/creator");
|
|
17
17
|
const type_1 = require("../type");
|
|
18
18
|
const common_1 = require("./common");
|
|
19
19
|
const runner_2 = require("./runner");
|
|
20
20
|
const creators = new Map();
|
|
21
|
-
function createHotProcessor(name, target, incremental = false) {
|
|
22
|
-
const
|
|
23
|
-
updateIndex: 0,
|
|
24
|
-
totalUpdates: 1,
|
|
25
|
-
changedFiles: []
|
|
26
|
-
};
|
|
21
|
+
function createHotProcessor(name, src, temp, target, incremental = false) {
|
|
22
|
+
const updatePlugin = new plugin_1.HotUpdatePlugin(src, temp);
|
|
27
23
|
const processor = {
|
|
24
|
+
before: async (context) => {
|
|
25
|
+
await updatePlugin.initialize();
|
|
26
|
+
context.setValue(name, "hotUpdatePlugin", updatePlugin);
|
|
27
|
+
},
|
|
28
28
|
config: async (context) => {
|
|
29
29
|
const compiler = (0, common_1.getCompiler)(context, name);
|
|
30
|
-
let options = defaultOptions(context, target
|
|
30
|
+
let options = defaultOptions(context, target);
|
|
31
31
|
options = await (0, common_1.config)(context, name, ["rspack.config.js", "webpack.config.js"], options);
|
|
32
|
-
overrideOptions(context, options, target,
|
|
32
|
+
overrideOptions(context, options, target, updatePlugin);
|
|
33
33
|
if (incremental) {
|
|
34
34
|
options.experiments ??= {};
|
|
35
35
|
options.experiments.incremental ??= "advance-silent";
|
|
@@ -43,8 +43,7 @@ function createHotProcessor(name, target, incremental = false) {
|
|
|
43
43
|
await (0, common_1.build)(context, name);
|
|
44
44
|
},
|
|
45
45
|
run: async (env, context) => {
|
|
46
|
-
|
|
47
|
-
await (0, common_1.run)(env, context, name, context => findBundle(context, name, target, hotUpdateContext));
|
|
46
|
+
await (0, common_1.run)(env, context, name, context => findBundle(context, name, target, updatePlugin));
|
|
48
47
|
},
|
|
49
48
|
check: async (env, context) => {
|
|
50
49
|
await (0, common_1.check)(env, context, name);
|
|
@@ -53,12 +52,14 @@ function createHotProcessor(name, target, incremental = false) {
|
|
|
53
52
|
if (context.getTestConfig().checkSteps === false) {
|
|
54
53
|
return;
|
|
55
54
|
}
|
|
56
|
-
|
|
57
|
-
|
|
55
|
+
const updateIndex = updatePlugin.getUpdateIndex();
|
|
56
|
+
const totalUpdates = updatePlugin.getTotalUpdates();
|
|
57
|
+
if (updateIndex + 1 !== totalUpdates) {
|
|
58
|
+
throw new Error(`Should run all hot steps (${updateIndex + 1} / ${totalUpdates}): ${name}`);
|
|
58
59
|
}
|
|
59
60
|
}
|
|
60
61
|
};
|
|
61
|
-
processor.
|
|
62
|
+
processor.updatePlugin = updatePlugin;
|
|
62
63
|
return processor;
|
|
63
64
|
}
|
|
64
65
|
function getCreator(target) {
|
|
@@ -67,8 +68,8 @@ function getCreator(target) {
|
|
|
67
68
|
clean: true,
|
|
68
69
|
describe: true,
|
|
69
70
|
target,
|
|
70
|
-
steps: ({ name, target }) => [
|
|
71
|
-
createHotProcessor(name, target)
|
|
71
|
+
steps: ({ name, target, src, dist, temp }) => [
|
|
72
|
+
createHotProcessor(name, src, temp || node_path_1.default.resolve(dist, "temp"), target)
|
|
72
73
|
],
|
|
73
74
|
runner: {
|
|
74
75
|
key: (context, name, file) => name,
|
|
@@ -79,11 +80,11 @@ function getCreator(target) {
|
|
|
79
80
|
}
|
|
80
81
|
return creators.get(target);
|
|
81
82
|
}
|
|
82
|
-
function createHotCase(name, src, dist, target) {
|
|
83
|
+
function createHotCase(name, src, dist, temp, target) {
|
|
83
84
|
const creator = getCreator(target);
|
|
84
|
-
creator.create(name, src, dist);
|
|
85
|
+
creator.create(name, src, dist, temp);
|
|
85
86
|
}
|
|
86
|
-
function defaultOptions(context, target
|
|
87
|
+
function defaultOptions(context, target) {
|
|
87
88
|
const options = {
|
|
88
89
|
context: context.getSource(),
|
|
89
90
|
mode: "development",
|
|
@@ -112,10 +113,10 @@ function defaultOptions(context, target, updateOptions) {
|
|
|
112
113
|
}
|
|
113
114
|
};
|
|
114
115
|
options.plugins ??= [];
|
|
115
|
-
options.plugins.push(new core_1.default.HotModuleReplacementPlugin()
|
|
116
|
+
options.plugins.push(new core_1.default.HotModuleReplacementPlugin());
|
|
116
117
|
return options;
|
|
117
118
|
}
|
|
118
|
-
function overrideOptions(context, options, target,
|
|
119
|
+
function overrideOptions(context, options, target, updatePlugin) {
|
|
119
120
|
if (!options.entry) {
|
|
120
121
|
options.entry = "./index.js";
|
|
121
122
|
}
|
|
@@ -126,34 +127,24 @@ function overrideOptions(context, options, target, updateOptions) {
|
|
|
126
127
|
options.module.generator[cssModuleType].exportsOnly ??=
|
|
127
128
|
target === "async-node";
|
|
128
129
|
}
|
|
129
|
-
options.module.rules ??= [];
|
|
130
|
-
options.module.rules.push({
|
|
131
|
-
use: [
|
|
132
|
-
{
|
|
133
|
-
loader: node_path_1.default.resolve(__dirname, "../helper/loaders/hot-update.js"),
|
|
134
|
-
options: updateOptions
|
|
135
|
-
}
|
|
136
|
-
],
|
|
137
|
-
enforce: "pre"
|
|
138
|
-
});
|
|
139
130
|
options.plugins ??= [];
|
|
140
|
-
options.plugins.push(
|
|
131
|
+
options.plugins.push(updatePlugin);
|
|
141
132
|
if (!global.printLogger) {
|
|
142
133
|
options.infrastructureLogging = {
|
|
143
134
|
level: "error"
|
|
144
135
|
};
|
|
145
136
|
}
|
|
146
137
|
if (options.lazyCompilation) {
|
|
147
|
-
options.plugins.push(new
|
|
138
|
+
options.plugins.push(new plugin_2.LazyCompilationTestPlugin());
|
|
148
139
|
}
|
|
149
140
|
}
|
|
150
|
-
function findBundle(context, name, target,
|
|
141
|
+
function findBundle(context, name, target, updatePlugin) {
|
|
151
142
|
const compiler = context.getCompiler(name);
|
|
152
143
|
if (!compiler)
|
|
153
144
|
throw new Error("Compiler should exists when find bundle");
|
|
154
145
|
const testConfig = context.getTestConfig();
|
|
155
146
|
if (typeof testConfig.findBundle === "function") {
|
|
156
|
-
return testConfig.findBundle(
|
|
147
|
+
return testConfig.findBundle(updatePlugin.getUpdateIndex(), compiler.getOptions());
|
|
157
148
|
}
|
|
158
149
|
const files = [];
|
|
159
150
|
const prefiles = [];
|
|
@@ -183,11 +174,11 @@ function createHotRunner(context, name, file, env) {
|
|
|
183
174
|
const testConfig = context.getTestConfig();
|
|
184
175
|
const source = context.getSource();
|
|
185
176
|
const dist = context.getDist();
|
|
186
|
-
const
|
|
177
|
+
const updatePlugin = context.getValue(name, "hotUpdatePlugin");
|
|
187
178
|
const next = async (callback) => {
|
|
188
179
|
const usePromise = typeof callback === "function";
|
|
189
180
|
try {
|
|
190
|
-
|
|
181
|
+
await updatePlugin.goNext();
|
|
191
182
|
const stats = await compiler.build();
|
|
192
183
|
if (!stats) {
|
|
193
184
|
throw new Error("Should generate stats during build");
|
|
@@ -200,10 +191,10 @@ function createHotRunner(context, name, file, env) {
|
|
|
200
191
|
? "hotUpdateStepErrorChecker"
|
|
201
192
|
: "hotUpdateStepChecker");
|
|
202
193
|
if (checker) {
|
|
203
|
-
checker(
|
|
194
|
+
checker(updatePlugin.getUpdateIndex(), stats, runner.getGlobal("__HMR_UPDATED_RUNTIME__"));
|
|
204
195
|
}
|
|
205
|
-
await (0, checkArrayExpectation_1.default)(source, jsonStats, "error", `errors${
|
|
206
|
-
await (0, checkArrayExpectation_1.default)(source, jsonStats, "warning", `warnings${
|
|
196
|
+
await (0, checkArrayExpectation_1.default)(source, jsonStats, "error", `errors${updatePlugin.getUpdateIndex()}`, "Error", compilerOptions);
|
|
197
|
+
await (0, checkArrayExpectation_1.default)(source, jsonStats, "warning", `warnings${updatePlugin.getUpdateIndex()}`, "Warning", compilerOptions);
|
|
207
198
|
if (usePromise) {
|
|
208
199
|
// old callback style hmr cases
|
|
209
200
|
callback(null, jsonStats);
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { type ECompilerType, type TCompilerOptions } from "../type";
|
|
2
|
-
export declare function createHotIncrementalCase(name: string, src: string, dist: string, target: TCompilerOptions<ECompilerType.Rspack>["target"], webpackCases: boolean): void;
|
|
2
|
+
export declare function createHotIncrementalCase(name: string, src: string, dist: string, temp: string, target: TCompilerOptions<ECompilerType.Rspack>["target"], webpackCases: boolean): void;
|
|
3
3
|
export type WatchIncrementalOptions = {
|
|
4
4
|
ignoreNotFriendlyForIncrementalWarnings?: boolean;
|
|
5
5
|
};
|
package/dist/case/incremental.js
CHANGED
|
@@ -12,9 +12,11 @@ const type_1 = require("../type");
|
|
|
12
12
|
const hot_1 = require("./hot");
|
|
13
13
|
const watch_1 = require("./watch");
|
|
14
14
|
const hotCreators = new Map();
|
|
15
|
-
function createHotIncrementalProcessor(name, target, webpackCases) {
|
|
16
|
-
const processor = (0, hot_1.createHotProcessor)(name, target, true);
|
|
15
|
+
function createHotIncrementalProcessor(name, src, temp, target, webpackCases) {
|
|
16
|
+
const processor = (0, hot_1.createHotProcessor)(name, src, temp, target, true);
|
|
17
|
+
const originalBefore = processor.before;
|
|
17
18
|
processor.before = async (context) => {
|
|
19
|
+
await originalBefore?.(context);
|
|
18
20
|
context.setValue(name, "documentType", webpackCases ? type_1.EDocumentType.Fake : type_1.EDocumentType.JSDOM);
|
|
19
21
|
};
|
|
20
22
|
const originalAfterAll = processor.afterAll;
|
|
@@ -38,8 +40,8 @@ function getHotCreator(target, webpackCases) {
|
|
|
38
40
|
clean: true,
|
|
39
41
|
describe: true,
|
|
40
42
|
target,
|
|
41
|
-
steps: ({ name, target }) => [
|
|
42
|
-
createHotIncrementalProcessor(name, target, webpackCases)
|
|
43
|
+
steps: ({ name, target, src, temp, dist }) => [
|
|
44
|
+
createHotIncrementalProcessor(name, src, temp || node_path_1.default.resolve(dist, "temp"), target, webpackCases)
|
|
43
45
|
],
|
|
44
46
|
runner: {
|
|
45
47
|
key: (context, name, file) => name,
|
|
@@ -50,9 +52,9 @@ function getHotCreator(target, webpackCases) {
|
|
|
50
52
|
}
|
|
51
53
|
return hotCreators.get(key);
|
|
52
54
|
}
|
|
53
|
-
function createHotIncrementalCase(name, src, dist, target, webpackCases) {
|
|
55
|
+
function createHotIncrementalCase(name, src, dist, temp, target, webpackCases) {
|
|
54
56
|
const creator = getHotCreator(target, webpackCases);
|
|
55
|
-
creator.create(name, src, dist);
|
|
57
|
+
creator.create(name, src, dist, temp);
|
|
56
58
|
}
|
|
57
59
|
const watchCreators = new Map();
|
|
58
60
|
function getWatchCreator(options) {
|
package/dist/case/normal.js
CHANGED
|
@@ -199,10 +199,6 @@ function defaultOptions(context, compilerOptions, mode) {
|
|
|
199
199
|
// Turning off here to fallback to webpack's default css processing logic.
|
|
200
200
|
...(compilerOptions?.module ? { outputModule: true } : {})
|
|
201
201
|
}
|
|
202
|
-
// infrastructureLogging: compilerOptions?.cache && {
|
|
203
|
-
// debug: true,
|
|
204
|
-
// console: createLogger(infraStructureLog)
|
|
205
|
-
// }
|
|
206
202
|
};
|
|
207
203
|
}
|
|
208
204
|
function overrideOptions(context, options) {
|
package/dist/case/watch.js
CHANGED
|
@@ -19,8 +19,6 @@ const runner_1 = require("../runner");
|
|
|
19
19
|
const creator_1 = require("../test/creator");
|
|
20
20
|
const type_1 = require("../type");
|
|
21
21
|
const common_1 = require("./common");
|
|
22
|
-
// This file is used to port step number to rspack.config.js/webpack.config.js
|
|
23
|
-
const currentWatchStepModulePath = node_path_1.default.resolve(__dirname, "../helper/util/currentWatchStep");
|
|
24
22
|
function createWatchInitialProcessor(name, tempDir, step, watchState, { incremental = false, nativeWatcher = false } = {}) {
|
|
25
23
|
const watchContext = {
|
|
26
24
|
currentTriggerFilename: null,
|
|
@@ -61,8 +59,6 @@ function createWatchInitialProcessor(name, tempDir, step, watchState, { incremen
|
|
|
61
59
|
},
|
|
62
60
|
build: async (context) => {
|
|
63
61
|
const compiler = (0, common_1.getCompiler)(context, name);
|
|
64
|
-
const currentWatchStepModule = require(currentWatchStepModulePath);
|
|
65
|
-
currentWatchStepModule.step[name] = watchContext.step;
|
|
66
62
|
node_fs_1.default.mkdirSync(watchContext.tempDir, { recursive: true });
|
|
67
63
|
(0, copyDiff_1.default)(node_path_1.default.join(context.getSource(), watchContext.step), watchContext.tempDir, true);
|
|
68
64
|
const task = new Promise((resolve, reject) => {
|
|
@@ -171,10 +167,7 @@ function createWatchStepProcessor(name, tempDir, step, watchState, { incremental
|
|
|
171
167
|
// do nothing
|
|
172
168
|
};
|
|
173
169
|
processor.build = async (context) => {
|
|
174
|
-
const watchContext = context.getValue(name, "watchContext");
|
|
175
170
|
const compiler = (0, common_1.getCompiler)(context, name);
|
|
176
|
-
const currentWatchStepModule = require(currentWatchStepModulePath);
|
|
177
|
-
currentWatchStepModule.step[name] = watchContext.step;
|
|
178
171
|
const task = new Promise((resolve, reject) => {
|
|
179
172
|
compiler.getEmitter().once(compiler_1.ECompilerEvent.Build, (e, stats) => {
|
|
180
173
|
if (e)
|
|
@@ -6,10 +6,10 @@ export declare class HotUpdatePlugin {
|
|
|
6
6
|
private updateIndex;
|
|
7
7
|
private files;
|
|
8
8
|
constructor(projectDir: string, tempDir: string);
|
|
9
|
-
private getModifiedFiles;
|
|
10
9
|
private getContent;
|
|
11
10
|
private updateFiles;
|
|
12
11
|
initialize(): Promise<void>;
|
|
12
|
+
getModifiedFiles(): string[];
|
|
13
13
|
getUpdateIndex(): number;
|
|
14
14
|
getTotalUpdates(): number;
|
|
15
15
|
goNext(): Promise<void>;
|
|
@@ -29,9 +29,6 @@ class HotUpdatePlugin {
|
|
|
29
29
|
this.updateIndex = 0;
|
|
30
30
|
this.files = {};
|
|
31
31
|
}
|
|
32
|
-
getModifiedFiles() {
|
|
33
|
-
return Object.keys(this.files);
|
|
34
|
-
}
|
|
35
32
|
getContent(filePath, index) {
|
|
36
33
|
const contents = this.files[filePath] || [];
|
|
37
34
|
let content = contents[index] === undefined ? contents.at(-1) || "" : contents[index];
|
|
@@ -86,13 +83,16 @@ class HotUpdatePlugin {
|
|
|
86
83
|
});
|
|
87
84
|
await this.updateFiles();
|
|
88
85
|
}
|
|
86
|
+
getModifiedFiles() {
|
|
87
|
+
return Object.keys(this.files);
|
|
88
|
+
}
|
|
89
89
|
getUpdateIndex() {
|
|
90
90
|
return this.updateIndex;
|
|
91
91
|
}
|
|
92
92
|
getTotalUpdates() {
|
|
93
93
|
return Object.values(this.files).reduce((max, item) => {
|
|
94
94
|
return Math.max(max, item.length);
|
|
95
|
-
},
|
|
95
|
+
}, 1);
|
|
96
96
|
}
|
|
97
97
|
async goNext() {
|
|
98
98
|
this.updateIndex++;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export default function update(done: any, options: any, callback: any): (err: any, stats: any) => any;
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.default = update;
|
|
4
|
+
// @ts-nocheck
|
|
5
|
+
function update(done, options, callback) {
|
|
6
|
+
return function (err, stats) {
|
|
7
|
+
if (err)
|
|
8
|
+
return done(err);
|
|
9
|
+
import.meta.webpackHot
|
|
10
|
+
.check(options || true)
|
|
11
|
+
.then(updatedModules => {
|
|
12
|
+
if (!updatedModules) {
|
|
13
|
+
return done(new Error("No update available"));
|
|
14
|
+
}
|
|
15
|
+
if (callback)
|
|
16
|
+
callback(stats);
|
|
17
|
+
})
|
|
18
|
+
.catch(err => {
|
|
19
|
+
done(err);
|
|
20
|
+
});
|
|
21
|
+
};
|
|
22
|
+
}
|
|
23
|
+
;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
// @ts-nocheck
|
|
3
|
+
module.exports = function (done, options, callback) {
|
|
4
|
+
return function (err, stats) {
|
|
5
|
+
if (err)
|
|
6
|
+
return done(err);
|
|
7
|
+
module.hot
|
|
8
|
+
.check(options || true)
|
|
9
|
+
.then(updatedModules => {
|
|
10
|
+
if (!updatedModules)
|
|
11
|
+
return done(new Error("No update available"));
|
|
12
|
+
if (callback)
|
|
13
|
+
callback(stats);
|
|
14
|
+
})
|
|
15
|
+
.catch(err => {
|
|
16
|
+
done(err);
|
|
17
|
+
});
|
|
18
|
+
};
|
|
19
|
+
};
|
|
@@ -16,24 +16,6 @@ exports.checkChunkModules = function checkChunkModules(statsJson, chunkModulesMa
|
|
|
16
16
|
}
|
|
17
17
|
return true;
|
|
18
18
|
};
|
|
19
|
-
exports.checkChunkRuntime = function checkChunkModules(statsJson, chunkModulesMap, strict = true) {
|
|
20
|
-
for (const chunkId of Reflect.ownKeys(chunkModulesMap)) {
|
|
21
|
-
const chunk = getChunk(statsJson, chunkId);
|
|
22
|
-
const expectedRuntime = chunkModulesMap[chunkId];
|
|
23
|
-
const chunkRuntime = chunk.runtime;
|
|
24
|
-
if (strict) {
|
|
25
|
-
expectedRuntime.length === chunkRuntime.length;
|
|
26
|
-
}
|
|
27
|
-
for (let i = 0; i < expectedRuntime.length; i++) {
|
|
28
|
-
const expected = expectedRuntime[i];
|
|
29
|
-
const rt = chunkRuntime[i];
|
|
30
|
-
if (expected !== rt) {
|
|
31
|
-
throw new Error(`chunk ${chunkId} runtime not equal, expected: ${expectedRuntime}, but got: ${chunkRuntime}`);
|
|
32
|
-
}
|
|
33
|
-
}
|
|
34
|
-
}
|
|
35
|
-
return true;
|
|
36
|
-
};
|
|
37
19
|
function getChunk(statsJson, id) {
|
|
38
20
|
const chunk = statsJson.chunks.find(chunk => chunk.id.includes(id));
|
|
39
21
|
if (!chunk) {
|
package/dist/index.d.ts
CHANGED
package/dist/index.js
CHANGED
|
@@ -18,7 +18,6 @@ __exportStar(require("./case"), exports);
|
|
|
18
18
|
__exportStar(require("./compare"), exports);
|
|
19
19
|
__exportStar(require("./helper"), exports);
|
|
20
20
|
__exportStar(require("./plugin"), exports);
|
|
21
|
-
__exportStar(require("./reporter"), exports);
|
|
22
21
|
__exportStar(require("./runner"), exports);
|
|
23
22
|
__exportStar(require("./test/context"), exports);
|
|
24
23
|
__exportStar(require("./test/creator"), exports);
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
// @ts-nocheck
|
|
3
|
+
const { DefaultReporter } = require("@jest/reporters");
|
|
4
|
+
const chalk = require.cache[require.resolve("@jest/reporters")].require("chalk");
|
|
5
|
+
const jestUtil = require.cache[require.resolve("@jest/reporters")].require("jest-util");
|
|
6
|
+
const ARROW = " \u203A ";
|
|
7
|
+
const DOT = " \u2022 ";
|
|
8
|
+
const FAIL_COLOR = chalk.bold.red;
|
|
9
|
+
const SNAPSHOT_ADDED = chalk.bold.green;
|
|
10
|
+
const SNAPSHOT_UPDATED = chalk.bold.green;
|
|
11
|
+
const SNAPSHOT_OUTDATED = chalk.bold.yellow;
|
|
12
|
+
function getSnapshotStatus(snapshot, afterUpdate) {
|
|
13
|
+
const statuses = [];
|
|
14
|
+
if (snapshot.added) {
|
|
15
|
+
statuses.push(SNAPSHOT_ADDED(`${ARROW + jestUtil.pluralize("snapshot", snapshot.added)} written.`));
|
|
16
|
+
}
|
|
17
|
+
if (snapshot.updated) {
|
|
18
|
+
statuses.push(SNAPSHOT_UPDATED(`${ARROW + jestUtil.pluralize("snapshot", snapshot.updated)} updated.`));
|
|
19
|
+
}
|
|
20
|
+
if (snapshot.unmatched) {
|
|
21
|
+
statuses.push(FAIL_COLOR(`${ARROW + jestUtil.pluralize("snapshot", snapshot.unmatched)} failed.`));
|
|
22
|
+
}
|
|
23
|
+
if (snapshot.unchecked) {
|
|
24
|
+
if (afterUpdate) {
|
|
25
|
+
statuses.push(SNAPSHOT_UPDATED(`${ARROW + jestUtil.pluralize("snapshot", snapshot.unchecked)} removed.`));
|
|
26
|
+
for (const key of snapshot.uncheckedKeys) {
|
|
27
|
+
statuses.push(` ${DOT}${key}`);
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
else {
|
|
31
|
+
statuses.push(`${SNAPSHOT_OUTDATED(`${ARROW + jestUtil.pluralize("snapshot", snapshot.unchecked)} obsolete`)}.`);
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
if (snapshot.fileDeleted) {
|
|
35
|
+
statuses.push(SNAPSHOT_UPDATED(`${ARROW}snapshot file removed.`));
|
|
36
|
+
}
|
|
37
|
+
return statuses;
|
|
38
|
+
}
|
|
39
|
+
const isUpdate = process.argv.includes("-u") || process.argv.includes("--updateSnapshot");
|
|
40
|
+
const isFiltering = process.argv.includes("-t") || process.argv.includes("--testNamePattern");
|
|
41
|
+
const isVerbose = process.argv.includes("--verbose");
|
|
42
|
+
if (!isVerbose && !isUpdate && isFiltering) {
|
|
43
|
+
class IgnoreSnapshotDefaultReporter extends DefaultReporter {
|
|
44
|
+
printTestFileFailureMessage(_testPath, _config, result) {
|
|
45
|
+
if (result.failureMessage) {
|
|
46
|
+
this.log(result.failureMessage);
|
|
47
|
+
}
|
|
48
|
+
const didUpdate = this._globalConfig.updateSnapshot === "all";
|
|
49
|
+
const snapshotStatuses = getSnapshotStatus(result.snapshot, didUpdate);
|
|
50
|
+
snapshotStatuses.forEach(this.log);
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
module.exports = IgnoreSnapshotDefaultReporter;
|
|
54
|
+
}
|
|
55
|
+
else {
|
|
56
|
+
module.exports = DefaultReporter;
|
|
57
|
+
}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
// @ts-nocheck
|
|
3
|
+
const { SummaryReporter } = require("@jest/reporters");
|
|
4
|
+
const chalk = require.cache[require.resolve("@jest/reporters")].require("chalk");
|
|
5
|
+
const isUpdate = process.argv.includes("-u") || process.argv.includes("--updateSnapshot");
|
|
6
|
+
const isFiltering = process.argv.includes("-t") || process.argv.includes("--testNamePattern");
|
|
7
|
+
const isVerbose = process.argv.includes("--verbose");
|
|
8
|
+
if (!isVerbose && !isUpdate && isFiltering) {
|
|
9
|
+
class IgnoreSnapshotSummaryReporter extends SummaryReporter {
|
|
10
|
+
_printSnapshotSummary(snapshots, globalConfig) {
|
|
11
|
+
if (snapshots.added ||
|
|
12
|
+
snapshots.filesRemoved ||
|
|
13
|
+
snapshots.unchecked ||
|
|
14
|
+
snapshots.unmatched ||
|
|
15
|
+
snapshots.updated) {
|
|
16
|
+
this.log(chalk.bold.yellow("Some snapshots are obsoleted, flush with `npm run test -- -u` if necessary.\n"));
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
module.exports = IgnoreSnapshotSummaryReporter;
|
|
21
|
+
}
|
|
22
|
+
else {
|
|
23
|
+
module.exports = SummaryReporter;
|
|
24
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
// @ts-nocheck
|
|
3
|
+
// Copied from <https://github.com/webpack/webpack/blob/main/test/patch-node-env.js>
|
|
4
|
+
//
|
|
5
|
+
const NodeEnvironment =
|
|
6
|
+
// For jest@29
|
|
7
|
+
require("jest-environment-node").TestEnvironment ||
|
|
8
|
+
// For jest@27
|
|
9
|
+
require("jest-environment-node");
|
|
10
|
+
class CustomEnvironment extends NodeEnvironment {
|
|
11
|
+
// Workaround for `Symbol('JEST_STATE_SYMBOL')`
|
|
12
|
+
async handleTestEvent(event, state) {
|
|
13
|
+
if (!this.global.JEST_STATE_SYMBOL) {
|
|
14
|
+
this.global.JEST_STATE_SYMBOL = state;
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
module.exports = CustomEnvironment;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
// @ts-nocheck
|
|
3
|
+
/**
|
|
4
|
+
* The following code is copied from
|
|
5
|
+
* https://github.com/sindresorhus/slash/blob/98b618f5a3bfcb5dd374b204868818845b87bb2f/index.js
|
|
6
|
+
*
|
|
7
|
+
* MIT Licensed
|
|
8
|
+
* Author Sindre Sorhus @sindresorhus
|
|
9
|
+
*/
|
|
10
|
+
module.exports = function slash(path) {
|
|
11
|
+
const isExtendedLengthPath = path.startsWith("\\\\?\\");
|
|
12
|
+
if (isExtendedLengthPath) {
|
|
13
|
+
return path;
|
|
14
|
+
}
|
|
15
|
+
return path.replace(/\\/g, "/");
|
|
16
|
+
};
|