@rspack/test-tools 1.4.7-alpha.0 → 1.4.7
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/index.d.ts
CHANGED
package/dist/case/index.js
CHANGED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function createNativeWatcher(name: string, src: string, dist: string, temp: string): void;
|
|
@@ -0,0 +1,55 @@
|
|
|
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.createNativeWatcher = createNativeWatcher;
|
|
7
|
+
const node_fs_1 = __importDefault(require("node:fs"));
|
|
8
|
+
const node_path_1 = __importDefault(require("node:path"));
|
|
9
|
+
const watch_1 = require("../processor/watch");
|
|
10
|
+
const runner_1 = require("../runner");
|
|
11
|
+
const creator_1 = require("../test/creator");
|
|
12
|
+
const type_1 = require("../type");
|
|
13
|
+
const creator = new creator_1.BasicCaseCreator({
|
|
14
|
+
clean: true,
|
|
15
|
+
runner: runner_1.WatchRunnerFactory,
|
|
16
|
+
description: (name, index) => {
|
|
17
|
+
return index === 0
|
|
18
|
+
? `${name} should compile`
|
|
19
|
+
: `should compile step ${index}`;
|
|
20
|
+
},
|
|
21
|
+
describe: false,
|
|
22
|
+
steps: ({ name, src, temp }) => {
|
|
23
|
+
const watchState = {};
|
|
24
|
+
const runs = node_fs_1.default
|
|
25
|
+
.readdirSync(src)
|
|
26
|
+
.sort()
|
|
27
|
+
.filter(name => {
|
|
28
|
+
return node_fs_1.default.statSync(node_path_1.default.join(src, name)).isDirectory();
|
|
29
|
+
})
|
|
30
|
+
.map(name => ({ name }));
|
|
31
|
+
return runs.map((run, index) => index === 0
|
|
32
|
+
? new watch_1.WatchProcessor({
|
|
33
|
+
name,
|
|
34
|
+
stepName: run.name,
|
|
35
|
+
tempDir: temp,
|
|
36
|
+
runable: true,
|
|
37
|
+
compilerType: type_1.ECompilerType.Rspack,
|
|
38
|
+
configFiles: ["rspack.config.js", "webpack.config.js"],
|
|
39
|
+
nativeWatcher: true
|
|
40
|
+
}, watchState)
|
|
41
|
+
: new watch_1.WatchStepProcessor({
|
|
42
|
+
name,
|
|
43
|
+
stepName: run.name,
|
|
44
|
+
tempDir: temp,
|
|
45
|
+
runable: true,
|
|
46
|
+
compilerType: type_1.ECompilerType.Rspack,
|
|
47
|
+
configFiles: ["rspack.config.js", "webpack.config.js"]
|
|
48
|
+
}, watchState));
|
|
49
|
+
},
|
|
50
|
+
// TODO: Enable concurrent mode for native watcher
|
|
51
|
+
concurrent: false
|
|
52
|
+
});
|
|
53
|
+
function createNativeWatcher(name, src, dist, temp) {
|
|
54
|
+
creator.create(name, src, dist, temp);
|
|
55
|
+
}
|
|
@@ -3,6 +3,7 @@ import { type IMultiTaskProcessorOptions, MultiTaskProcessor } from "./multi";
|
|
|
3
3
|
export interface IWatchProcessorOptions<T extends ECompilerType> extends IMultiTaskProcessorOptions<T> {
|
|
4
4
|
stepName: string;
|
|
5
5
|
tempDir: string;
|
|
6
|
+
nativeWatcher?: boolean;
|
|
6
7
|
}
|
|
7
8
|
export declare class WatchProcessor<T extends ECompilerType> extends MultiTaskProcessor<T> {
|
|
8
9
|
protected _watchOptions: IWatchProcessorOptions<T>;
|
|
@@ -15,7 +16,7 @@ export declare class WatchProcessor<T extends ECompilerType> extends MultiTaskPr
|
|
|
15
16
|
run(env: ITestEnv, context: ITestContext): Promise<void>;
|
|
16
17
|
check(env: ITestEnv, context: ITestContext): Promise<void>;
|
|
17
18
|
config(context: ITestContext): Promise<void>;
|
|
18
|
-
static overrideOptions<T extends ECompilerType>({ tempDir,
|
|
19
|
+
static overrideOptions<T extends ECompilerType>({ tempDir, nativeWatcher }: IWatchProcessorOptions<T>): (index: number, context: ITestContext, options: TCompilerOptions<ECompilerType>) => void;
|
|
19
20
|
static findBundle<T extends ECompilerType>(this: IWatchProcessorOptions<T>, index: number, context: ITestContext, options: TCompilerOptions<T>): string | string[];
|
|
20
21
|
}
|
|
21
22
|
export interface IWatchStepProcessorOptions<T extends ECompilerType> extends Omit<IWatchProcessorOptions<T>, "experiments" | "optimization"> {
|
package/dist/processor/watch.js
CHANGED
|
@@ -159,7 +159,7 @@ class WatchProcessor extends multi_1.MultiTaskProcessor {
|
|
|
159
159
|
const compiler = this.getCompiler(context);
|
|
160
160
|
compiler.setOptions(compilerOptions);
|
|
161
161
|
}
|
|
162
|
-
static overrideOptions({ tempDir,
|
|
162
|
+
static overrideOptions({ tempDir, nativeWatcher }) {
|
|
163
163
|
return (index, context, options) => {
|
|
164
164
|
if (!options.mode)
|
|
165
165
|
options.mode = "development";
|
|
@@ -187,6 +187,9 @@ class WatchProcessor extends multi_1.MultiTaskProcessor {
|
|
|
187
187
|
options.optimization ??= {};
|
|
188
188
|
options.experiments ??= {};
|
|
189
189
|
options.experiments.css ??= true;
|
|
190
|
+
if (nativeWatcher) {
|
|
191
|
+
options.experiments.nativeWatcher ??= true;
|
|
192
|
+
}
|
|
190
193
|
options.experiments.rspackFuture ??= {};
|
|
191
194
|
options.experiments.rspackFuture.bundlerInfo ??= {};
|
|
192
195
|
options.experiments.rspackFuture.bundlerInfo.force ??= false;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rspack/test-tools",
|
|
3
|
-
"version": "1.4.7
|
|
3
|
+
"version": "1.4.7",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"description": "Test tools for rspack",
|
|
6
6
|
"main": "dist/index.js",
|
|
@@ -41,7 +41,7 @@
|
|
|
41
41
|
"deepmerge": "^4.3.1",
|
|
42
42
|
"filenamify": "4.3.0",
|
|
43
43
|
"fs-extra": "^11.3.0",
|
|
44
|
-
"glob": "^11.0.
|
|
44
|
+
"glob": "^11.0.3",
|
|
45
45
|
"graceful-fs": "^4.2.11",
|
|
46
46
|
"iconv-lite": "^0.6.3",
|
|
47
47
|
"jest-diff": "^29.7.0",
|
|
@@ -67,7 +67,7 @@
|
|
|
67
67
|
"@types/babel__traverse": "7.20.7",
|
|
68
68
|
"@types/fs-extra": "11.0.4",
|
|
69
69
|
"@types/jsdom": "^21.1.7",
|
|
70
|
-
"@types/react": "^19.1.
|
|
70
|
+
"@types/react": "^19.1.8",
|
|
71
71
|
"@types/react-dom": "^19.1.6",
|
|
72
72
|
"@webdiscus/pug-loader": "^2.11.1",
|
|
73
73
|
"acorn": "^8.15.0",
|
|
@@ -92,14 +92,14 @@
|
|
|
92
92
|
"source-map": "^0.7.4",
|
|
93
93
|
"source-map-loader": "^5.0.0",
|
|
94
94
|
"style-loader": "^4.0.0",
|
|
95
|
-
"terser": "5.43.
|
|
95
|
+
"terser": "5.43.1",
|
|
96
96
|
"typescript": "^5.8.3",
|
|
97
97
|
"wast-loader": "^1.14.1",
|
|
98
98
|
"worker-rspack-loader": "^3.1.2",
|
|
99
|
-
"@rspack/cli": "1.4.7
|
|
100
|
-
"@rspack/
|
|
101
|
-
"@rspack/
|
|
102
|
-
"@rspack/
|
|
99
|
+
"@rspack/cli": "1.4.7",
|
|
100
|
+
"@rspack/test-tools": "1.4.7",
|
|
101
|
+
"@rspack/core": "1.4.7",
|
|
102
|
+
"@rspack/binding-testing": "1.4.1"
|
|
103
103
|
},
|
|
104
104
|
"peerDependencies": {
|
|
105
105
|
"@rspack/core": ">=1.0.0"
|