@rspack-canary/test-tools 1.5.6-canary-e598f284-20250921173624 → 1.5.8-canary-e350b761-20250924173613
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 +173 -13
- package/dist/case/cache.d.ts +1 -1
- package/dist/case/cache.js +210 -11
- package/dist/case/common.d.ts +10 -0
- package/dist/case/common.js +237 -0
- package/dist/case/compiler.d.ts +7 -4
- package/dist/case/compiler.js +144 -109
- package/dist/case/config.d.ts +5 -1
- package/dist/case/config.js +102 -16
- package/dist/case/defaults.d.ts +12 -4
- package/dist/case/defaults.js +67 -12
- package/dist/case/diagnostic.d.ts +6 -0
- package/dist/case/diagnostic.js +123 -14
- package/dist/case/diff.d.ts +17 -1
- package/dist/case/diff.js +170 -22
- package/dist/case/error.d.ts +14 -4
- package/dist/case/error.js +117 -10
- package/dist/case/hash.d.ts +1 -1
- package/dist/case/hash.js +70 -9
- package/dist/case/hook.d.ts +35 -4
- package/dist/case/hook.js +210 -21
- package/dist/case/hot-step.js +307 -9
- package/dist/case/hot.d.ts +8 -1
- package/dist/case/hot.js +235 -8
- package/dist/case/incremental.d.ts +1 -1
- package/dist/case/incremental.js +39 -41
- package/dist/case/index.d.ts +20 -20
- package/dist/case/index.js +44 -34
- package/dist/case/native-watcher.js +10 -23
- package/dist/case/normal.js +174 -12
- package/dist/case/runner.d.ts +18 -0
- package/dist/case/runner.js +108 -0
- package/dist/case/serial.d.ts +1 -1
- package/dist/case/serial.js +8 -12
- package/dist/case/stats-api.d.ts +0 -5
- package/dist/case/stats-api.js +71 -10
- package/dist/case/stats-output.js +197 -11
- package/dist/case/treeshaking.js +34 -7
- package/dist/case/watch.d.ts +27 -0
- package/dist/case/watch.js +321 -21
- package/dist/helper/plugins/hot-update.d.ts +2 -2
- package/dist/index.d.ts +0 -2
- package/dist/index.js +0 -2
- package/dist/runner/index.d.ts +2 -7
- package/dist/runner/index.js +2 -7
- package/dist/runner/{runner/node → node}/index.d.ts +1 -2
- package/dist/runner/{runner/node → node}/index.js +2 -2
- package/dist/runner/{runner/web → web}/fake.d.ts +1 -2
- package/dist/runner/{runner/web → web}/fake.js +7 -7
- package/dist/runner/{runner/web → web}/index.d.ts +2 -2
- package/dist/runner/{runner/web → web}/index.js +1 -1
- package/dist/runner/{runner/web → web}/jsdom.d.ts +1 -2
- package/dist/runner/{runner/web → web}/jsdom.js +4 -4
- package/dist/test/context.d.ts +3 -5
- package/dist/test/context.js +22 -12
- package/dist/test/creator.d.ts +13 -12
- package/dist/test/creator.js +52 -43
- package/dist/test/tester.js +4 -1
- package/dist/type.d.ts +42 -11
- package/dist/type.js +7 -1
- package/package.json +5 -5
- package/dist/processor/basic.d.ts +0 -24
- package/dist/processor/basic.js +0 -147
- 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/diff.d.ts +0 -30
- package/dist/processor/diff.js +0 -140
- 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/index.d.ts +0 -20
- package/dist/processor/index.js +0 -36
- package/dist/processor/multi.d.ts +0 -17
- package/dist/processor/multi.js +0 -73
- package/dist/processor/normal.d.ts +0 -12
- package/dist/processor/normal.js +0 -170
- package/dist/processor/simple.d.ts +0 -24
- package/dist/processor/simple.js +0 -51
- package/dist/processor/snapshot.d.ts +0 -12
- package/dist/processor/snapshot.js +0 -66
- 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/watch.d.ts +0 -30
- package/dist/processor/watch.js +0 -252
- package/dist/runner/basic.d.ts +0 -10
- package/dist/runner/basic.js +0 -64
- package/dist/runner/cache.d.ts +0 -5
- package/dist/runner/cache.js +0 -92
- package/dist/runner/hot.d.ts +0 -5
- package/dist/runner/hot.js +0 -91
- package/dist/runner/multiple.d.ts +0 -11
- package/dist/runner/multiple.js +0 -52
- package/dist/runner/runner/index.d.ts +0 -2
- package/dist/runner/runner/index.js +0 -18
- package/dist/runner/type.d.ts +0 -42
- package/dist/runner/type.js +0 -9
- package/dist/runner/watch.d.ts +0 -7
- package/dist/runner/watch.js +0 -71
- package/dist/test/simple.d.ts +0 -5
- package/dist/test/simple.js +0 -43
|
@@ -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
|
-
}
|
package/dist/processor/config.js
DELETED
|
@@ -1,88 +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.ConfigProcessor = void 0;
|
|
7
|
-
const node_fs_1 = __importDefault(require("node:fs"));
|
|
8
|
-
const node_path_1 = __importDefault(require("node:path"));
|
|
9
|
-
const parseResource_1 = require("../helper/legacy/parseResource");
|
|
10
|
-
const multi_1 = require("./multi");
|
|
11
|
-
class ConfigProcessor extends multi_1.MultiTaskProcessor {
|
|
12
|
-
constructor(_configOptions) {
|
|
13
|
-
super({
|
|
14
|
-
defaultOptions: (ConfigProcessor.defaultOptions),
|
|
15
|
-
overrideOptions: (ConfigProcessor.overrideOptions),
|
|
16
|
-
findBundle: (ConfigProcessor.findBundle),
|
|
17
|
-
..._configOptions
|
|
18
|
-
});
|
|
19
|
-
this._configOptions = _configOptions;
|
|
20
|
-
}
|
|
21
|
-
static findBundle(index, context, options) {
|
|
22
|
-
const testConfig = context.getTestConfig();
|
|
23
|
-
if (typeof testConfig.findBundle === "function") {
|
|
24
|
-
return testConfig.findBundle(index, options);
|
|
25
|
-
}
|
|
26
|
-
const ext = node_path_1.default.extname((0, parseResource_1.parseResource)(options.output?.filename).path);
|
|
27
|
-
const bundlePath = [];
|
|
28
|
-
if (options.output?.path &&
|
|
29
|
-
node_fs_1.default.existsSync(node_path_1.default.join(options.output.path, `bundle${index}${ext}`))) {
|
|
30
|
-
if (options.experiments?.css) {
|
|
31
|
-
const cssOutputPath = node_path_1.default.join(options.output.path, (typeof options.output?.cssFilename === "string" &&
|
|
32
|
-
options.output?.cssFilename) ||
|
|
33
|
-
`bundle${index}.css`);
|
|
34
|
-
if (node_fs_1.default.existsSync(cssOutputPath)) {
|
|
35
|
-
bundlePath.push(`./bundle${index}.css`);
|
|
36
|
-
}
|
|
37
|
-
}
|
|
38
|
-
bundlePath.push(`./bundle${index}${ext}`);
|
|
39
|
-
}
|
|
40
|
-
return bundlePath;
|
|
41
|
-
}
|
|
42
|
-
static defaultOptions(index, context) {
|
|
43
|
-
return {
|
|
44
|
-
context: context.getSource(),
|
|
45
|
-
mode: "production",
|
|
46
|
-
target: "async-node",
|
|
47
|
-
devtool: false,
|
|
48
|
-
cache: false,
|
|
49
|
-
output: {
|
|
50
|
-
path: context.getDist()
|
|
51
|
-
},
|
|
52
|
-
optimization: {
|
|
53
|
-
minimize: false
|
|
54
|
-
},
|
|
55
|
-
experiments: {
|
|
56
|
-
css: true,
|
|
57
|
-
rspackFuture: {
|
|
58
|
-
bundlerInfo: {
|
|
59
|
-
force: false
|
|
60
|
-
}
|
|
61
|
-
},
|
|
62
|
-
inlineConst: true,
|
|
63
|
-
lazyBarrel: true
|
|
64
|
-
}
|
|
65
|
-
};
|
|
66
|
-
}
|
|
67
|
-
static overrideOptions(index, context, options) {
|
|
68
|
-
if (!options.entry) {
|
|
69
|
-
options.entry = "./index.js";
|
|
70
|
-
}
|
|
71
|
-
if (options.amd === undefined) {
|
|
72
|
-
options.amd = {};
|
|
73
|
-
}
|
|
74
|
-
if (!options.output?.filename) {
|
|
75
|
-
const outputModule = options.experiments?.outputModule;
|
|
76
|
-
options.output ??= {};
|
|
77
|
-
options.output.filename = `bundle${index}${outputModule ? ".mjs" : ".js"}`;
|
|
78
|
-
}
|
|
79
|
-
if (options.cache === undefined)
|
|
80
|
-
options.cache = false;
|
|
81
|
-
if (!global.printLogger) {
|
|
82
|
-
options.infrastructureLogging = {
|
|
83
|
-
level: "error"
|
|
84
|
-
};
|
|
85
|
-
}
|
|
86
|
-
}
|
|
87
|
-
}
|
|
88
|
-
exports.ConfigProcessor = ConfigProcessor;
|
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
import type { ECompilerType, ITestContext, ITestEnv, TCompilerOptions } from "../type";
|
|
2
|
-
import { SimpleTaskProcessor } from "./simple";
|
|
3
|
-
declare class RspackTestDiff {
|
|
4
|
-
value: string;
|
|
5
|
-
constructor(value: string);
|
|
6
|
-
}
|
|
7
|
-
export interface IDefaultsConfigProcessorOptions<T extends ECompilerType> {
|
|
8
|
-
options?: (context: ITestContext) => TCompilerOptions<T>;
|
|
9
|
-
cwd?: string;
|
|
10
|
-
name: string;
|
|
11
|
-
diff: (diff: jest.JestMatchers<RspackTestDiff>, defaults: jest.JestMatchers<TCompilerOptions<T>>) => Promise<void>;
|
|
12
|
-
compilerType: T;
|
|
13
|
-
}
|
|
14
|
-
export declare class DefaultsConfigProcessor<T extends ECompilerType> extends SimpleTaskProcessor<T> {
|
|
15
|
-
protected _defaultsConfigOptions: IDefaultsConfigProcessorOptions<T>;
|
|
16
|
-
private defaultConfig;
|
|
17
|
-
constructor(_defaultsConfigOptions: IDefaultsConfigProcessorOptions<T>);
|
|
18
|
-
compiler(context: ITestContext): Promise<void>;
|
|
19
|
-
build(context: ITestContext): Promise<void>;
|
|
20
|
-
run(env: ITestEnv, context: ITestContext): Promise<void>;
|
|
21
|
-
check(env: ITestEnv, context: ITestContext): Promise<void>;
|
|
22
|
-
before(context: ITestContext): Promise<void>;
|
|
23
|
-
after(context: ITestContext): Promise<void>;
|
|
24
|
-
beforeAll(context: ITestContext): Promise<void>;
|
|
25
|
-
afterAll(context: ITestContext): Promise<void>;
|
|
26
|
-
protected getCompiler(context: ITestContext): import("../type").ITestCompilerManager<T>;
|
|
27
|
-
static getDefaultConfig(cwd: string, config: TCompilerOptions<ECompilerType>): TCompilerOptions<ECompilerType>;
|
|
28
|
-
static overrideOptions<T extends ECompilerType>(options: TCompilerOptions<T>): void;
|
|
29
|
-
}
|
|
30
|
-
export {};
|
|
@@ -1,72 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.DefaultsConfigProcessor = void 0;
|
|
4
|
-
const node_util_1 = require("node:util");
|
|
5
|
-
const jest_diff_1 = require("jest-diff");
|
|
6
|
-
const simple_1 = require("./simple");
|
|
7
|
-
const CURRENT_CWD = process.cwd();
|
|
8
|
-
class RspackTestDiff {
|
|
9
|
-
constructor(value) {
|
|
10
|
-
this.value = value;
|
|
11
|
-
}
|
|
12
|
-
}
|
|
13
|
-
class DefaultsConfigProcessor extends simple_1.SimpleTaskProcessor {
|
|
14
|
-
constructor(_defaultsConfigOptions) {
|
|
15
|
-
super({
|
|
16
|
-
options: context => {
|
|
17
|
-
let res;
|
|
18
|
-
if (typeof _defaultsConfigOptions.options === "function") {
|
|
19
|
-
res = _defaultsConfigOptions.options(context);
|
|
20
|
-
}
|
|
21
|
-
else {
|
|
22
|
-
res = {};
|
|
23
|
-
}
|
|
24
|
-
if (!("mode" in res)) {
|
|
25
|
-
res.mode = "none";
|
|
26
|
-
}
|
|
27
|
-
return res;
|
|
28
|
-
},
|
|
29
|
-
compilerType: _defaultsConfigOptions.compilerType,
|
|
30
|
-
name: _defaultsConfigOptions.name
|
|
31
|
-
});
|
|
32
|
-
this._defaultsConfigOptions = _defaultsConfigOptions;
|
|
33
|
-
this.defaultConfig = DefaultsConfigProcessor.getDefaultConfig(CURRENT_CWD, {
|
|
34
|
-
mode: "none"
|
|
35
|
-
});
|
|
36
|
-
}
|
|
37
|
-
async compiler(context) { }
|
|
38
|
-
async build(context) { }
|
|
39
|
-
async run(env, context) { }
|
|
40
|
-
async check(env, context) {
|
|
41
|
-
const compiler = this.getCompiler(context);
|
|
42
|
-
const config = DefaultsConfigProcessor.getDefaultConfig(this._defaultsConfigOptions.cwd || CURRENT_CWD, compiler.getOptions());
|
|
43
|
-
const diff = (0, node_util_1.stripVTControlCharacters)((0, jest_diff_1.diff)(this.defaultConfig, config, { expand: false, contextLines: 0 }));
|
|
44
|
-
await this._defaultsConfigOptions.diff(env.expect(new RspackTestDiff(diff)), env.expect(this.defaultConfig));
|
|
45
|
-
}
|
|
46
|
-
async before(context) { }
|
|
47
|
-
async after(context) { }
|
|
48
|
-
async beforeAll(context) { }
|
|
49
|
-
async afterAll(context) { }
|
|
50
|
-
getCompiler(context) {
|
|
51
|
-
return context.getCompiler(this._options.name, this._options.compilerType);
|
|
52
|
-
}
|
|
53
|
-
static getDefaultConfig(cwd, config) {
|
|
54
|
-
process.chdir(cwd);
|
|
55
|
-
const { applyWebpackOptionsDefaults, getNormalizedWebpackOptions } = require("@rspack/core").config;
|
|
56
|
-
const normalizedConfig = getNormalizedWebpackOptions(config);
|
|
57
|
-
applyWebpackOptionsDefaults(normalizedConfig);
|
|
58
|
-
// make snapshot stable
|
|
59
|
-
normalizedConfig.experiments.rspackFuture.bundlerInfo.version =
|
|
60
|
-
"$version$";
|
|
61
|
-
process.chdir(CURRENT_CWD);
|
|
62
|
-
return normalizedConfig;
|
|
63
|
-
}
|
|
64
|
-
static overrideOptions(options) {
|
|
65
|
-
if (!global.printLogger) {
|
|
66
|
-
options.infrastructureLogging = {
|
|
67
|
-
level: "error"
|
|
68
|
-
};
|
|
69
|
-
}
|
|
70
|
-
}
|
|
71
|
-
}
|
|
72
|
-
exports.DefaultsConfigProcessor = DefaultsConfigProcessor;
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
import type { ECompilerType, ITestContext, ITestEnv, TCompilerOptions } from "../type";
|
|
2
|
-
import { BasicProcessor, type IBasicProcessorOptions } from "./basic";
|
|
3
|
-
export interface IDiagnosticProcessorOptions<T extends ECompilerType> extends Omit<IBasicProcessorOptions<T>, "runable"> {
|
|
4
|
-
snapshot: string;
|
|
5
|
-
snapshotErrors: string;
|
|
6
|
-
snapshotWarning: string;
|
|
7
|
-
format?: (output: string) => string;
|
|
8
|
-
}
|
|
9
|
-
export declare class DiagnosticProcessor<T extends ECompilerType> extends BasicProcessor<T> {
|
|
10
|
-
protected _diagnosticOptions: IDiagnosticProcessorOptions<T>;
|
|
11
|
-
constructor(_diagnosticOptions: IDiagnosticProcessorOptions<T>);
|
|
12
|
-
check(env: ITestEnv, context: ITestContext): Promise<void>;
|
|
13
|
-
static defaultOptions<T extends ECompilerType>(context: ITestContext): TCompilerOptions<T>;
|
|
14
|
-
static overrideOptions<T extends ECompilerType>(options: TCompilerOptions<T>): void;
|
|
15
|
-
}
|
|
@@ -1,104 +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.DiagnosticProcessor = void 0;
|
|
7
|
-
const node_assert_1 = __importDefault(require("node:assert"));
|
|
8
|
-
const node_path_1 = __importDefault(require("node:path"));
|
|
9
|
-
const placeholder_1 = require("../helper/expect/placeholder");
|
|
10
|
-
const basic_1 = require("./basic");
|
|
11
|
-
class DiagnosticProcessor extends basic_1.BasicProcessor {
|
|
12
|
-
constructor(_diagnosticOptions) {
|
|
13
|
-
super({
|
|
14
|
-
defaultOptions: (DiagnosticProcessor.defaultOptions),
|
|
15
|
-
runable: false,
|
|
16
|
-
..._diagnosticOptions
|
|
17
|
-
});
|
|
18
|
-
this._diagnosticOptions = _diagnosticOptions;
|
|
19
|
-
}
|
|
20
|
-
async check(env, context) {
|
|
21
|
-
const compiler = this.getCompiler(context);
|
|
22
|
-
const stats = compiler.getStats();
|
|
23
|
-
if (!stats) {
|
|
24
|
-
throw new Error("Stats should exists");
|
|
25
|
-
}
|
|
26
|
-
(0, node_assert_1.default)(stats.hasErrors() || stats.hasWarnings());
|
|
27
|
-
let output = (0, placeholder_1.normalizePlaceholder)(stats.toString({
|
|
28
|
-
all: false,
|
|
29
|
-
errors: true,
|
|
30
|
-
warnings: true
|
|
31
|
-
})).replaceAll("\\", "/"); // stats has some win32 paths that path-serializer can not handle
|
|
32
|
-
const statsJson = stats.toJson({
|
|
33
|
-
all: false,
|
|
34
|
-
errors: true,
|
|
35
|
-
warnings: true
|
|
36
|
-
});
|
|
37
|
-
const errors = (statsJson.errors || []).map(e => {
|
|
38
|
-
// @ts-expect-error error message is already serialized in `stats.err`
|
|
39
|
-
delete e.message;
|
|
40
|
-
delete e.stack;
|
|
41
|
-
return e;
|
|
42
|
-
});
|
|
43
|
-
const warnings = (statsJson.warnings || []).map(e => {
|
|
44
|
-
// @ts-expect-error error message is already serialized in `stats.err`
|
|
45
|
-
delete e.message;
|
|
46
|
-
delete e.stack;
|
|
47
|
-
return e;
|
|
48
|
-
});
|
|
49
|
-
if (typeof this._diagnosticOptions.format === "function") {
|
|
50
|
-
output = this._diagnosticOptions.format(output);
|
|
51
|
-
}
|
|
52
|
-
env.expect.addSnapshotSerializer({
|
|
53
|
-
test(received) {
|
|
54
|
-
return typeof received === "string";
|
|
55
|
-
},
|
|
56
|
-
serialize(received) {
|
|
57
|
-
return (0, placeholder_1.normalizePlaceholder)(received.trim());
|
|
58
|
-
}
|
|
59
|
-
});
|
|
60
|
-
const errorOutputPath = node_path_1.default.resolve(context.getSource(this._diagnosticOptions.snapshot));
|
|
61
|
-
const errorStatsOutputPath = node_path_1.default.resolve(context.getSource(this._diagnosticOptions.snapshotErrors));
|
|
62
|
-
const warningStatsOutputPath = node_path_1.default.resolve(context.getSource(this._diagnosticOptions.snapshotWarning));
|
|
63
|
-
env.expect(output).toMatchFileSnapshot(errorOutputPath);
|
|
64
|
-
env.expect(errors).toMatchFileSnapshot(errorStatsOutputPath);
|
|
65
|
-
env.expect(warnings).toMatchFileSnapshot(warningStatsOutputPath);
|
|
66
|
-
}
|
|
67
|
-
static defaultOptions(context) {
|
|
68
|
-
return {
|
|
69
|
-
target: "node",
|
|
70
|
-
context: context.getSource(),
|
|
71
|
-
entry: {
|
|
72
|
-
main: "./"
|
|
73
|
-
},
|
|
74
|
-
mode: "development",
|
|
75
|
-
devServer: {
|
|
76
|
-
hot: false
|
|
77
|
-
},
|
|
78
|
-
infrastructureLogging: {
|
|
79
|
-
debug: false
|
|
80
|
-
},
|
|
81
|
-
output: {
|
|
82
|
-
path: context.getDist()
|
|
83
|
-
},
|
|
84
|
-
experiments: {
|
|
85
|
-
css: true,
|
|
86
|
-
rspackFuture: {
|
|
87
|
-
bundlerInfo: {
|
|
88
|
-
force: false
|
|
89
|
-
}
|
|
90
|
-
},
|
|
91
|
-
inlineConst: true,
|
|
92
|
-
lazyBarrel: true
|
|
93
|
-
}
|
|
94
|
-
};
|
|
95
|
-
}
|
|
96
|
-
static overrideOptions(options) {
|
|
97
|
-
if (!global.printLogger) {
|
|
98
|
-
options.infrastructureLogging = {
|
|
99
|
-
level: "error"
|
|
100
|
-
};
|
|
101
|
-
}
|
|
102
|
-
}
|
|
103
|
-
}
|
|
104
|
-
exports.DiagnosticProcessor = DiagnosticProcessor;
|
package/dist/processor/diff.d.ts
DELETED
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
import { type IFormatCodeOptions, type IFormatCodeReplacement } from "../compare";
|
|
2
|
-
import { type ITestContext, type ITestEnv, type ITestProcessor, type TCompareModules, type TFileCompareResult, type TModuleCompareResult } from "../type";
|
|
3
|
-
export interface IDiffProcessorOptions extends IFormatCodeOptions {
|
|
4
|
-
webpackPath: string;
|
|
5
|
-
rspackPath: string;
|
|
6
|
-
files?: string[];
|
|
7
|
-
modules?: TCompareModules;
|
|
8
|
-
runtimeModules?: TCompareModules;
|
|
9
|
-
bootstrap?: boolean;
|
|
10
|
-
detail?: boolean;
|
|
11
|
-
errors?: boolean;
|
|
12
|
-
replacements?: IFormatCodeReplacement[];
|
|
13
|
-
renameModule?: (file: string) => string;
|
|
14
|
-
onCompareFile?: (file: string, result: TFileCompareResult) => void;
|
|
15
|
-
onCompareModules?: (file: string, results: TModuleCompareResult[]) => void;
|
|
16
|
-
onCompareRuntimeModules?: (file: string, results: TModuleCompareResult[]) => void;
|
|
17
|
-
}
|
|
18
|
-
export declare class DiffProcessor implements ITestProcessor {
|
|
19
|
-
private options;
|
|
20
|
-
private hashes;
|
|
21
|
-
private webpack;
|
|
22
|
-
private rspack;
|
|
23
|
-
constructor(options: IDiffProcessorOptions);
|
|
24
|
-
config(context: ITestContext): Promise<void>;
|
|
25
|
-
compiler(context: ITestContext): Promise<void>;
|
|
26
|
-
build(context: ITestContext): Promise<void>;
|
|
27
|
-
check(env: ITestEnv, context: ITestContext): Promise<void>;
|
|
28
|
-
private getDefaultOptions;
|
|
29
|
-
private createFormatOptions;
|
|
30
|
-
}
|