@rspack/test-tools 1.5.7 → 1.6.0-beta.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/case/builtin.js +0 -22
- package/dist/case/cache.js +1 -2
- package/dist/case/common.js +48 -42
- package/dist/case/compiler.js +142 -124
- package/dist/case/config.js +1 -2
- package/dist/case/diagnostic.d.ts +2 -2
- package/dist/case/diagnostic.js +1 -2
- package/dist/case/error.d.ts +1 -0
- package/dist/case/error.js +61 -31
- package/dist/case/esm-output.d.ts +1 -0
- package/dist/case/esm-output.js +96 -0
- package/dist/case/example.d.ts +1 -0
- package/dist/case/example.js +57 -0
- package/dist/case/hash.js +3 -4
- package/dist/case/hook.js +45 -39
- 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 +33 -43
- package/dist/case/incremental.d.ts +1 -1
- package/dist/case/incremental.js +10 -10
- package/dist/case/index.d.ts +13 -1
- package/dist/case/index.js +9 -1
- package/dist/case/multi-compiler.d.ts +18 -0
- package/dist/case/multi-compiler.js +98 -0
- package/dist/case/normal.d.ts +2 -0
- package/dist/case/normal.js +19 -12
- package/dist/case/stats-api.d.ts +9 -0
- package/dist/case/stats-api.js +40 -29
- package/dist/case/stats-output.d.ts +10 -0
- package/dist/case/stats-output.js +10 -6
- package/dist/case/watch.d.ts +2 -4
- package/dist/case/watch.js +5 -11
- package/dist/compare/compare.js +6 -3
- package/dist/helper/directory.js +1 -1
- package/dist/helper/expect/error.js +1 -1
- package/dist/helper/expect/placeholder.js +7 -7
- package/dist/helper/expect/to-match-file-snapshot.d.ts +0 -1
- package/dist/helper/hot-update/plugin.d.ts +1 -1
- package/dist/helper/hot-update/plugin.js +10 -5
- package/dist/helper/legacy/LogTestPlugin.d.ts +6 -0
- package/dist/helper/legacy/LogTestPlugin.js +35 -0
- 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 -2
- package/dist/index.js +0 -2
- 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/dist/runner/node/index.js +15 -7
- package/dist/runner/web/fake.js +6 -3
- package/dist/runner/web/jsdom.js +1 -5
- package/dist/test/creator.d.ts +12 -11
- package/dist/test/creator.js +52 -44
- package/dist/test/tester.js +14 -5
- package/dist/type.d.ts +10 -0
- package/package.json +13 -10
- package/dist/helper/legacy/createLogger.d.ts +0 -23
- package/dist/helper/legacy/createLogger.js +0 -20
- 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/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 -40
- 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/test/simple.d.ts +0 -5
- package/dist/test/simple.js +0 -44
package/dist/case/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.createWatchCase = exports.createTreeShakingCase = exports.createStatsOutputCase = exports.createStatsAPICase = exports.createSerialCase = exports.createNormalCase = exports.createHotNormalCase = exports.createNativeWatcher = exports.createWatchIncrementalCase = exports.createHotIncrementalCase = exports.createHotStepCase = exports.createHotCase = exports.createHookCase = exports.createHashCase = exports.createErrorCase = exports.createDiffCase = exports.createDiagnosticCase = exports.getRspackDefaultConfig = exports.createDefaultsCase = exports.createConfigCase = exports.createCompilerCase = exports.createCacheCase = exports.createBuiltinCase = void 0;
|
|
3
|
+
exports.createWatchCase = exports.createTreeShakingCase = exports.createStatsOutputCase = exports.createStatsAPICase = exports.createSerialCase = exports.createProdNormalCase = exports.createNormalCase = exports.createHotNormalCase = exports.createDevNormalCase = exports.createNativeWatcher = exports.createMultiCompilerCase = exports.createWatchIncrementalCase = exports.createHotIncrementalCase = exports.createHotStepCase = exports.createHotCase = exports.createHookCase = exports.createHashCase = exports.createExampleCase = exports.createEsmOutputCase = exports.createErrorCase = exports.createDiffCase = exports.createDiagnosticCase = exports.getRspackDefaultConfig = exports.createDefaultsCase = exports.createConfigCase = exports.createCompilerCase = exports.createCacheCase = exports.createBuiltinCase = void 0;
|
|
4
4
|
var builtin_1 = require("./builtin");
|
|
5
5
|
Object.defineProperty(exports, "createBuiltinCase", { enumerable: true, get: function () { return builtin_1.createBuiltinCase; } });
|
|
6
6
|
var cache_1 = require("./cache");
|
|
@@ -18,6 +18,10 @@ var diff_1 = require("./diff");
|
|
|
18
18
|
Object.defineProperty(exports, "createDiffCase", { enumerable: true, get: function () { return diff_1.createDiffCase; } });
|
|
19
19
|
var error_1 = require("./error");
|
|
20
20
|
Object.defineProperty(exports, "createErrorCase", { enumerable: true, get: function () { return error_1.createErrorCase; } });
|
|
21
|
+
var esm_output_1 = require("./esm-output");
|
|
22
|
+
Object.defineProperty(exports, "createEsmOutputCase", { enumerable: true, get: function () { return esm_output_1.createEsmOutputCase; } });
|
|
23
|
+
var example_1 = require("./example");
|
|
24
|
+
Object.defineProperty(exports, "createExampleCase", { enumerable: true, get: function () { return example_1.createExampleCase; } });
|
|
21
25
|
var hash_1 = require("./hash");
|
|
22
26
|
Object.defineProperty(exports, "createHashCase", { enumerable: true, get: function () { return hash_1.createHashCase; } });
|
|
23
27
|
var hook_1 = require("./hook");
|
|
@@ -29,11 +33,15 @@ Object.defineProperty(exports, "createHotStepCase", { enumerable: true, get: fun
|
|
|
29
33
|
var incremental_1 = require("./incremental");
|
|
30
34
|
Object.defineProperty(exports, "createHotIncrementalCase", { enumerable: true, get: function () { return incremental_1.createHotIncrementalCase; } });
|
|
31
35
|
Object.defineProperty(exports, "createWatchIncrementalCase", { enumerable: true, get: function () { return incremental_1.createWatchIncrementalCase; } });
|
|
36
|
+
var multi_compiler_1 = require("./multi-compiler");
|
|
37
|
+
Object.defineProperty(exports, "createMultiCompilerCase", { enumerable: true, get: function () { return multi_compiler_1.createMultiCompilerCase; } });
|
|
32
38
|
var native_watcher_1 = require("./native-watcher");
|
|
33
39
|
Object.defineProperty(exports, "createNativeWatcher", { enumerable: true, get: function () { return native_watcher_1.createNativeWatcher; } });
|
|
34
40
|
var normal_1 = require("./normal");
|
|
41
|
+
Object.defineProperty(exports, "createDevNormalCase", { enumerable: true, get: function () { return normal_1.createDevNormalCase; } });
|
|
35
42
|
Object.defineProperty(exports, "createHotNormalCase", { enumerable: true, get: function () { return normal_1.createHotNormalCase; } });
|
|
36
43
|
Object.defineProperty(exports, "createNormalCase", { enumerable: true, get: function () { return normal_1.createNormalCase; } });
|
|
44
|
+
Object.defineProperty(exports, "createProdNormalCase", { enumerable: true, get: function () { return normal_1.createProdNormalCase; } });
|
|
37
45
|
var serial_1 = require("./serial");
|
|
38
46
|
Object.defineProperty(exports, "createSerialCase", { enumerable: true, get: function () { return serial_1.createSerialCase; } });
|
|
39
47
|
var stats_api_1 = require("./stats-api");
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import type { ECompilerType, ITestContext, TCompilation, TCompiler, TCompilerOptions, TCompilerStats, TCompilerStatsCompilation } from "../type";
|
|
2
|
+
export declare function createMultiCompilerCase(name: string, src: string, dist: string, testConfig: string): void;
|
|
3
|
+
export type TMultiCompilerCaseConfig = {
|
|
4
|
+
description: string;
|
|
5
|
+
error?: boolean;
|
|
6
|
+
skip?: boolean;
|
|
7
|
+
options?: (context: ITestContext) => TCompilerOptions<ECompilerType.Rspack>;
|
|
8
|
+
compiler?: (context: ITestContext, compiler: TCompiler<ECompilerType.Rspack>) => Promise<void>;
|
|
9
|
+
build?: (context: ITestContext, compiler: TCompiler<ECompilerType.Rspack>) => Promise<void>;
|
|
10
|
+
check?: ({ context, stats, files, compiler, compilation }: {
|
|
11
|
+
context: ITestContext;
|
|
12
|
+
stats?: TCompilerStatsCompilation<ECompilerType.Rspack>;
|
|
13
|
+
files?: Record<string, string>;
|
|
14
|
+
compiler: TCompiler<ECompilerType.Rspack>;
|
|
15
|
+
compilation?: TCompilation<ECompilerType.Rspack>;
|
|
16
|
+
}) => Promise<void>;
|
|
17
|
+
compilerCallback?: (error: Error | null, stats: TCompilerStats<ECompilerType.Rspack> | null) => void;
|
|
18
|
+
};
|
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.createMultiCompilerCase = createMultiCompilerCase;
|
|
7
|
+
const node_path_1 = __importDefault(require("node:path"));
|
|
8
|
+
const memfs_1 = require("memfs");
|
|
9
|
+
const creator_1 = require("../test/creator");
|
|
10
|
+
const common_1 = require("./common");
|
|
11
|
+
function createMultiCompilerProcessor(name, caseConfig) {
|
|
12
|
+
return {
|
|
13
|
+
config: async (context) => {
|
|
14
|
+
const compiler = (0, common_1.getCompiler)(context, name);
|
|
15
|
+
const options = Object.assign([
|
|
16
|
+
{
|
|
17
|
+
name: "a",
|
|
18
|
+
context: node_path_1.default.join(__dirname, "fixtures"),
|
|
19
|
+
entry: "./a.js"
|
|
20
|
+
},
|
|
21
|
+
{
|
|
22
|
+
name: "b",
|
|
23
|
+
context: node_path_1.default.join(__dirname, "fixtures"),
|
|
24
|
+
entry: "./b.js"
|
|
25
|
+
}
|
|
26
|
+
], caseConfig.options?.(context) || {});
|
|
27
|
+
compiler.setOptions(options);
|
|
28
|
+
},
|
|
29
|
+
compiler: async (context) => {
|
|
30
|
+
const compiler = (0, common_1.getCompiler)(context, name);
|
|
31
|
+
if (caseConfig.compilerCallback) {
|
|
32
|
+
compiler.createCompilerWithCallback(caseConfig.compilerCallback);
|
|
33
|
+
}
|
|
34
|
+
else {
|
|
35
|
+
compiler.createCompiler();
|
|
36
|
+
}
|
|
37
|
+
const c = compiler.getCompiler();
|
|
38
|
+
c.outputFileSystem = (0, memfs_1.createFsFromVolume)(new memfs_1.Volume());
|
|
39
|
+
c.watchFileSystem = {
|
|
40
|
+
watch() {
|
|
41
|
+
// watch should return a watcher instance
|
|
42
|
+
// watcher instance should have close, pause and getInfo methods
|
|
43
|
+
return {
|
|
44
|
+
close: () => { },
|
|
45
|
+
pause: () => { },
|
|
46
|
+
getInfo: () => {
|
|
47
|
+
return {
|
|
48
|
+
changes: new Set(),
|
|
49
|
+
removals: new Set(),
|
|
50
|
+
fileTimeInfoEntries: new Map(),
|
|
51
|
+
directoryTimeInfoEntries: new Map()
|
|
52
|
+
};
|
|
53
|
+
}
|
|
54
|
+
};
|
|
55
|
+
}
|
|
56
|
+
};
|
|
57
|
+
await caseConfig.compiler?.(context, c);
|
|
58
|
+
},
|
|
59
|
+
build: async (context) => {
|
|
60
|
+
const compiler = (0, common_1.getCompiler)(context, name);
|
|
61
|
+
if (typeof caseConfig.build === "function") {
|
|
62
|
+
await caseConfig.build?.(context, compiler.getCompiler());
|
|
63
|
+
}
|
|
64
|
+
else {
|
|
65
|
+
await compiler.build();
|
|
66
|
+
}
|
|
67
|
+
},
|
|
68
|
+
run: async (env, context) => { },
|
|
69
|
+
check: async (env, context) => { }
|
|
70
|
+
};
|
|
71
|
+
}
|
|
72
|
+
const creator = new creator_1.BasicCaseCreator({
|
|
73
|
+
clean: true,
|
|
74
|
+
describe: false,
|
|
75
|
+
steps: ({ name, caseConfig }) => {
|
|
76
|
+
return [
|
|
77
|
+
createMultiCompilerProcessor(name, caseConfig)
|
|
78
|
+
];
|
|
79
|
+
},
|
|
80
|
+
concurrent: false
|
|
81
|
+
});
|
|
82
|
+
function createMultiCompilerCase(name, src, dist, testConfig) {
|
|
83
|
+
let caseConfigList = require(testConfig);
|
|
84
|
+
if (!Array.isArray(caseConfigList)) {
|
|
85
|
+
caseConfigList = [caseConfigList];
|
|
86
|
+
}
|
|
87
|
+
for (let i = 0; i < caseConfigList.length; i++) {
|
|
88
|
+
const caseConfig = caseConfigList[i];
|
|
89
|
+
if (caseConfig.skip) {
|
|
90
|
+
it.skip(`${name}[${i}]`, () => { });
|
|
91
|
+
continue;
|
|
92
|
+
}
|
|
93
|
+
creator.create(`${name}[${i}]`, src, dist, undefined, {
|
|
94
|
+
caseConfig,
|
|
95
|
+
description: () => caseConfig.description
|
|
96
|
+
});
|
|
97
|
+
}
|
|
98
|
+
}
|
package/dist/case/normal.d.ts
CHANGED
|
@@ -1,2 +1,4 @@
|
|
|
1
1
|
export declare function createNormalCase(name: string, src: string, dist: string): void;
|
|
2
2
|
export declare function createHotNormalCase(name: string, src: string, dist: string): void;
|
|
3
|
+
export declare function createDevNormalCase(name: string, src: string, dist: string): void;
|
|
4
|
+
export declare function createProdNormalCase(name: string, src: string, dist: string): void;
|
package/dist/case/normal.js
CHANGED
|
@@ -5,14 +5,16 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
exports.createNormalCase = createNormalCase;
|
|
7
7
|
exports.createHotNormalCase = createHotNormalCase;
|
|
8
|
+
exports.createDevNormalCase = createDevNormalCase;
|
|
9
|
+
exports.createProdNormalCase = createProdNormalCase;
|
|
8
10
|
const node_fs_1 = __importDefault(require("node:fs"));
|
|
9
11
|
const node_path_1 = __importDefault(require("node:path"));
|
|
10
12
|
const core_1 = require("@rspack/core");
|
|
11
13
|
const creator_1 = require("../test/creator");
|
|
12
14
|
const common_1 = require("./common");
|
|
13
15
|
const runner_1 = require("./runner");
|
|
14
|
-
const NORMAL_CASES_ROOT = node_path_1.default.resolve(
|
|
15
|
-
const createCaseOptions = (hot) => {
|
|
16
|
+
const NORMAL_CASES_ROOT = node_path_1.default.resolve(__TEST_PATH__, "normalCases");
|
|
17
|
+
const createCaseOptions = (hot, mode) => {
|
|
16
18
|
return {
|
|
17
19
|
clean: true,
|
|
18
20
|
describe: false,
|
|
@@ -22,7 +24,7 @@ const createCaseOptions = (hot) => {
|
|
|
22
24
|
const compiler = (0, common_1.getCompiler)(context, name);
|
|
23
25
|
let options = defaultOptions(context, {
|
|
24
26
|
plugins: hot ? [new core_1.HotModuleReplacementPlugin()] : []
|
|
25
|
-
});
|
|
27
|
+
}, mode);
|
|
26
28
|
options = await (0, common_1.config)(context, name, ["rspack.config.js", "webpack.config.js"], options);
|
|
27
29
|
overrideOptions(context, options);
|
|
28
30
|
compiler.setOptions(options);
|
|
@@ -56,6 +58,14 @@ const hotCreator = new creator_1.BasicCaseCreator(createCaseOptions(true));
|
|
|
56
58
|
function createHotNormalCase(name, src, dist) {
|
|
57
59
|
hotCreator.create(name, src, dist);
|
|
58
60
|
}
|
|
61
|
+
const devCreator = new creator_1.BasicCaseCreator(createCaseOptions(false, "development"));
|
|
62
|
+
function createDevNormalCase(name, src, dist) {
|
|
63
|
+
devCreator.create(name, src, dist);
|
|
64
|
+
}
|
|
65
|
+
const prodCreator = new creator_1.BasicCaseCreator(createCaseOptions(false, "production"));
|
|
66
|
+
function createProdNormalCase(name, src, dist) {
|
|
67
|
+
prodCreator.create(name, src, dist);
|
|
68
|
+
}
|
|
59
69
|
function findBundle(context, options) {
|
|
60
70
|
const testConfig = context.getTestConfig();
|
|
61
71
|
if (typeof testConfig.findBundle === "function") {
|
|
@@ -64,7 +74,7 @@ function findBundle(context, options) {
|
|
|
64
74
|
const filename = options.output?.filename;
|
|
65
75
|
return typeof filename === "string" ? filename : undefined;
|
|
66
76
|
}
|
|
67
|
-
function defaultOptions(context, compilerOptions) {
|
|
77
|
+
function defaultOptions(context, compilerOptions, mode) {
|
|
68
78
|
let testConfig = {};
|
|
69
79
|
const testConfigPath = node_path_1.default.join(context.getSource(), "test.config.js");
|
|
70
80
|
if (node_fs_1.default.existsSync(testConfigPath)) {
|
|
@@ -80,11 +90,12 @@ function defaultOptions(context, compilerOptions) {
|
|
|
80
90
|
entry: `./${node_path_1.default.relative(NORMAL_CASES_ROOT, context.getSource())}/`,
|
|
81
91
|
target: compilerOptions?.target || "async-node",
|
|
82
92
|
devtool: compilerOptions?.devtool,
|
|
83
|
-
mode: compilerOptions?.mode || "none",
|
|
93
|
+
mode: compilerOptions?.mode || mode || "none",
|
|
84
94
|
optimization: compilerOptions?.mode
|
|
85
95
|
? {
|
|
86
|
-
|
|
96
|
+
emitOnErrors: true,
|
|
87
97
|
minimizer: [terserForTesting],
|
|
98
|
+
minimize: false,
|
|
88
99
|
...testConfig.optimization
|
|
89
100
|
}
|
|
90
101
|
: {
|
|
@@ -98,7 +109,7 @@ function defaultOptions(context, compilerOptions) {
|
|
|
98
109
|
usedExports: true,
|
|
99
110
|
mangleExports: true,
|
|
100
111
|
// CHANGE: rspack does not support `emitOnErrors` yet.
|
|
101
|
-
|
|
112
|
+
emitOnErrors: true,
|
|
102
113
|
concatenateModules: !!testConfig?.optimization?.concatenateModules,
|
|
103
114
|
innerGraph: true,
|
|
104
115
|
// CHANGE: size is not supported yet
|
|
@@ -106,6 +117,7 @@ function defaultOptions(context, compilerOptions) {
|
|
|
106
117
|
// chunkIds: "size",
|
|
107
118
|
moduleIds: "named",
|
|
108
119
|
chunkIds: "named",
|
|
120
|
+
minimize: false,
|
|
109
121
|
minimizer: [terserForTesting],
|
|
110
122
|
...compilerOptions?.optimization
|
|
111
123
|
},
|
|
@@ -181,17 +193,12 @@ function defaultOptions(context, compilerOptions) {
|
|
|
181
193
|
asyncWebAssembly: true,
|
|
182
194
|
topLevelAwait: true,
|
|
183
195
|
inlineConst: true,
|
|
184
|
-
lazyBarrel: true,
|
|
185
196
|
// CHANGE: rspack does not support `backCompat` yet.
|
|
186
197
|
// backCompat: false,
|
|
187
198
|
// CHANGE: Rspack enables `css` by default.
|
|
188
199
|
// Turning off here to fallback to webpack's default css processing logic.
|
|
189
200
|
...(compilerOptions?.module ? { outputModule: true } : {})
|
|
190
201
|
}
|
|
191
|
-
// infrastructureLogging: compilerOptions?.cache && {
|
|
192
|
-
// debug: true,
|
|
193
|
-
// console: createLogger(infraStructureLog)
|
|
194
|
-
// }
|
|
195
202
|
};
|
|
196
203
|
}
|
|
197
204
|
function overrideOptions(context, options) {
|
package/dist/case/stats-api.d.ts
CHANGED
|
@@ -1 +1,10 @@
|
|
|
1
|
+
import type { ECompilerType, ITestContext, TCompiler, TCompilerOptions, TCompilerStats } from "../type";
|
|
2
|
+
export type TStatsAPICaseConfig = {
|
|
3
|
+
description: string;
|
|
4
|
+
options?: (context: ITestContext) => TCompilerOptions<ECompilerType.Rspack>;
|
|
5
|
+
snapshotName?: string;
|
|
6
|
+
compiler?: (context: ITestContext, compiler: TCompiler<ECompilerType.Rspack>) => Promise<void>;
|
|
7
|
+
build?: (context: ITestContext, compiler: TCompiler<ECompilerType.Rspack>) => Promise<void>;
|
|
8
|
+
check?: (stats: TCompilerStats<ECompilerType.Rspack>, compiler: TCompiler<ECompilerType.Rspack>) => Promise<void>;
|
|
9
|
+
};
|
|
1
10
|
export declare function createStatsAPICase(name: string, src: string, dist: string, testConfig: string): void;
|
package/dist/case/stats-api.js
CHANGED
|
@@ -2,42 +2,53 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.createStatsAPICase = createStatsAPICase;
|
|
4
4
|
const memfs_1 = require("memfs");
|
|
5
|
-
const
|
|
5
|
+
const creator_1 = require("../test/creator");
|
|
6
6
|
const common_1 = require("./common");
|
|
7
7
|
let addedSerializer = false;
|
|
8
|
+
const creator = new creator_1.BasicCaseCreator({
|
|
9
|
+
clean: true,
|
|
10
|
+
describe: true,
|
|
11
|
+
steps: ({ name, caseConfig }) => {
|
|
12
|
+
const config = caseConfig;
|
|
13
|
+
return [
|
|
14
|
+
{
|
|
15
|
+
config: async (context) => {
|
|
16
|
+
const compiler = (0, common_1.getCompiler)(context, name);
|
|
17
|
+
compiler.setOptions(options(context, config.options));
|
|
18
|
+
},
|
|
19
|
+
compiler: async (context) => {
|
|
20
|
+
const compilerManager = (0, common_1.getCompiler)(context, name);
|
|
21
|
+
compilerManager.createCompiler();
|
|
22
|
+
compiler(context, compilerManager.getCompiler(), config.compiler);
|
|
23
|
+
},
|
|
24
|
+
build: async (context) => {
|
|
25
|
+
const compiler = (0, common_1.getCompiler)(context, name);
|
|
26
|
+
if (typeof config.build === "function") {
|
|
27
|
+
await config.build(context, compiler.getCompiler());
|
|
28
|
+
}
|
|
29
|
+
else {
|
|
30
|
+
await compiler.build();
|
|
31
|
+
}
|
|
32
|
+
},
|
|
33
|
+
run: async (env, context) => {
|
|
34
|
+
// no need to run, just check the snapshot of diagnostics
|
|
35
|
+
},
|
|
36
|
+
check: async (env, context) => {
|
|
37
|
+
await check(env, context, name, config.check);
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
];
|
|
41
|
+
},
|
|
42
|
+
concurrent: true
|
|
43
|
+
});
|
|
8
44
|
function createStatsAPICase(name, src, dist, testConfig) {
|
|
9
45
|
if (!addedSerializer) {
|
|
10
46
|
addedSerializer = true;
|
|
11
47
|
}
|
|
12
48
|
const caseConfig = require(testConfig);
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
config: async (context) => {
|
|
17
|
-
const compiler = (0, common_1.getCompiler)(context, name);
|
|
18
|
-
compiler.setOptions(options(context, caseConfig.options));
|
|
19
|
-
},
|
|
20
|
-
compiler: async (context) => {
|
|
21
|
-
const compilerManager = (0, common_1.getCompiler)(context, name);
|
|
22
|
-
compilerManager.createCompiler();
|
|
23
|
-
compiler(context, compilerManager.getCompiler(), caseConfig.compiler);
|
|
24
|
-
},
|
|
25
|
-
build: async (context) => {
|
|
26
|
-
const compiler = (0, common_1.getCompiler)(context, name);
|
|
27
|
-
if (typeof caseConfig.build === "function") {
|
|
28
|
-
await caseConfig.build(context, compiler.getCompiler());
|
|
29
|
-
}
|
|
30
|
-
else {
|
|
31
|
-
await compiler.build();
|
|
32
|
-
}
|
|
33
|
-
},
|
|
34
|
-
run: async (env, context) => {
|
|
35
|
-
// no need to run, just check the snapshot of diagnostics
|
|
36
|
-
},
|
|
37
|
-
check: async (env, context) => {
|
|
38
|
-
await check(env, context, name, caseConfig.check);
|
|
39
|
-
}
|
|
40
|
-
});
|
|
49
|
+
creator.create(name, src, dist, undefined, {
|
|
50
|
+
caseConfig,
|
|
51
|
+
description: () => caseConfig.description
|
|
41
52
|
});
|
|
42
53
|
}
|
|
43
54
|
function options(context, custom) {
|
|
@@ -1 +1,11 @@
|
|
|
1
|
+
import type { ECompilerType, ITestContext, ITestEnv, TCompilerOptions } from "../type";
|
|
2
|
+
export declare function createStatsProcessor(name: string, defaultOptions: (index: number, context: ITestContext) => TCompilerOptions<ECompilerType.Rspack>, overrideOptions: (index: number, context: ITestContext, options: TCompilerOptions<ECompilerType.Rspack>) => void): {
|
|
3
|
+
before: (context: ITestContext) => Promise<void>;
|
|
4
|
+
config: (context: ITestContext) => Promise<void>;
|
|
5
|
+
compiler: (context: ITestContext) => Promise<void>;
|
|
6
|
+
build: (context: ITestContext) => Promise<void>;
|
|
7
|
+
run: (env: ITestEnv, context: ITestContext) => Promise<void>;
|
|
8
|
+
check: (env: ITestEnv, context: ITestContext) => Promise<void>;
|
|
9
|
+
after: (context: ITestContext) => Promise<void>;
|
|
10
|
+
};
|
|
1
11
|
export declare function createStatsOutputCase(name: string, src: string, dist: string): void;
|
|
@@ -3,6 +3,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.createStatsProcessor = createStatsProcessor;
|
|
6
7
|
exports.createStatsOutputCase = createStatsOutputCase;
|
|
7
8
|
const node_path_1 = __importDefault(require("node:path"));
|
|
8
9
|
const fs_extra_1 = __importDefault(require("fs-extra"));
|
|
@@ -11,7 +12,7 @@ const captureStdio_1 = __importDefault(require("../helper/legacy/captureStdio"))
|
|
|
11
12
|
const creator_1 = require("../test/creator");
|
|
12
13
|
const common_1 = require("./common");
|
|
13
14
|
const REG_ERROR_CASE = /error$/;
|
|
14
|
-
function createStatsProcessor(name) {
|
|
15
|
+
function createStatsProcessor(name, defaultOptions, overrideOptions) {
|
|
15
16
|
const writeStatsOuptut = false;
|
|
16
17
|
const snapshotName = "stats.txt";
|
|
17
18
|
let stderr = null;
|
|
@@ -43,14 +44,17 @@ function createStatsProcessor(name) {
|
|
|
43
44
|
const creator = new creator_1.BasicCaseCreator({
|
|
44
45
|
clean: true,
|
|
45
46
|
describe: false,
|
|
46
|
-
steps: ({ name }) => [
|
|
47
|
+
steps: ({ name }) => [
|
|
48
|
+
createStatsProcessor(name, defaultOptions, overrideOptions)
|
|
49
|
+
],
|
|
47
50
|
description: () => "should print correct stats for"
|
|
48
51
|
});
|
|
49
52
|
function createStatsOutputCase(name, src, dist) {
|
|
50
53
|
creator.create(name, src, dist);
|
|
51
54
|
}
|
|
52
55
|
function defaultOptions(index, context) {
|
|
53
|
-
if (fs_extra_1.default.existsSync(node_path_1.default.join(context.getSource(), "rspack.config.js"))
|
|
56
|
+
if (fs_extra_1.default.existsSync(node_path_1.default.join(context.getSource(), "rspack.config.js")) ||
|
|
57
|
+
fs_extra_1.default.existsSync(node_path_1.default.join(context.getSource(), "webpack.config.js"))) {
|
|
54
58
|
return {
|
|
55
59
|
experiments: {
|
|
56
60
|
css: true,
|
|
@@ -80,8 +84,7 @@ function defaultOptions(index, context) {
|
|
|
80
84
|
force: false
|
|
81
85
|
}
|
|
82
86
|
},
|
|
83
|
-
inlineConst: true
|
|
84
|
-
lazyBarrel: true
|
|
87
|
+
inlineConst: true
|
|
85
88
|
}
|
|
86
89
|
};
|
|
87
90
|
}
|
|
@@ -171,7 +174,8 @@ async function check(env, context, name, writeStatsOuptut, snapshot, stderr) {
|
|
|
171
174
|
// CHANGE: The time unit display in Rspack is second
|
|
172
175
|
.replace(/[.0-9]+(\s?s)/g, "X$1")
|
|
173
176
|
// CHANGE: Replace bundle size, since bundle sizes may differ between platforms
|
|
174
|
-
.replace(/[0-9]+\.?[0-9]+ KiB/g, "xx KiB")
|
|
177
|
+
.replace(/[0-9]+\.?[0-9]+ KiB/g, "xx KiB")
|
|
178
|
+
.replace(/[0-9]+ ms/g, "xx ms");
|
|
175
179
|
}
|
|
176
180
|
const snapshotPath = node_path_1.default.isAbsolute(snapshot)
|
|
177
181
|
? snapshot
|
package/dist/case/watch.d.ts
CHANGED
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
import { type ECompilerType, type ITestContext, type ITestEnv, type ITestRunner } from "../type";
|
|
2
|
-
export declare function createWatchInitialProcessor(name: string, tempDir: string, step: string, watchState: Record<string, any>, { incremental, nativeWatcher
|
|
2
|
+
export declare function createWatchInitialProcessor(name: string, tempDir: string, step: string, watchState: Record<string, any>, { incremental, nativeWatcher }?: {
|
|
3
3
|
incremental?: boolean | undefined;
|
|
4
4
|
nativeWatcher?: boolean | undefined;
|
|
5
|
-
ignoreNotFriendlyForIncrementalWarnings?: boolean | undefined;
|
|
6
5
|
}): {
|
|
7
6
|
before: (context: ITestContext) => Promise<void>;
|
|
8
7
|
config: <T extends ECompilerType.Rspack>(context: ITestContext) => Promise<void>;
|
|
@@ -11,10 +10,9 @@ export declare function createWatchInitialProcessor(name: string, tempDir: strin
|
|
|
11
10
|
run: (env: ITestEnv, context: ITestContext) => Promise<void>;
|
|
12
11
|
check: <T extends ECompilerType.Rspack>(env: ITestEnv, context: ITestContext) => Promise<void>;
|
|
13
12
|
};
|
|
14
|
-
export declare function createWatchStepProcessor(name: string, tempDir: string, step: string, watchState: Record<string, any>, { incremental, nativeWatcher
|
|
13
|
+
export declare function createWatchStepProcessor(name: string, tempDir: string, step: string, watchState: Record<string, any>, { incremental, nativeWatcher }?: {
|
|
15
14
|
incremental?: boolean | undefined;
|
|
16
15
|
nativeWatcher?: boolean | undefined;
|
|
17
|
-
ignoreNotFriendlyForIncrementalWarnings?: boolean | undefined;
|
|
18
16
|
}): {
|
|
19
17
|
before: (context: ITestContext) => Promise<void>;
|
|
20
18
|
config: <T extends ECompilerType.Rspack>(context: ITestContext) => Promise<void>;
|
package/dist/case/watch.js
CHANGED
|
@@ -19,9 +19,7 @@ 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
|
-
|
|
23
|
-
const currentWatchStepModulePath = node_path_1.default.resolve(__dirname, "../helper/util/currentWatchStep");
|
|
24
|
-
function createWatchInitialProcessor(name, tempDir, step, watchState, { incremental = false, nativeWatcher = false, ignoreNotFriendlyForIncrementalWarnings = false } = {}) {
|
|
22
|
+
function createWatchInitialProcessor(name, tempDir, step, watchState, { incremental = false, nativeWatcher = false } = {}) {
|
|
25
23
|
const watchContext = {
|
|
26
24
|
currentTriggerFilename: null,
|
|
27
25
|
lastHash: null,
|
|
@@ -35,12 +33,13 @@ function createWatchInitialProcessor(name, tempDir, step, watchState, { incremen
|
|
|
35
33
|
context.setValue(name, "watchContext", watchContext);
|
|
36
34
|
},
|
|
37
35
|
config: async (context) => {
|
|
36
|
+
const testConfig = context.getTestConfig();
|
|
38
37
|
const multiCompilerOptions = [];
|
|
39
38
|
const caseOptions = (0, helper_1.readConfigFile)(["rspack.config.js", "webpack.config.js"].map(i => context.getSource(i)));
|
|
40
39
|
for (const [index, options] of caseOptions.entries()) {
|
|
41
40
|
const compilerOptions = (0, webpack_merge_1.default)(defaultOptions({
|
|
42
41
|
incremental,
|
|
43
|
-
ignoreNotFriendlyForIncrementalWarnings
|
|
42
|
+
ignoreNotFriendlyForIncrementalWarnings: testConfig.ignoreNotFriendlyForIncrementalWarnings
|
|
44
43
|
}), options);
|
|
45
44
|
overrideOptions(index, context, compilerOptions, tempDir, nativeWatcher);
|
|
46
45
|
multiCompilerOptions.push(compilerOptions);
|
|
@@ -60,8 +59,6 @@ function createWatchInitialProcessor(name, tempDir, step, watchState, { incremen
|
|
|
60
59
|
},
|
|
61
60
|
build: async (context) => {
|
|
62
61
|
const compiler = (0, common_1.getCompiler)(context, name);
|
|
63
|
-
const currentWatchStepModule = require(currentWatchStepModulePath);
|
|
64
|
-
currentWatchStepModule.step[name] = watchContext.step;
|
|
65
62
|
node_fs_1.default.mkdirSync(watchContext.tempDir, { recursive: true });
|
|
66
63
|
(0, copyDiff_1.default)(node_path_1.default.join(context.getSource(), watchContext.step), watchContext.tempDir, true);
|
|
67
64
|
const task = new Promise((resolve, reject) => {
|
|
@@ -164,16 +161,13 @@ function createWatchInitialProcessor(name, tempDir, step, watchState, { incremen
|
|
|
164
161
|
}
|
|
165
162
|
};
|
|
166
163
|
}
|
|
167
|
-
function createWatchStepProcessor(name, tempDir, step, watchState, { incremental = false, nativeWatcher = false
|
|
168
|
-
const processor = createWatchInitialProcessor(name, tempDir, step, watchState, { incremental
|
|
164
|
+
function createWatchStepProcessor(name, tempDir, step, watchState, { incremental = false, nativeWatcher = false } = {}) {
|
|
165
|
+
const processor = createWatchInitialProcessor(name, tempDir, step, watchState, { incremental });
|
|
169
166
|
processor.compiler = async (context) => {
|
|
170
167
|
// do nothing
|
|
171
168
|
};
|
|
172
169
|
processor.build = async (context) => {
|
|
173
|
-
const watchContext = context.getValue(name, "watchContext");
|
|
174
170
|
const compiler = (0, common_1.getCompiler)(context, name);
|
|
175
|
-
const currentWatchStepModule = require(currentWatchStepModulePath);
|
|
176
|
-
currentWatchStepModule.step[name] = watchContext.step;
|
|
177
171
|
const task = new Promise((resolve, reject) => {
|
|
178
172
|
compiler.getEmitter().once(compiler_1.ECompilerEvent.Build, (e, stats) => {
|
|
179
173
|
if (e)
|
package/dist/compare/compare.js
CHANGED
|
@@ -13,7 +13,6 @@ const helper_1 = require("../helper");
|
|
|
13
13
|
const type_1 = require("../type");
|
|
14
14
|
const format_code_1 = require("./format-code");
|
|
15
15
|
const replace_runtime_module_name_1 = require("./replace-runtime-module-name");
|
|
16
|
-
const WORKSPACE = node_path_1.default.resolve(__dirname, "../../../..");
|
|
17
16
|
function compareFile(sourceFile, distFile, compareOptions) {
|
|
18
17
|
const result = {
|
|
19
18
|
type: type_1.ECompareResultType.Same,
|
|
@@ -49,7 +48,9 @@ function compareFile(sourceFile, distFile, compareOptions) {
|
|
|
49
48
|
}
|
|
50
49
|
return res;
|
|
51
50
|
}
|
|
52
|
-
const sourceContent = (0, replace_runtime_module_name_1.replaceRuntimeModuleName)(fs_extra_1.default
|
|
51
|
+
const sourceContent = (0, replace_runtime_module_name_1.replaceRuntimeModuleName)(fs_extra_1.default
|
|
52
|
+
.readFileSync(sourceFile, "utf-8")
|
|
53
|
+
.replaceAll(__ROOT_PATH__, "__WORKSPACE__"));
|
|
53
54
|
const sourceModules = (0, helper_1.parseModules)(sourceContent, {
|
|
54
55
|
bootstrap: compareOptions.bootstrap,
|
|
55
56
|
renameModule: compareOptions.renameModule
|
|
@@ -66,7 +67,9 @@ function compareFile(sourceFile, distFile, compareOptions) {
|
|
|
66
67
|
distModules = JSON.parse(fs_extra_1.default.readFileSync(compareOptions.snapshot, "utf-8"));
|
|
67
68
|
}
|
|
68
69
|
else {
|
|
69
|
-
const distContent = (0, replace_runtime_module_name_1.replaceRuntimeModuleName)(fs_extra_1.default
|
|
70
|
+
const distContent = (0, replace_runtime_module_name_1.replaceRuntimeModuleName)(fs_extra_1.default
|
|
71
|
+
.readFileSync(distFile, "utf-8")
|
|
72
|
+
.replaceAll(__ROOT_PATH__, "__WORKSPACE__"));
|
|
70
73
|
distModules = (0, helper_1.parseModules)(distContent, {
|
|
71
74
|
bootstrap: compareOptions.bootstrap,
|
|
72
75
|
renameModule: compareOptions.renameModule
|
package/dist/helper/directory.js
CHANGED
|
@@ -31,7 +31,7 @@ function describeByWalk(testFile, createCase, options = {}) {
|
|
|
31
31
|
.filter(folder => {
|
|
32
32
|
if (options.exclude) {
|
|
33
33
|
if (options.exclude.some(exclude => {
|
|
34
|
-
return exclude.test(folder);
|
|
34
|
+
return exclude.test(node_path_1.default.join(dirname, folder).replace(/\\/g, "/"));
|
|
35
35
|
})) {
|
|
36
36
|
return false;
|
|
37
37
|
}
|
|
@@ -1,10 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
3
|
exports.normalizePlaceholder = void 0;
|
|
7
|
-
const node_path_1 = __importDefault(require("node:path"));
|
|
8
4
|
const path_serializer_1 = require("path-serializer");
|
|
9
5
|
// 1. escapeEOL \r\n -> \n
|
|
10
6
|
// 2. replace <RSPACK_ROOT> etc
|
|
@@ -13,14 +9,18 @@ const placeholderSerializer = (0, path_serializer_1.createSnapshotSerializer)({
|
|
|
13
9
|
root: __dirname.includes("node_modules")
|
|
14
10
|
? // Use `process.cwd()` when using outside Rspack
|
|
15
11
|
process.cwd()
|
|
16
|
-
:
|
|
12
|
+
: __ROOT_PATH__,
|
|
17
13
|
replace: [
|
|
18
14
|
{
|
|
19
|
-
match:
|
|
15
|
+
match: __RSPACK_TEST_TOOLS_PATH__,
|
|
20
16
|
mark: "test_tools_root"
|
|
21
17
|
},
|
|
22
18
|
{
|
|
23
|
-
match:
|
|
19
|
+
match: __TEST_PATH__,
|
|
20
|
+
mark: "test_root"
|
|
21
|
+
},
|
|
22
|
+
{
|
|
23
|
+
match: __RSPACK_PATH__,
|
|
24
24
|
mark: "rspack_root"
|
|
25
25
|
},
|
|
26
26
|
{
|
|
@@ -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];
|
|
@@ -71,7 +68,12 @@ class HotUpdatePlugin {
|
|
|
71
68
|
return;
|
|
72
69
|
}
|
|
73
70
|
this.initialized = true;
|
|
74
|
-
|
|
71
|
+
try {
|
|
72
|
+
await promises_1.default.rmdir(this.tempDir, { recursive: true });
|
|
73
|
+
}
|
|
74
|
+
catch (_e) {
|
|
75
|
+
// empty
|
|
76
|
+
}
|
|
75
77
|
await promises_1.default.cp(this.projectDir, this.tempDir, { recursive: true });
|
|
76
78
|
await loopFile(this.tempDir, (filePath, content) => {
|
|
77
79
|
const contents = content.split(/---+\r?\n/g);
|
|
@@ -81,13 +83,16 @@ class HotUpdatePlugin {
|
|
|
81
83
|
});
|
|
82
84
|
await this.updateFiles();
|
|
83
85
|
}
|
|
86
|
+
getModifiedFiles() {
|
|
87
|
+
return Object.keys(this.files);
|
|
88
|
+
}
|
|
84
89
|
getUpdateIndex() {
|
|
85
90
|
return this.updateIndex;
|
|
86
91
|
}
|
|
87
92
|
getTotalUpdates() {
|
|
88
93
|
return Object.values(this.files).reduce((max, item) => {
|
|
89
94
|
return Math.max(max, item.length);
|
|
90
|
-
},
|
|
95
|
+
}, 1);
|
|
91
96
|
}
|
|
92
97
|
async goNext() {
|
|
93
98
|
this.updateIndex++;
|