@rspack-canary/test-tools 1.5.6-canary-e598f284-20250921173624 → 1.5.7-canary-a3406c0a-20250922173625
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.d.ts +2 -0
- package/dist/case/builtin.js +153 -2
- package/dist/case/cache.js +115 -9
- package/dist/case/compiler.js +1 -1
- package/dist/case/config.d.ts +4 -1
- package/dist/case/config.js +80 -2
- package/dist/case/defaults.d.ts +11 -3
- package/dist/case/defaults.js +47 -2
- package/dist/case/diagnostic.d.ts +6 -0
- package/dist/case/diagnostic.js +109 -9
- package/dist/case/error.d.ts +2 -2
- package/dist/case/error.js +79 -2
- package/dist/case/hash.js +61 -7
- package/dist/case/hook.d.ts +35 -3
- package/dist/case/hook.js +185 -4
- package/dist/case/hot-step.d.ts +1 -1
- package/dist/case/hot-step.js +302 -8
- package/dist/case/hot.d.ts +8 -1
- package/dist/case/hot.js +147 -7
- package/dist/case/incremental.js +21 -8
- package/dist/case/index.d.ts +20 -20
- package/dist/case/index.js +44 -34
- package/dist/case/normal.js +152 -5
- package/dist/case/serial.js +7 -3
- package/dist/case/stats-api.d.ts +0 -5
- package/dist/case/stats-api.js +33 -2
- package/dist/case/stats-output.js +200 -10
- package/dist/case/treeshaking.js +19 -3
- package/dist/helper/plugins/hot-update.d.ts +2 -2
- package/dist/processor/basic.d.ts +4 -1
- package/dist/processor/basic.js +20 -10
- package/dist/processor/index.d.ts +0 -14
- package/dist/processor/index.js +0 -14
- package/dist/processor/multi.d.ts +3 -1
- package/dist/processor/multi.js +2 -0
- package/dist/processor/simple.d.ts +1 -1
- package/dist/processor/simple.js +4 -4
- package/dist/processor/snapshot.js +4 -3
- package/dist/type.d.ts +1 -1
- package/package.json +4 -4
- package/dist/processor/builtin.d.ts +0 -9
- package/dist/processor/builtin.js +0 -171
- package/dist/processor/cache.d.ts +0 -20
- package/dist/processor/cache.js +0 -131
- package/dist/processor/config.d.ts +0 -11
- package/dist/processor/config.js +0 -88
- package/dist/processor/defaults.d.ts +0 -30
- package/dist/processor/defaults.js +0 -72
- package/dist/processor/diagnostic.d.ts +0 -15
- package/dist/processor/diagnostic.js +0 -104
- package/dist/processor/error.d.ts +0 -23
- package/dist/processor/error.js +0 -95
- package/dist/processor/hash.d.ts +0 -10
- package/dist/processor/hash.js +0 -65
- package/dist/processor/hook.d.ts +0 -44
- package/dist/processor/hook.js +0 -206
- package/dist/processor/hot-incremental.d.ts +0 -14
- package/dist/processor/hot-incremental.js +0 -43
- package/dist/processor/hot-step.d.ts +0 -18
- package/dist/processor/hot-step.js +0 -307
- package/dist/processor/hot.d.ts +0 -17
- package/dist/processor/hot.js +0 -147
- package/dist/processor/normal.d.ts +0 -12
- package/dist/processor/normal.js +0 -170
- package/dist/processor/stats-api.d.ts +0 -18
- package/dist/processor/stats-api.js +0 -48
- package/dist/processor/stats.d.ts +0 -18
- package/dist/processor/stats.js +0 -206
- package/dist/processor/treeshaking.d.ts +0 -10
- package/dist/processor/treeshaking.js +0 -33
package/dist/processor/basic.js
CHANGED
|
@@ -15,7 +15,7 @@ class BasicProcessor {
|
|
|
15
15
|
async config(context) {
|
|
16
16
|
const compiler = this.getCompiler(context);
|
|
17
17
|
if (typeof this._options.defaultOptions === "function") {
|
|
18
|
-
compiler.setOptions(this._options.defaultOptions.
|
|
18
|
+
compiler.setOptions(this._options.defaultOptions.call(this, context));
|
|
19
19
|
}
|
|
20
20
|
if (Array.isArray(this._options.configFiles)) {
|
|
21
21
|
const fileOptions = (0, helper_1.readConfigFile)(this._options.configFiles.map(i => context.getSource(i)))[0];
|
|
@@ -23,16 +23,24 @@ class BasicProcessor {
|
|
|
23
23
|
}
|
|
24
24
|
if (typeof this._options.overrideOptions === "function") {
|
|
25
25
|
const compilerOptions = compiler.getOptions();
|
|
26
|
-
this._options.overrideOptions.
|
|
26
|
+
this._options.overrideOptions.call(this, context, compilerOptions);
|
|
27
27
|
}
|
|
28
28
|
}
|
|
29
29
|
async compiler(context) {
|
|
30
30
|
const compiler = this.getCompiler(context);
|
|
31
31
|
compiler.createCompiler();
|
|
32
|
+
if (typeof this._options.compiler === "function") {
|
|
33
|
+
await this._options.compiler.call(this, context, compiler.getCompiler());
|
|
34
|
+
}
|
|
32
35
|
}
|
|
33
36
|
async build(context) {
|
|
34
37
|
const compiler = this.getCompiler(context);
|
|
35
|
-
|
|
38
|
+
if (typeof this._options.build === "function") {
|
|
39
|
+
await this._options.build.call(this, context, compiler.getCompiler());
|
|
40
|
+
}
|
|
41
|
+
else {
|
|
42
|
+
await compiler.build();
|
|
43
|
+
}
|
|
36
44
|
}
|
|
37
45
|
async run(env, context) {
|
|
38
46
|
if (!this._options.runable)
|
|
@@ -45,17 +53,14 @@ class BasicProcessor {
|
|
|
45
53
|
}
|
|
46
54
|
const compiler = this.getCompiler(context);
|
|
47
55
|
if (typeof testConfig.beforeExecute === "function") {
|
|
48
|
-
testConfig.beforeExecute(compiler.getOptions());
|
|
56
|
+
testConfig.beforeExecute.call(this, compiler.getOptions());
|
|
49
57
|
}
|
|
50
58
|
let bundles;
|
|
51
59
|
if (testConfig.bundlePath) {
|
|
52
60
|
bundles = testConfig.bundlePath;
|
|
53
61
|
}
|
|
54
62
|
else if (typeof this._options.findBundle === "function") {
|
|
55
|
-
bundles = this._options.findBundle.
|
|
56
|
-
context,
|
|
57
|
-
compiler.getOptions()
|
|
58
|
-
]);
|
|
63
|
+
bundles = this._options.findBundle.call(this, context, compiler.getOptions());
|
|
59
64
|
}
|
|
60
65
|
else {
|
|
61
66
|
bundles = [];
|
|
@@ -83,19 +88,24 @@ class BasicProcessor {
|
|
|
83
88
|
const results = context.getValue(this._options.name, "modules") || [];
|
|
84
89
|
await Promise.all(results);
|
|
85
90
|
if (typeof testConfig.afterExecute === "function") {
|
|
86
|
-
testConfig.afterExecute(compiler.getOptions());
|
|
91
|
+
testConfig.afterExecute.call(this, compiler.getOptions());
|
|
87
92
|
}
|
|
88
93
|
}
|
|
89
94
|
async check(env, context) {
|
|
90
95
|
const testConfig = context.getTestConfig();
|
|
91
96
|
if (testConfig.noTests)
|
|
92
97
|
return;
|
|
98
|
+
const compiler = this.getCompiler(context);
|
|
99
|
+
if (typeof this._options.check === "function") {
|
|
100
|
+
const stats = compiler.getStats();
|
|
101
|
+
await this._options.check.call(this, env, context, compiler.getCompiler(), stats);
|
|
102
|
+
return;
|
|
103
|
+
}
|
|
93
104
|
const errors = (context.getError(this._options.name) || []).map(e => ({
|
|
94
105
|
message: e.message,
|
|
95
106
|
stack: e.stack
|
|
96
107
|
}));
|
|
97
108
|
const warnings = [];
|
|
98
|
-
const compiler = this.getCompiler(context);
|
|
99
109
|
const stats = compiler.getStats();
|
|
100
110
|
const options = compiler.getOptions();
|
|
101
111
|
if (stats) {
|
|
@@ -1,20 +1,6 @@
|
|
|
1
1
|
export * from "./basic";
|
|
2
|
-
export * from "./builtin";
|
|
3
|
-
export * from "./cache";
|
|
4
|
-
export * from "./config";
|
|
5
|
-
export * from "./defaults";
|
|
6
|
-
export * from "./diagnostic";
|
|
7
2
|
export * from "./diff";
|
|
8
|
-
export * from "./error";
|
|
9
|
-
export * from "./hash";
|
|
10
|
-
export * from "./hook";
|
|
11
|
-
export * from "./hot";
|
|
12
|
-
export * from "./hot-incremental";
|
|
13
|
-
export * from "./hot-step";
|
|
14
3
|
export * from "./multi";
|
|
15
|
-
export * from "./normal";
|
|
16
4
|
export * from "./simple";
|
|
17
5
|
export * from "./snapshot";
|
|
18
|
-
export * from "./stats";
|
|
19
|
-
export * from "./stats-api";
|
|
20
6
|
export * from "./watch";
|
package/dist/processor/index.js
CHANGED
|
@@ -15,22 +15,8 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
15
15
|
};
|
|
16
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
17
|
__exportStar(require("./basic"), exports);
|
|
18
|
-
__exportStar(require("./builtin"), exports);
|
|
19
|
-
__exportStar(require("./cache"), exports);
|
|
20
|
-
__exportStar(require("./config"), exports);
|
|
21
|
-
__exportStar(require("./defaults"), exports);
|
|
22
|
-
__exportStar(require("./diagnostic"), exports);
|
|
23
18
|
__exportStar(require("./diff"), exports);
|
|
24
|
-
__exportStar(require("./error"), exports);
|
|
25
|
-
__exportStar(require("./hash"), exports);
|
|
26
|
-
__exportStar(require("./hook"), exports);
|
|
27
|
-
__exportStar(require("./hot"), exports);
|
|
28
|
-
__exportStar(require("./hot-incremental"), exports);
|
|
29
|
-
__exportStar(require("./hot-step"), exports);
|
|
30
19
|
__exportStar(require("./multi"), exports);
|
|
31
|
-
__exportStar(require("./normal"), exports);
|
|
32
20
|
__exportStar(require("./simple"), exports);
|
|
33
21
|
__exportStar(require("./snapshot"), exports);
|
|
34
|
-
__exportStar(require("./stats"), exports);
|
|
35
|
-
__exportStar(require("./stats-api"), exports);
|
|
36
22
|
__exportStar(require("./watch"), exports);
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { ECompilerType, ITestContext, ITestProcessor, TCompilerOptions } from "../type";
|
|
1
|
+
import type { ECompilerType, ITestContext, ITestEnv, ITestProcessor, TCompiler, TCompilerMultiStats, TCompilerOptions, TCompilerStats } from "../type";
|
|
2
2
|
import { BasicProcessor } from "./basic";
|
|
3
3
|
export interface IMultiTaskProcessorOptions<T extends ECompilerType> {
|
|
4
4
|
defaultOptions?: (index: number, context: ITestContext) => TCompilerOptions<T>;
|
|
@@ -8,6 +8,8 @@ export interface IMultiTaskProcessorOptions<T extends ECompilerType> {
|
|
|
8
8
|
name: string;
|
|
9
9
|
configFiles?: string[];
|
|
10
10
|
runable: boolean;
|
|
11
|
+
compiler?: (context: ITestContext, compiler: TCompiler<T>) => Promise<void>;
|
|
12
|
+
check?: (env: ITestEnv, context: ITestContext, compiler: TCompiler<T>, stats: TCompilerStats<T> | TCompilerMultiStats<T> | null) => Promise<void>;
|
|
11
13
|
}
|
|
12
14
|
export declare class MultiTaskProcessor<T extends ECompilerType> extends BasicProcessor<T> implements ITestProcessor {
|
|
13
15
|
protected _multiOptions: IMultiTaskProcessorOptions<T>;
|
package/dist/processor/multi.js
CHANGED
|
@@ -35,6 +35,8 @@ class MultiTaskProcessor extends basic_1.BasicProcessor {
|
|
|
35
35
|
context.setValue(_multiOptions.name, "multiFileIndexMap", multiFileIndexMap);
|
|
36
36
|
return result;
|
|
37
37
|
},
|
|
38
|
+
check: _multiOptions.check,
|
|
39
|
+
compiler: _multiOptions.compiler,
|
|
38
40
|
name: _multiOptions.name
|
|
39
41
|
});
|
|
40
42
|
this._multiOptions = _multiOptions;
|
|
@@ -6,7 +6,7 @@ export interface ISimpleProcessorOptions<T extends ECompilerType> {
|
|
|
6
6
|
name: string;
|
|
7
7
|
build?: (context: ITestContext, compiler: TCompiler<T>) => Promise<void>;
|
|
8
8
|
compiler?: (context: ITestContext, compiler: TCompiler<T>) => Promise<void>;
|
|
9
|
-
check?: (context: ITestContext, compiler: TCompiler<T>, stats: TCompilerStats<T>) => Promise<void>;
|
|
9
|
+
check?: (env: ITestEnv, context: ITestContext, compiler: TCompiler<T>, stats: TCompilerStats<T>) => Promise<void>;
|
|
10
10
|
}
|
|
11
11
|
export declare class SimpleTaskProcessor<T extends ECompilerType> implements ITestProcessor {
|
|
12
12
|
protected _options: ISimpleProcessorOptions<T>;
|
package/dist/processor/simple.js
CHANGED
|
@@ -8,7 +8,7 @@ class SimpleTaskProcessor {
|
|
|
8
8
|
async config(context) {
|
|
9
9
|
const compiler = this.getCompiler(context);
|
|
10
10
|
if (typeof this._options.options === "function") {
|
|
11
|
-
compiler.setOptions(this._options.options(context));
|
|
11
|
+
compiler.setOptions(this._options.options.call(this, context));
|
|
12
12
|
}
|
|
13
13
|
}
|
|
14
14
|
async compiler(context) {
|
|
@@ -17,13 +17,13 @@ class SimpleTaskProcessor {
|
|
|
17
17
|
? compiler.createCompilerWithCallback(this._options.compilerCallback)
|
|
18
18
|
: compiler.createCompiler();
|
|
19
19
|
if (typeof this._options.compiler === "function") {
|
|
20
|
-
await this._options.compiler(context, instance);
|
|
20
|
+
await this._options.compiler.call(this, context, instance);
|
|
21
21
|
}
|
|
22
22
|
}
|
|
23
23
|
async build(context) {
|
|
24
24
|
const compiler = this.getCompiler(context);
|
|
25
25
|
if (typeof this._options.build === "function") {
|
|
26
|
-
await this._options.build(context, compiler.getCompiler());
|
|
26
|
+
await this._options.build.call(this, context, compiler.getCompiler());
|
|
27
27
|
}
|
|
28
28
|
else {
|
|
29
29
|
await compiler.build();
|
|
@@ -34,7 +34,7 @@ class SimpleTaskProcessor {
|
|
|
34
34
|
const compiler = this.getCompiler(context);
|
|
35
35
|
const stats = compiler.getStats();
|
|
36
36
|
if (typeof this._options.check === "function") {
|
|
37
|
-
await this._options.check(context, compiler.getCompiler(), stats);
|
|
37
|
+
await this._options.check.call(this, env, context, compiler.getCompiler(), stats);
|
|
38
38
|
}
|
|
39
39
|
}
|
|
40
40
|
async before(context) { }
|
|
@@ -5,6 +5,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
exports.SnapshotProcessor = void 0;
|
|
7
7
|
const node_path_1 = __importDefault(require("node:path"));
|
|
8
|
+
const placeholder_1 = require("../helper/expect/placeholder");
|
|
8
9
|
const basic_1 = require("./basic");
|
|
9
10
|
class SnapshotProcessor extends basic_1.BasicProcessor {
|
|
10
11
|
constructor(_snapshotOptions) {
|
|
@@ -42,10 +43,10 @@ class SnapshotProcessor extends basic_1.BasicProcessor {
|
|
|
42
43
|
const snapshotFileFilter = this._snapshotOptions.snapshotFileFilter ||
|
|
43
44
|
((file) => file.endsWith(".js") && !file.includes("runtime.js"));
|
|
44
45
|
const fileContents = Object.entries(compilation.assets)
|
|
45
|
-
.filter(([file]) => snapshotFileFilter(file))
|
|
46
|
+
.filter(([file]) => snapshotFileFilter.call(this, file))
|
|
46
47
|
.map(([file, source]) => {
|
|
47
48
|
const tag = node_path_1.default.extname(file).slice(1) || "txt";
|
|
48
|
-
let content =
|
|
49
|
+
let content = (0, placeholder_1.normalizePlaceholder)(source.source().toString());
|
|
49
50
|
const testConfig = context.getTestConfig();
|
|
50
51
|
if (testConfig.snapshotContent) {
|
|
51
52
|
content = testConfig.snapshotContent(content);
|
|
@@ -60,7 +61,7 @@ class SnapshotProcessor extends basic_1.BasicProcessor {
|
|
|
60
61
|
env.expect(content).toMatchFileSnapshot(snapshotPath);
|
|
61
62
|
}
|
|
62
63
|
serializeEachFile(content) {
|
|
63
|
-
return content;
|
|
64
|
+
return (0, placeholder_1.normalizePlaceholder)(content);
|
|
64
65
|
}
|
|
65
66
|
}
|
|
66
67
|
exports.SnapshotProcessor = SnapshotProcessor;
|
package/dist/type.d.ts
CHANGED
|
@@ -163,7 +163,7 @@ export type TCompilerFactory<T extends ECompilerType> = (options: TCompilerOptio
|
|
|
163
163
|
export interface TRunnerFactory<T extends ECompilerType> {
|
|
164
164
|
create(file: string, compilerOptions: TCompilerOptions<T>, env: ITestEnv): ITestRunner;
|
|
165
165
|
}
|
|
166
|
-
export type
|
|
166
|
+
export type THotUpdateContext = {
|
|
167
167
|
updateIndex: number;
|
|
168
168
|
totalUpdates: number;
|
|
169
169
|
changedFiles: string[];
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rspack-canary/test-tools",
|
|
3
|
-
"version": "1.5.
|
|
3
|
+
"version": "1.5.7-canary-a3406c0a-20250922173625",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"description": "Test tools for rspack",
|
|
6
6
|
"main": "dist/index.js",
|
|
@@ -100,10 +100,10 @@
|
|
|
100
100
|
"wast-loader": "^1.14.1",
|
|
101
101
|
"worker-rspack-loader": "^3.1.2",
|
|
102
102
|
"exports-loader": "^5.0.0",
|
|
103
|
-
"@rspack/cli": "npm:@rspack-canary/cli@1.5.
|
|
104
|
-
"@rspack/core": "npm:@rspack-canary/core@1.5.
|
|
103
|
+
"@rspack/cli": "npm:@rspack-canary/cli@1.5.7-canary-a3406c0a-20250922173625",
|
|
104
|
+
"@rspack/core": "npm:@rspack-canary/core@1.5.7-canary-a3406c0a-20250922173625",
|
|
105
105
|
"@rspack/binding-testing": "1.4.1",
|
|
106
|
-
"@rspack/test-tools": "npm:@rspack-canary/test-tools@1.5.
|
|
106
|
+
"@rspack/test-tools": "npm:@rspack-canary/test-tools@1.5.7-canary-a3406c0a-20250922173625"
|
|
107
107
|
},
|
|
108
108
|
"peerDependencies": {
|
|
109
109
|
"@rspack/core": ">=1.0.0"
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import { ECompilerType, type ITestContext, type TCompilerOptions } from "../type";
|
|
2
|
-
import { type ISnapshotProcessorOptions, SnapshotProcessor } from "./snapshot";
|
|
3
|
-
export interface IBuiltinProcessorOptions<T extends ECompilerType> extends Omit<ISnapshotProcessorOptions<T>, "runable"> {
|
|
4
|
-
}
|
|
5
|
-
export declare class BuiltinProcessor<T extends ECompilerType> extends SnapshotProcessor<T> {
|
|
6
|
-
protected _builtinOptions: IBuiltinProcessorOptions<T>;
|
|
7
|
-
constructor(_builtinOptions: IBuiltinProcessorOptions<T>);
|
|
8
|
-
static defaultOptions<T extends ECompilerType>(this: BuiltinProcessor<T>, context: ITestContext): TCompilerOptions<T>;
|
|
9
|
-
}
|
|
@@ -1,171 +0,0 @@
|
|
|
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.BuiltinProcessor = void 0;
|
|
7
|
-
const core_1 = require("@rspack/core");
|
|
8
|
-
const fs_extra_1 = __importDefault(require("fs-extra"));
|
|
9
|
-
const webpack_merge_1 = require("webpack-merge");
|
|
10
|
-
const type_1 = require("../type");
|
|
11
|
-
const snapshot_1 = require("./snapshot");
|
|
12
|
-
class BuiltinProcessor extends snapshot_1.SnapshotProcessor {
|
|
13
|
-
constructor(_builtinOptions) {
|
|
14
|
-
super({
|
|
15
|
-
defaultOptions: BuiltinProcessor.defaultOptions,
|
|
16
|
-
runable: false,
|
|
17
|
-
..._builtinOptions
|
|
18
|
-
});
|
|
19
|
-
this._builtinOptions = _builtinOptions;
|
|
20
|
-
}
|
|
21
|
-
static defaultOptions(context) {
|
|
22
|
-
let defaultOptions = {
|
|
23
|
-
entry: {
|
|
24
|
-
main: {
|
|
25
|
-
import: "./index"
|
|
26
|
-
}
|
|
27
|
-
},
|
|
28
|
-
output: {
|
|
29
|
-
publicPath: "/",
|
|
30
|
-
path: context.getDist(),
|
|
31
|
-
filename: "[name].js",
|
|
32
|
-
chunkFilename: "[name].js",
|
|
33
|
-
chunkFormat: "array-push",
|
|
34
|
-
cssFilename: "[name].css",
|
|
35
|
-
cssChunkFilename: "[name].css",
|
|
36
|
-
assetModuleFilename: "[hash][ext][query]",
|
|
37
|
-
sourceMapFilename: "[file].map",
|
|
38
|
-
chunkLoadingGlobal: "webpackChunkwebpack",
|
|
39
|
-
chunkLoading: "jsonp",
|
|
40
|
-
uniqueName: "__rspack_test__",
|
|
41
|
-
enabledLibraryTypes: ["system"],
|
|
42
|
-
strictModuleErrorHandling: false,
|
|
43
|
-
iife: true,
|
|
44
|
-
module: false,
|
|
45
|
-
asyncChunks: true,
|
|
46
|
-
scriptType: false,
|
|
47
|
-
globalObject: "self",
|
|
48
|
-
importFunctionName: "import",
|
|
49
|
-
wasmLoading: "fetch",
|
|
50
|
-
webassemblyModuleFilename: "[hash].module.wasm",
|
|
51
|
-
workerChunkLoading: "import-scripts",
|
|
52
|
-
workerWasmLoading: "fetch"
|
|
53
|
-
},
|
|
54
|
-
module: {
|
|
55
|
-
rules: [
|
|
56
|
-
{
|
|
57
|
-
test: /\.json$/,
|
|
58
|
-
type: "json"
|
|
59
|
-
},
|
|
60
|
-
{
|
|
61
|
-
test: /\.mjs$/,
|
|
62
|
-
type: "javascript/esm"
|
|
63
|
-
},
|
|
64
|
-
{
|
|
65
|
-
test: /\.cjs$/,
|
|
66
|
-
type: "javascript/dynamic"
|
|
67
|
-
},
|
|
68
|
-
{
|
|
69
|
-
test: /\.js$/,
|
|
70
|
-
type: "javascript/auto"
|
|
71
|
-
},
|
|
72
|
-
{
|
|
73
|
-
test: /\.css$/,
|
|
74
|
-
type: "css"
|
|
75
|
-
},
|
|
76
|
-
{
|
|
77
|
-
test: /\.wasm$/,
|
|
78
|
-
type: "webassembly/async"
|
|
79
|
-
}
|
|
80
|
-
]
|
|
81
|
-
},
|
|
82
|
-
node: {
|
|
83
|
-
__dirname: "mock",
|
|
84
|
-
__filename: "mock",
|
|
85
|
-
global: "warn"
|
|
86
|
-
},
|
|
87
|
-
optimization: {
|
|
88
|
-
runtimeChunk: {
|
|
89
|
-
name: "runtime"
|
|
90
|
-
},
|
|
91
|
-
minimize: false,
|
|
92
|
-
removeAvailableModules: true,
|
|
93
|
-
removeEmptyChunks: true,
|
|
94
|
-
moduleIds: "named",
|
|
95
|
-
chunkIds: "named",
|
|
96
|
-
sideEffects: false,
|
|
97
|
-
mangleExports: false,
|
|
98
|
-
usedExports: false,
|
|
99
|
-
concatenateModules: false,
|
|
100
|
-
nodeEnv: false
|
|
101
|
-
},
|
|
102
|
-
resolve: {
|
|
103
|
-
extensions: [
|
|
104
|
-
".js",
|
|
105
|
-
".jsx",
|
|
106
|
-
".ts",
|
|
107
|
-
".tsx",
|
|
108
|
-
".json",
|
|
109
|
-
".d.ts",
|
|
110
|
-
".css",
|
|
111
|
-
".wasm"
|
|
112
|
-
]
|
|
113
|
-
},
|
|
114
|
-
resolveLoader: {
|
|
115
|
-
extensions: [".js"]
|
|
116
|
-
},
|
|
117
|
-
experiments: {
|
|
118
|
-
css: true,
|
|
119
|
-
futureDefaults: true,
|
|
120
|
-
rspackFuture: {
|
|
121
|
-
bundlerInfo: {
|
|
122
|
-
force: false
|
|
123
|
-
}
|
|
124
|
-
}
|
|
125
|
-
},
|
|
126
|
-
devtool: false,
|
|
127
|
-
context: context.getSource(),
|
|
128
|
-
plugins: []
|
|
129
|
-
};
|
|
130
|
-
if (this._options.compilerType === type_1.ECompilerType.Rspack) {
|
|
131
|
-
let rspackDefaultOptions = defaultOptions;
|
|
132
|
-
const testConfigFile = context.getSource("rspack.config.js");
|
|
133
|
-
if (fs_extra_1.default.existsSync(testConfigFile)) {
|
|
134
|
-
const caseOptions = require(testConfigFile);
|
|
135
|
-
if (caseOptions.entry) {
|
|
136
|
-
delete rspackDefaultOptions.entry;
|
|
137
|
-
}
|
|
138
|
-
rspackDefaultOptions = (0, webpack_merge_1.merge)(rspackDefaultOptions, caseOptions);
|
|
139
|
-
}
|
|
140
|
-
// TODO: remove builtin compatible code
|
|
141
|
-
const defineOptions = rspackDefaultOptions.builtins?.define;
|
|
142
|
-
if (defineOptions) {
|
|
143
|
-
rspackDefaultOptions.plugins.push(new core_1.rspack.DefinePlugin(defineOptions));
|
|
144
|
-
}
|
|
145
|
-
const provideOptions = rspackDefaultOptions.builtins?.provide;
|
|
146
|
-
if (provideOptions) {
|
|
147
|
-
rspackDefaultOptions.plugins.push(new core_1.rspack.ProvidePlugin(provideOptions));
|
|
148
|
-
}
|
|
149
|
-
const htmlOptions = rspackDefaultOptions.builtins?.html;
|
|
150
|
-
if (htmlOptions) {
|
|
151
|
-
if (Array.isArray(htmlOptions)) {
|
|
152
|
-
for (const item of htmlOptions) {
|
|
153
|
-
rspackDefaultOptions.plugins.push(new core_1.rspack.HtmlRspackPlugin(item));
|
|
154
|
-
}
|
|
155
|
-
}
|
|
156
|
-
else {
|
|
157
|
-
rspackDefaultOptions.plugins.push(new core_1.rspack.HtmlRspackPlugin(htmlOptions));
|
|
158
|
-
}
|
|
159
|
-
}
|
|
160
|
-
delete rspackDefaultOptions.builtins;
|
|
161
|
-
defaultOptions = rspackDefaultOptions;
|
|
162
|
-
}
|
|
163
|
-
if (!global.printLogger) {
|
|
164
|
-
defaultOptions.infrastructureLogging = {
|
|
165
|
-
level: "error"
|
|
166
|
-
};
|
|
167
|
-
}
|
|
168
|
-
return defaultOptions;
|
|
169
|
-
}
|
|
170
|
-
}
|
|
171
|
-
exports.BuiltinProcessor = BuiltinProcessor;
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
import { HotUpdatePlugin } from "../helper/hot-update";
|
|
2
|
-
import { ECompilerType, type ITestContext, type ITestEnv, type ITestRunner, type TCompilerOptions } from "../type";
|
|
3
|
-
import { BasicProcessor, type IBasicProcessorOptions } from "./basic";
|
|
4
|
-
export interface ICacheProcessorOptions<T extends ECompilerType> extends Omit<IBasicProcessorOptions<T>, "runable"> {
|
|
5
|
-
target: TCompilerOptions<T>["target"];
|
|
6
|
-
tempDir: string;
|
|
7
|
-
sourceDir: string;
|
|
8
|
-
}
|
|
9
|
-
export declare class CacheProcessor<T extends ECompilerType> extends BasicProcessor<T> {
|
|
10
|
-
protected _cacheOptions: ICacheProcessorOptions<T>;
|
|
11
|
-
protected updatePlugin: HotUpdatePlugin;
|
|
12
|
-
protected runner: ITestRunner | null;
|
|
13
|
-
constructor(_cacheOptions: ICacheProcessorOptions<T>);
|
|
14
|
-
config(context: ITestContext): Promise<void>;
|
|
15
|
-
run(env: ITestEnv, context: ITestContext): Promise<void>;
|
|
16
|
-
static findBundle<T extends ECompilerType>(this: CacheProcessor<T>, context: ITestContext): string[];
|
|
17
|
-
afterAll(context: ITestContext): Promise<void>;
|
|
18
|
-
static defaultOptions<T extends ECompilerType>(this: CacheProcessor<T>, context: ITestContext): TCompilerOptions<T>;
|
|
19
|
-
static overrideOptions<T extends ECompilerType>(this: CacheProcessor<T>, context: ITestContext, options: TCompilerOptions<T>): void;
|
|
20
|
-
}
|
package/dist/processor/cache.js
DELETED
|
@@ -1,131 +0,0 @@
|
|
|
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.CacheProcessor = void 0;
|
|
7
|
-
const node_path_1 = __importDefault(require("node:path"));
|
|
8
|
-
const core_1 = require("@rspack/core");
|
|
9
|
-
const helper_1 = require("../helper");
|
|
10
|
-
const hot_update_1 = require("../helper/hot-update");
|
|
11
|
-
const type_1 = require("../type");
|
|
12
|
-
const basic_1 = require("./basic");
|
|
13
|
-
class CacheProcessor extends basic_1.BasicProcessor {
|
|
14
|
-
constructor(_cacheOptions) {
|
|
15
|
-
super({
|
|
16
|
-
defaultOptions: CacheProcessor.defaultOptions,
|
|
17
|
-
overrideOptions: CacheProcessor.overrideOptions,
|
|
18
|
-
findBundle: CacheProcessor.findBundle,
|
|
19
|
-
runable: true,
|
|
20
|
-
..._cacheOptions
|
|
21
|
-
});
|
|
22
|
-
this._cacheOptions = _cacheOptions;
|
|
23
|
-
this.runner = null;
|
|
24
|
-
this.updatePlugin = new hot_update_1.HotUpdatePlugin(_cacheOptions.sourceDir, _cacheOptions.tempDir);
|
|
25
|
-
}
|
|
26
|
-
async config(context) {
|
|
27
|
-
await this.updatePlugin.initialize();
|
|
28
|
-
this._options.configFiles = this._options.configFiles?.map(item => {
|
|
29
|
-
return node_path_1.default.resolve(this._cacheOptions.tempDir, item);
|
|
30
|
-
});
|
|
31
|
-
super.config(context);
|
|
32
|
-
}
|
|
33
|
-
async run(env, context) {
|
|
34
|
-
context.setValue(this._options.name, "hotUpdateContext", this.updatePlugin);
|
|
35
|
-
await super.run(env, context);
|
|
36
|
-
}
|
|
37
|
-
static findBundle(context) {
|
|
38
|
-
const files = [];
|
|
39
|
-
const prefiles = [];
|
|
40
|
-
const compiler = context.getCompiler(this._cacheOptions.name);
|
|
41
|
-
if (!compiler)
|
|
42
|
-
throw new Error("Compiler should exists when find bundle");
|
|
43
|
-
const stats = compiler.getStats();
|
|
44
|
-
if (!stats)
|
|
45
|
-
throw new Error("Stats should exists when find bundle");
|
|
46
|
-
const info = stats.toJson({ all: false, entrypoints: true });
|
|
47
|
-
if (this._cacheOptions.target === "web" ||
|
|
48
|
-
this._cacheOptions.target === "webworker") {
|
|
49
|
-
for (const file of info.entrypoints.main.assets) {
|
|
50
|
-
if ((0, helper_1.isJavaScript)(file.name)) {
|
|
51
|
-
files.push(file.name);
|
|
52
|
-
}
|
|
53
|
-
else {
|
|
54
|
-
prefiles.push(file.name);
|
|
55
|
-
}
|
|
56
|
-
}
|
|
57
|
-
}
|
|
58
|
-
else {
|
|
59
|
-
const assets = info.entrypoints.main.assets.filter(s => (0, helper_1.isJavaScript)(s.name));
|
|
60
|
-
files.push(assets[assets.length - 1].name);
|
|
61
|
-
}
|
|
62
|
-
return [...prefiles, ...files];
|
|
63
|
-
}
|
|
64
|
-
async afterAll(context) {
|
|
65
|
-
await super.afterAll(context);
|
|
66
|
-
const updateIndex = this.updatePlugin.getUpdateIndex();
|
|
67
|
-
const totalUpdates = this.updatePlugin.getTotalUpdates();
|
|
68
|
-
if (updateIndex + 1 !== totalUpdates) {
|
|
69
|
-
throw new Error(`Should run all hot steps (${updateIndex + 1} / ${totalUpdates}): ${this._options.name}`);
|
|
70
|
-
}
|
|
71
|
-
}
|
|
72
|
-
static defaultOptions(context) {
|
|
73
|
-
const options = {
|
|
74
|
-
context: this._cacheOptions.tempDir,
|
|
75
|
-
mode: "production",
|
|
76
|
-
cache: true,
|
|
77
|
-
devtool: false,
|
|
78
|
-
output: {
|
|
79
|
-
path: context.getDist(),
|
|
80
|
-
filename: "bundle.js",
|
|
81
|
-
chunkFilename: "[name].chunk.[fullhash].js",
|
|
82
|
-
publicPath: "https://test.cases/path/",
|
|
83
|
-
library: { type: "commonjs2" }
|
|
84
|
-
},
|
|
85
|
-
optimization: {
|
|
86
|
-
moduleIds: "named",
|
|
87
|
-
emitOnErrors: true
|
|
88
|
-
},
|
|
89
|
-
target: this._cacheOptions.target,
|
|
90
|
-
experiments: {
|
|
91
|
-
css: true,
|
|
92
|
-
rspackFuture: {
|
|
93
|
-
bundlerInfo: {
|
|
94
|
-
force: false
|
|
95
|
-
}
|
|
96
|
-
},
|
|
97
|
-
inlineConst: true,
|
|
98
|
-
lazyBarrel: true
|
|
99
|
-
}
|
|
100
|
-
};
|
|
101
|
-
if (this._cacheOptions.compilerType === type_1.ECompilerType.Rspack) {
|
|
102
|
-
options.plugins ??= [];
|
|
103
|
-
options.plugins.push(new core_1.rspack.HotModuleReplacementPlugin());
|
|
104
|
-
}
|
|
105
|
-
return options;
|
|
106
|
-
}
|
|
107
|
-
static overrideOptions(context, options) {
|
|
108
|
-
if (!options.entry) {
|
|
109
|
-
options.entry = "./index.js";
|
|
110
|
-
}
|
|
111
|
-
// rewrite context to temp dir
|
|
112
|
-
options.context = this._cacheOptions.tempDir;
|
|
113
|
-
options.module ??= {};
|
|
114
|
-
for (const cssModuleType of ["css/auto", "css/module", "css"]) {
|
|
115
|
-
options.module.generator ??= {};
|
|
116
|
-
options.module.generator[cssModuleType] ??= {};
|
|
117
|
-
options.module.generator[cssModuleType].exportsOnly ??=
|
|
118
|
-
this._cacheOptions.target === "async-node";
|
|
119
|
-
}
|
|
120
|
-
if (this._cacheOptions.compilerType === type_1.ECompilerType.Rspack) {
|
|
121
|
-
options.plugins ??= [];
|
|
122
|
-
options.plugins.push(this.updatePlugin);
|
|
123
|
-
}
|
|
124
|
-
if (!global.printLogger) {
|
|
125
|
-
options.infrastructureLogging = {
|
|
126
|
-
level: "error"
|
|
127
|
-
};
|
|
128
|
-
}
|
|
129
|
-
}
|
|
130
|
-
}
|
|
131
|
-
exports.CacheProcessor = CacheProcessor;
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import type { ECompilerType, ITestContext, TCompilerOptions } from "../type";
|
|
2
|
-
import { type IMultiTaskProcessorOptions, MultiTaskProcessor } from "./multi";
|
|
3
|
-
export interface IConfigProcessorOptions<T extends ECompilerType> extends IMultiTaskProcessorOptions<T> {
|
|
4
|
-
}
|
|
5
|
-
export declare class ConfigProcessor<T extends ECompilerType> extends MultiTaskProcessor<T> {
|
|
6
|
-
protected _configOptions: IConfigProcessorOptions<T>;
|
|
7
|
-
constructor(_configOptions: IConfigProcessorOptions<T>);
|
|
8
|
-
static findBundle<T extends ECompilerType>(index: number, context: ITestContext, options: TCompilerOptions<T>): string | string[];
|
|
9
|
-
static defaultOptions<T extends ECompilerType>(index: number, context: ITestContext): TCompilerOptions<T>;
|
|
10
|
-
static overrideOptions<T extends ECompilerType>(index: number, context: ITestContext, options: TCompilerOptions<T>): void;
|
|
11
|
-
}
|