@rspack-debug/test-tools 2.0.0-canary-20260116 → 2.0.0-canary.20260120
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 +1 -2
- package/dist/case/cache.js +17 -6
- package/dist/case/common.js +10 -0
- package/dist/case/compiler.js +5 -0
- package/dist/case/config.d.ts +1 -0
- package/dist/case/config.js +19 -12
- package/dist/case/diagnostic.js +9 -3
- package/dist/case/error.js +8 -3
- package/dist/case/esm-output.js +9 -1
- package/dist/case/hash.js +9 -3
- package/dist/case/hook.js +9 -3
- package/dist/case/hot-step.js +1 -1
- package/dist/case/hot.js +16 -2
- package/dist/case/runner.js +6 -0
- package/dist/case/stats-api.js +6 -2
- package/dist/case/stats-output.js +16 -5
- package/dist/case/watch.js +23 -1
- package/dist/helper/directory.d.ts +5 -1
- package/dist/helper/directory.js +16 -3
- package/dist/plugin/lazy-compilation-test-plugin.js +2 -0
- package/dist/runner/node/index.js +3 -2
- package/dist/runner/web/index.js +5 -1
- package/package.json +8 -8
package/dist/case/builtin.js
CHANGED
|
@@ -63,7 +63,7 @@ function defaultOptions(context) {
|
|
|
63
63
|
cssChunkFilename: '[name].css',
|
|
64
64
|
assetModuleFilename: '[hash][ext][query]',
|
|
65
65
|
sourceMapFilename: '[file].map',
|
|
66
|
-
chunkLoadingGlobal: '
|
|
66
|
+
chunkLoadingGlobal: 'rspackChunk',
|
|
67
67
|
chunkLoading: 'jsonp',
|
|
68
68
|
uniqueName: '__rspack_test__',
|
|
69
69
|
enabledLibraryTypes: ['system'],
|
|
@@ -147,7 +147,6 @@ function defaultOptions(context) {
|
|
|
147
147
|
extensions: ['.js'],
|
|
148
148
|
},
|
|
149
149
|
experiments: {
|
|
150
|
-
css: true,
|
|
151
150
|
futureDefaults: true,
|
|
152
151
|
},
|
|
153
152
|
devtool: false,
|
package/dist/case/cache.js
CHANGED
|
@@ -93,9 +93,6 @@ async function generateOptions(context, temp, target, updatePlugin) {
|
|
|
93
93
|
emitOnErrors: true,
|
|
94
94
|
},
|
|
95
95
|
target,
|
|
96
|
-
experiments: {
|
|
97
|
-
css: true,
|
|
98
|
-
},
|
|
99
96
|
};
|
|
100
97
|
options.plugins ??= [];
|
|
101
98
|
options.plugins.push(new core_1.default.HotModuleReplacementPlugin());
|
|
@@ -194,7 +191,13 @@ function createRunner(context, name, file, env) {
|
|
|
194
191
|
await updatePlugin.goNext();
|
|
195
192
|
const stats = await compiler.build();
|
|
196
193
|
const jsonStats = stats.toJson({
|
|
197
|
-
|
|
194
|
+
assets: true,
|
|
195
|
+
chunks: true,
|
|
196
|
+
chunkModules: true,
|
|
197
|
+
modules: true,
|
|
198
|
+
entrypoints: true,
|
|
199
|
+
chunkGroups: true,
|
|
200
|
+
// errorDetails: true
|
|
198
201
|
});
|
|
199
202
|
await checkStats(jsonStats);
|
|
200
203
|
const updatedModules = await m.hot.check(options || true);
|
|
@@ -210,7 +213,11 @@ function createRunner(context, name, file, env) {
|
|
|
210
213
|
compiler.createCompiler();
|
|
211
214
|
const stats = await compiler.build();
|
|
212
215
|
const jsonStats = stats.toJson({
|
|
213
|
-
|
|
216
|
+
assets: true,
|
|
217
|
+
chunks: true,
|
|
218
|
+
entrypoints: true,
|
|
219
|
+
chunkGroups: true,
|
|
220
|
+
// errorDetails: true
|
|
214
221
|
});
|
|
215
222
|
await checkStats(jsonStats);
|
|
216
223
|
env.it(`NEXT_START run with compilerIndex==${compilerIndex}`, async () => {
|
|
@@ -228,7 +235,11 @@ function createRunner(context, name, file, env) {
|
|
|
228
235
|
compiler.createCompiler();
|
|
229
236
|
const stats = await compiler.build();
|
|
230
237
|
const jsonStats = stats.toJson({
|
|
231
|
-
|
|
238
|
+
assets: true,
|
|
239
|
+
chunks: true,
|
|
240
|
+
entrypoints: true,
|
|
241
|
+
chunkGroups: true,
|
|
242
|
+
// errorDetails: true
|
|
232
243
|
});
|
|
233
244
|
await checkStats(jsonStats);
|
|
234
245
|
env.it(`NEXT_MOVE_DIR_START run with compilerIndex==${compilerIndex}`, async () => {
|
package/dist/case/common.js
CHANGED
|
@@ -104,6 +104,10 @@ async function check(env, context, name) {
|
|
|
104
104
|
}
|
|
105
105
|
if (testConfig.writeStatsJson) {
|
|
106
106
|
const jsonStats = stats.toJson({
|
|
107
|
+
assets: true,
|
|
108
|
+
chunks: true,
|
|
109
|
+
entrypoints: true,
|
|
110
|
+
chunkGroups: true,
|
|
107
111
|
errorDetails: true,
|
|
108
112
|
});
|
|
109
113
|
fs_extra_1.default.writeFileSync(path_1.default.join(context.getDist(), 'stats.json'), JSON.stringify(jsonStats, null, 2), 'utf-8');
|
|
@@ -113,6 +117,12 @@ async function check(env, context, name) {
|
|
|
113
117
|
stats.hasErrors() ||
|
|
114
118
|
stats.hasWarnings()) {
|
|
115
119
|
const statsJson = stats.toJson({
|
|
120
|
+
assets: true,
|
|
121
|
+
chunks: true,
|
|
122
|
+
chunkModules: true,
|
|
123
|
+
modules: true,
|
|
124
|
+
entrypoints: true,
|
|
125
|
+
chunkGroups: true,
|
|
116
126
|
errorDetails: true,
|
|
117
127
|
});
|
|
118
128
|
if (statsJson.errors) {
|
package/dist/case/compiler.js
CHANGED
|
@@ -95,7 +95,12 @@ function createCompilerProcessor(name, caseConfig) {
|
|
|
95
95
|
expect(typeof stats).toBe('object');
|
|
96
96
|
const compilation = stats.compilation;
|
|
97
97
|
const statsJson = stats.toJson({
|
|
98
|
+
assets: true,
|
|
99
|
+
chunks: true,
|
|
100
|
+
chunkModules: true,
|
|
98
101
|
modules: true,
|
|
102
|
+
entrypoints: true,
|
|
103
|
+
chunkGroups: true,
|
|
99
104
|
reasons: true,
|
|
100
105
|
});
|
|
101
106
|
expect(typeof statsJson).toBe('object');
|
package/dist/case/config.d.ts
CHANGED
|
@@ -4,5 +4,6 @@ export type TConfigCaseConfig = Omit<TTestConfig, 'validate'>;
|
|
|
4
4
|
export declare function createConfigProcessor(name: string): ITestProcessor;
|
|
5
5
|
export declare function createConfigCase(name: string, src: string, dist: string): void;
|
|
6
6
|
export declare function defaultOptions(index: number, context: ITestContext): RspackOptions;
|
|
7
|
+
export declare function enableEsmLibraryPlugin(options: RspackOptions): boolean;
|
|
7
8
|
export declare function overrideOptions(index: number, context: ITestContext, options: RspackOptions): void;
|
|
8
9
|
export declare function findBundle(index: number, context: ITestContext, options: RspackOptions): string | string[];
|
package/dist/case/config.js
CHANGED
|
@@ -6,6 +6,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
6
6
|
exports.createConfigProcessor = createConfigProcessor;
|
|
7
7
|
exports.createConfigCase = createConfigCase;
|
|
8
8
|
exports.defaultOptions = defaultOptions;
|
|
9
|
+
exports.enableEsmLibraryPlugin = enableEsmLibraryPlugin;
|
|
9
10
|
exports.overrideOptions = overrideOptions;
|
|
10
11
|
exports.findBundle = findBundle;
|
|
11
12
|
const fs_extra_1 = __importDefault(require("fs-extra"));
|
|
@@ -76,11 +77,13 @@ function defaultOptions(index, context) {
|
|
|
76
77
|
optimization: {
|
|
77
78
|
minimize: false,
|
|
78
79
|
},
|
|
79
|
-
experiments: {
|
|
80
|
-
css: true,
|
|
81
|
-
},
|
|
82
80
|
};
|
|
83
81
|
}
|
|
82
|
+
function enableEsmLibraryPlugin(options) {
|
|
83
|
+
return (options.output?.library === 'modern-module' ||
|
|
84
|
+
(typeof options.output?.library === 'object' &&
|
|
85
|
+
(options.output?.library).type === 'modern-module'));
|
|
86
|
+
}
|
|
84
87
|
function overrideOptions(index, context, options) {
|
|
85
88
|
if (!options.entry) {
|
|
86
89
|
options.entry = './index.js';
|
|
@@ -89,9 +92,15 @@ function overrideOptions(index, context, options) {
|
|
|
89
92
|
options.amd = {};
|
|
90
93
|
}
|
|
91
94
|
if (!options.output?.filename) {
|
|
92
|
-
const
|
|
95
|
+
const runtimeChunkForModernModule = options.optimization?.runtimeChunk === undefined &&
|
|
96
|
+
enableEsmLibraryPlugin(options);
|
|
97
|
+
const outputModule = options.experiments?.outputModule || enableEsmLibraryPlugin(options);
|
|
93
98
|
options.output ??= {};
|
|
94
|
-
options.output.filename = `bundle${index}${outputModule ? '.mjs' : '.js'}`;
|
|
99
|
+
options.output.filename = `${runtimeChunkForModernModule ? `[name]${outputModule ? '.mjs' : '.js'}` : `bundle${index}${outputModule ? '.mjs' : '.js'}`}`;
|
|
100
|
+
}
|
|
101
|
+
if (enableEsmLibraryPlugin(options)) {
|
|
102
|
+
options.optimization ??= {};
|
|
103
|
+
options.optimization.runtimeChunk ??= { name: `runtime~${index}` };
|
|
95
104
|
}
|
|
96
105
|
if (options.cache === undefined)
|
|
97
106
|
options.cache = false;
|
|
@@ -110,13 +119,11 @@ function findBundle(index, context, options) {
|
|
|
110
119
|
const bundlePath = [];
|
|
111
120
|
if (options.output?.path &&
|
|
112
121
|
fs_extra_1.default.existsSync(path_1.default.join(options.output.path, `bundle${index}${ext}`))) {
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
bundlePath.push(path_1.default.relative(options.output.path, cssOutputPath));
|
|
119
|
-
}
|
|
122
|
+
const cssOutputPath = path_1.default.join(options.output.path, (typeof options.output?.cssFilename === 'string' &&
|
|
123
|
+
options.output?.cssFilename) ||
|
|
124
|
+
`bundle${index}.css`);
|
|
125
|
+
if (fs_extra_1.default.existsSync(cssOutputPath)) {
|
|
126
|
+
bundlePath.push(path_1.default.relative(options.output.path, cssOutputPath));
|
|
120
127
|
}
|
|
121
128
|
bundlePath.push(`./bundle${index}${ext}`);
|
|
122
129
|
}
|
package/dist/case/diagnostic.js
CHANGED
|
@@ -66,6 +66,15 @@ function defaultOptions(context) {
|
|
|
66
66
|
entry: {
|
|
67
67
|
main: './',
|
|
68
68
|
},
|
|
69
|
+
module: {
|
|
70
|
+
defaultRules: [
|
|
71
|
+
'...',
|
|
72
|
+
{
|
|
73
|
+
test: /\.css/,
|
|
74
|
+
type: 'css/auto',
|
|
75
|
+
},
|
|
76
|
+
],
|
|
77
|
+
},
|
|
69
78
|
mode: 'development',
|
|
70
79
|
devServer: {
|
|
71
80
|
hot: false,
|
|
@@ -79,9 +88,6 @@ function defaultOptions(context) {
|
|
|
79
88
|
force: false,
|
|
80
89
|
},
|
|
81
90
|
},
|
|
82
|
-
experiments: {
|
|
83
|
-
css: true,
|
|
84
|
-
},
|
|
85
91
|
};
|
|
86
92
|
}
|
|
87
93
|
async function check(env, context, name, options) {
|
package/dist/case/error.js
CHANGED
|
@@ -78,14 +78,19 @@ function options(context, custom) {
|
|
|
78
78
|
moduleIds: 'named',
|
|
79
79
|
chunkIds: 'named',
|
|
80
80
|
},
|
|
81
|
+
module: {
|
|
82
|
+
defaultRules: [
|
|
83
|
+
{
|
|
84
|
+
test: /\.css$/i,
|
|
85
|
+
type: 'css/auto',
|
|
86
|
+
},
|
|
87
|
+
],
|
|
88
|
+
},
|
|
81
89
|
otuput: {
|
|
82
90
|
bundlerInfo: {
|
|
83
91
|
force: false,
|
|
84
92
|
},
|
|
85
93
|
},
|
|
86
|
-
experiments: {
|
|
87
|
-
css: true,
|
|
88
|
-
},
|
|
89
94
|
};
|
|
90
95
|
if (typeof custom === 'function') {
|
|
91
96
|
options = (0, webpack_merge_1.default)(options, custom(context, options));
|
package/dist/case/esm-output.js
CHANGED
|
@@ -97,6 +97,15 @@ const defaultOptions = (_index, context) => ({
|
|
|
97
97
|
force: false,
|
|
98
98
|
},
|
|
99
99
|
},
|
|
100
|
+
module: {
|
|
101
|
+
defaultRules: [
|
|
102
|
+
'...',
|
|
103
|
+
{
|
|
104
|
+
test: /\.css$/i,
|
|
105
|
+
type: 'css/auto',
|
|
106
|
+
},
|
|
107
|
+
],
|
|
108
|
+
},
|
|
100
109
|
bail: true,
|
|
101
110
|
optimization: {
|
|
102
111
|
minimize: false,
|
|
@@ -110,7 +119,6 @@ const defaultOptions = (_index, context) => ({
|
|
|
110
119
|
},
|
|
111
120
|
plugins: [new core_1.default.experiments.EsmLibraryPlugin()],
|
|
112
121
|
experiments: {
|
|
113
|
-
css: true,
|
|
114
122
|
outputModule: true,
|
|
115
123
|
},
|
|
116
124
|
});
|
package/dist/case/hash.js
CHANGED
|
@@ -43,15 +43,21 @@ function createHashCase(name, src, dist) {
|
|
|
43
43
|
function defaultOptions(index, context) {
|
|
44
44
|
return {
|
|
45
45
|
context: context.getSource(),
|
|
46
|
+
module: {
|
|
47
|
+
defaultRules: [
|
|
48
|
+
'...',
|
|
49
|
+
{
|
|
50
|
+
test: /\.css$/i,
|
|
51
|
+
type: 'css/auto',
|
|
52
|
+
},
|
|
53
|
+
],
|
|
54
|
+
},
|
|
46
55
|
output: {
|
|
47
56
|
path: context.getDist(),
|
|
48
57
|
bundlerInfo: {
|
|
49
58
|
force: false,
|
|
50
59
|
},
|
|
51
60
|
},
|
|
52
|
-
experiments: {
|
|
53
|
-
css: true,
|
|
54
|
-
},
|
|
55
61
|
};
|
|
56
62
|
}
|
|
57
63
|
function overrideOptions(index, context, options) {
|
package/dist/case/hook.js
CHANGED
|
@@ -207,12 +207,18 @@ function defaultOptions(context, custom) {
|
|
|
207
207
|
force: false,
|
|
208
208
|
},
|
|
209
209
|
},
|
|
210
|
+
module: {
|
|
211
|
+
defaultRules: [
|
|
212
|
+
'...',
|
|
213
|
+
{
|
|
214
|
+
test: /\.css$/i,
|
|
215
|
+
type: 'css/auto',
|
|
216
|
+
},
|
|
217
|
+
],
|
|
218
|
+
},
|
|
210
219
|
optimization: {
|
|
211
220
|
minimize: false,
|
|
212
221
|
},
|
|
213
|
-
experiments: {
|
|
214
|
-
css: true,
|
|
215
|
-
},
|
|
216
222
|
};
|
|
217
223
|
if (custom) {
|
|
218
224
|
defaultOptions = (0, webpack_merge_1.default)(defaultOptions, custom(context));
|
package/dist/case/hot-step.js
CHANGED
|
@@ -17,7 +17,7 @@ const SELF_HANDLER = (file, options) => {
|
|
|
17
17
|
const hotUpdateGlobal = (_, modules) => {
|
|
18
18
|
res = Object.keys(modules);
|
|
19
19
|
};
|
|
20
|
-
const hotUpdateGlobalKey = escapeLocalName(`${options.output?.hotUpdateGlobal || '
|
|
20
|
+
const hotUpdateGlobalKey = escapeLocalName(`${options.output?.hotUpdateGlobal || 'rspackHotUpdate'}${options.output?.uniqueName || ''}`);
|
|
21
21
|
global.self ??= {};
|
|
22
22
|
global.self[hotUpdateGlobalKey] = hotUpdateGlobal;
|
|
23
23
|
require(file);
|
package/dist/case/hot.js
CHANGED
|
@@ -101,12 +101,20 @@ function defaultOptions(context, target) {
|
|
|
101
101
|
force: false,
|
|
102
102
|
},
|
|
103
103
|
},
|
|
104
|
+
module: {
|
|
105
|
+
defaultRules: [
|
|
106
|
+
'...',
|
|
107
|
+
{
|
|
108
|
+
test: /\.css$/i,
|
|
109
|
+
type: 'css/auto',
|
|
110
|
+
},
|
|
111
|
+
],
|
|
112
|
+
},
|
|
104
113
|
optimization: {
|
|
105
114
|
moduleIds: 'named',
|
|
106
115
|
},
|
|
107
116
|
target,
|
|
108
117
|
experiments: {
|
|
109
|
-
css: true,
|
|
110
118
|
// test incremental: "safe" here, we test default incremental in Incremental-*.test.js
|
|
111
119
|
incremental: 'safe',
|
|
112
120
|
},
|
|
@@ -181,7 +189,13 @@ function createHotRunner(context, name, file, env) {
|
|
|
181
189
|
throw new Error('Should generate stats during build');
|
|
182
190
|
}
|
|
183
191
|
const jsonStats = stats.toJson({
|
|
184
|
-
|
|
192
|
+
assets: true,
|
|
193
|
+
chunks: true,
|
|
194
|
+
chunkModules: true,
|
|
195
|
+
modules: true,
|
|
196
|
+
entrypoints: true,
|
|
197
|
+
chunkGroups: true,
|
|
198
|
+
// errorDetails: true
|
|
185
199
|
});
|
|
186
200
|
const compilerOptions = compiler.getOptions();
|
|
187
201
|
const checker = context.getValue(jsonStats.errors?.length
|
package/dist/case/runner.js
CHANGED
|
@@ -22,6 +22,12 @@ function cachedStats(context, name) {
|
|
|
22
22
|
return cached;
|
|
23
23
|
}
|
|
24
24
|
cached = compiler.getStats().toJson({
|
|
25
|
+
assets: true,
|
|
26
|
+
chunks: true,
|
|
27
|
+
chunkModules: true,
|
|
28
|
+
modules: true,
|
|
29
|
+
entrypoints: true,
|
|
30
|
+
chunkGroups: true,
|
|
25
31
|
errorDetails: true,
|
|
26
32
|
});
|
|
27
33
|
return cached;
|
package/dist/case/stats-api.js
CHANGED
|
@@ -52,9 +52,13 @@ function createStatsAPICase(name, src, dist, testConfig) {
|
|
|
52
52
|
}
|
|
53
53
|
function options(context, custom) {
|
|
54
54
|
const res = (custom?.(context) || {});
|
|
55
|
-
res.experiments ??= {};
|
|
56
|
-
res.experiments.css ??= true;
|
|
57
55
|
res.output ??= {};
|
|
56
|
+
res.module ??= {};
|
|
57
|
+
res.module.defaultRules ??= ['...'];
|
|
58
|
+
res.module.defaultRules.push({
|
|
59
|
+
test: /\.css$/,
|
|
60
|
+
type: 'css/auto',
|
|
61
|
+
});
|
|
58
62
|
res.output.bundlerInfo ??= {};
|
|
59
63
|
res.output.bundlerInfo.force ??= false;
|
|
60
64
|
if (!global.printLogger) {
|
|
@@ -61,8 +61,14 @@ function defaultOptions(index, context) {
|
|
|
61
61
|
force: false,
|
|
62
62
|
},
|
|
63
63
|
},
|
|
64
|
-
|
|
65
|
-
|
|
64
|
+
module: {
|
|
65
|
+
defaultRules: [
|
|
66
|
+
'...',
|
|
67
|
+
{
|
|
68
|
+
test: /\.css$/i,
|
|
69
|
+
type: 'css/auto',
|
|
70
|
+
},
|
|
71
|
+
],
|
|
66
72
|
},
|
|
67
73
|
};
|
|
68
74
|
}
|
|
@@ -77,12 +83,17 @@ function defaultOptions(index, context) {
|
|
|
77
83
|
force: false,
|
|
78
84
|
},
|
|
79
85
|
},
|
|
86
|
+
module: {
|
|
87
|
+
defaultRules: [
|
|
88
|
+
{
|
|
89
|
+
test: /\.css$/i,
|
|
90
|
+
type: 'css/auto',
|
|
91
|
+
},
|
|
92
|
+
],
|
|
93
|
+
},
|
|
80
94
|
optimization: {
|
|
81
95
|
minimize: false,
|
|
82
96
|
},
|
|
83
|
-
experiments: {
|
|
84
|
-
css: true,
|
|
85
|
-
},
|
|
86
97
|
};
|
|
87
98
|
}
|
|
88
99
|
function overrideOptions(index, context, options) {
|
package/dist/case/watch.js
CHANGED
|
@@ -104,6 +104,12 @@ function createWatchInitialProcessor(name, tempDir, step, watchState, { incremen
|
|
|
104
104
|
return () => {
|
|
105
105
|
if (!cached) {
|
|
106
106
|
cached = stats.toJson({
|
|
107
|
+
assets: true,
|
|
108
|
+
chunks: true,
|
|
109
|
+
chunkModules: true,
|
|
110
|
+
modules: true,
|
|
111
|
+
entrypoints: true,
|
|
112
|
+
chunkGroups: true,
|
|
107
113
|
errorDetails: true,
|
|
108
114
|
});
|
|
109
115
|
}
|
|
@@ -140,6 +146,12 @@ function createWatchInitialProcessor(name, tempDir, step, watchState, { incremen
|
|
|
140
146
|
stats.hasErrors() ||
|
|
141
147
|
stats.hasWarnings()) {
|
|
142
148
|
const statsJson = stats.toJson({
|
|
149
|
+
assets: true,
|
|
150
|
+
chunks: true,
|
|
151
|
+
chunkModules: true,
|
|
152
|
+
modules: true,
|
|
153
|
+
entrypoints: true,
|
|
154
|
+
chunkGroups: true,
|
|
143
155
|
errorDetails: true,
|
|
144
156
|
});
|
|
145
157
|
if (statsJson.errors) {
|
|
@@ -247,7 +259,12 @@ function overrideOptions(index, context, options, tempDir, nativeWatcher) {
|
|
|
247
259
|
options.output.filename = 'bundle.js';
|
|
248
260
|
options.optimization ??= {};
|
|
249
261
|
options.experiments ??= {};
|
|
250
|
-
options.
|
|
262
|
+
options.module ??= {};
|
|
263
|
+
options.module.defaultRules ??= ['...'];
|
|
264
|
+
options.module.defaultRules.push({
|
|
265
|
+
test: /\.css$/,
|
|
266
|
+
type: 'css/auto',
|
|
267
|
+
});
|
|
251
268
|
if (nativeWatcher) {
|
|
252
269
|
options.experiments.nativeWatcher ??= true;
|
|
253
270
|
}
|
|
@@ -298,6 +315,11 @@ function cachedWatchStats(context, name) {
|
|
|
298
315
|
return cached[stepName];
|
|
299
316
|
}
|
|
300
317
|
cached[stepName] = compiler.getStats().toJson({
|
|
318
|
+
entrypoints: true,
|
|
319
|
+
assets: true,
|
|
320
|
+
chunks: true,
|
|
321
|
+
chunkModules: true,
|
|
322
|
+
modules: true,
|
|
301
323
|
errorDetails: true,
|
|
302
324
|
});
|
|
303
325
|
return cached[stepName];
|
|
@@ -1,7 +1,11 @@
|
|
|
1
1
|
export declare const isDirectory: (p: string) => boolean;
|
|
2
2
|
export declare const isFile: (p: string) => boolean;
|
|
3
3
|
export declare const isValidCaseDirectory: (name: string) => boolean;
|
|
4
|
-
export declare function describeByWalk(
|
|
4
|
+
export declare function describeByWalk(
|
|
5
|
+
/**
|
|
6
|
+
* The test file absolute path.
|
|
7
|
+
*/
|
|
8
|
+
testFile: string, createCase: (name: string, src: string, dist: string) => void, options?: {
|
|
5
9
|
type?: 'file' | 'directory';
|
|
6
10
|
level?: number;
|
|
7
11
|
source?: string;
|
package/dist/helper/directory.js
CHANGED
|
@@ -14,7 +14,11 @@ const isFile = (p) => node_fs_1.default.lstatSync(p).isFile();
|
|
|
14
14
|
exports.isFile = isFile;
|
|
15
15
|
const isValidCaseDirectory = (name) => !name.startsWith('_') && !name.startsWith('.') && name !== 'node_modules';
|
|
16
16
|
exports.isValidCaseDirectory = isValidCaseDirectory;
|
|
17
|
-
function describeByWalk(
|
|
17
|
+
function describeByWalk(
|
|
18
|
+
/**
|
|
19
|
+
* The test file absolute path.
|
|
20
|
+
*/
|
|
21
|
+
testFile, createCase, options = {}) {
|
|
18
22
|
const describeFn = options.describe || describe;
|
|
19
23
|
const testBasename = node_path_1.default
|
|
20
24
|
.basename(testFile)
|
|
@@ -22,6 +26,7 @@ function describeByWalk(testFile, createCase, options = {}) {
|
|
|
22
26
|
const testId = testBasename.charAt(0).toLowerCase() + testBasename.slice(1);
|
|
23
27
|
const sourceBase = options.source || node_path_1.default.join(node_path_1.default.dirname(testFile), `${testId}Cases`);
|
|
24
28
|
const testSourceId = node_path_1.default.basename(sourceBase);
|
|
29
|
+
const absoluteTestDir = node_path_1.default.dirname(testFile);
|
|
25
30
|
const distBase = options.dist || node_path_1.default.join(node_path_1.default.dirname(testFile), 'js', testId);
|
|
26
31
|
const level = options.level || 2;
|
|
27
32
|
const type = options.type || 'directory';
|
|
@@ -59,7 +64,15 @@ function describeByWalk(testFile, createCase, options = {}) {
|
|
|
59
64
|
.join(`${testId}Cases-${testSourceId}`, caseName)
|
|
60
65
|
.split('.')
|
|
61
66
|
.shift());
|
|
62
|
-
|
|
67
|
+
let suiteName = name;
|
|
68
|
+
// support filter test by absolute path
|
|
69
|
+
if (process.env.testFilter?.includes(absoluteTestDir)) {
|
|
70
|
+
const fullCasePath = node_path_1.default.join(absoluteTestDir, testSourceId, caseName);
|
|
71
|
+
if (fullCasePath.includes(process.env.testFilter)) {
|
|
72
|
+
suiteName = fullCasePath;
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
describeFn(suiteName, () => {
|
|
63
76
|
const source = node_path_1.default.join(sourceBase, caseName);
|
|
64
77
|
let dist = '';
|
|
65
78
|
if (absoluteDist) {
|
|
@@ -74,7 +87,7 @@ function describeByWalk(testFile, createCase, options = {}) {
|
|
|
74
87
|
dist = node_path_1.default.join(sourceBase, caseName, relativeDist);
|
|
75
88
|
}
|
|
76
89
|
}
|
|
77
|
-
createCase(
|
|
90
|
+
createCase(suiteName, source, dist);
|
|
78
91
|
});
|
|
79
92
|
}
|
|
80
93
|
});
|
|
@@ -33,6 +33,8 @@ class LazyCompilationTestPlugin {
|
|
|
33
33
|
resolve(null);
|
|
34
34
|
});
|
|
35
35
|
server.on('request', (req, res) => {
|
|
36
|
+
// Set CORS headers for jsdom's XMLHttpRequest
|
|
37
|
+
res.setHeader('Access-Control-Allow-Origin', '*');
|
|
36
38
|
middleware(req, res, () => { });
|
|
37
39
|
});
|
|
38
40
|
server.on('connection', (socket) => {
|
|
@@ -41,6 +41,7 @@ const node_fs_1 = __importDefault(require("node:fs"));
|
|
|
41
41
|
const node_path_1 = __importDefault(require("node:path"));
|
|
42
42
|
const node_url_1 = require("node:url");
|
|
43
43
|
const node_vm_1 = __importStar(require("node:vm"));
|
|
44
|
+
const config_1 = require("../../case/config");
|
|
44
45
|
const asModule_1 = __importDefault(require("../../helper/legacy/asModule"));
|
|
45
46
|
const createFakeWorker_1 = __importDefault(require("../../helper/legacy/createFakeWorker"));
|
|
46
47
|
const urlToRelativePath_1 = __importDefault(require("../../helper/legacy/urlToRelativePath"));
|
|
@@ -279,8 +280,8 @@ class NodeRunner {
|
|
|
279
280
|
file,
|
|
280
281
|
});
|
|
281
282
|
}
|
|
282
|
-
if (file.path.endsWith('.mjs')
|
|
283
|
-
this._options.compilerOptions
|
|
283
|
+
if (file.path.endsWith('.mjs') ||
|
|
284
|
+
(0, config_1.enableEsmLibraryPlugin)(this._options.compilerOptions)) {
|
|
284
285
|
return this.requirers.get('esm')(currentDirectory, modulePath, {
|
|
285
286
|
...context,
|
|
286
287
|
file,
|
package/dist/runner/web/index.js
CHANGED
|
@@ -152,7 +152,11 @@ class WebRunner extends node_1.NodeRunner {
|
|
|
152
152
|
createBaseModuleScope() {
|
|
153
153
|
const moduleScope = super.createBaseModuleScope();
|
|
154
154
|
moduleScope.EventSource = EventSourceForNode_1.default;
|
|
155
|
-
moduleScope.fetch = async (url) => {
|
|
155
|
+
moduleScope.fetch = async (url, options) => {
|
|
156
|
+
// For Lazy Compilation Proxy the POST request to the real dev server.
|
|
157
|
+
if (options?.method === 'POST') {
|
|
158
|
+
return fetch(url, options);
|
|
159
|
+
}
|
|
156
160
|
try {
|
|
157
161
|
const filePath = this.urlToPath(url);
|
|
158
162
|
this.log(`fetch: ${url} -> ${filePath}`);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rspack-debug/test-tools",
|
|
3
|
-
"version": "2.0.0-canary
|
|
3
|
+
"version": "2.0.0-canary.20260120",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"description": "Test tools for rspack",
|
|
6
6
|
"main": "dist/index.js",
|
|
@@ -35,19 +35,19 @@
|
|
|
35
35
|
"directory": "packages/rspack-test-tools"
|
|
36
36
|
},
|
|
37
37
|
"dependencies": {
|
|
38
|
-
"@babel/generator": "7.28.
|
|
39
|
-
"@babel/parser": "7.28.
|
|
40
|
-
"@babel/traverse": "7.28.
|
|
41
|
-
"@babel/types": "7.28.
|
|
38
|
+
"@babel/generator": "7.28.6",
|
|
39
|
+
"@babel/parser": "7.28.6",
|
|
40
|
+
"@babel/traverse": "7.28.6",
|
|
41
|
+
"@babel/types": "7.28.6",
|
|
42
42
|
"cross-env": "^10.1.0",
|
|
43
43
|
"filenamify": "4.3.0",
|
|
44
44
|
"fs-extra": "^11.3.3",
|
|
45
|
-
"iconv-lite": "^0.7.
|
|
45
|
+
"iconv-lite": "^0.7.2",
|
|
46
46
|
"javascript-stringify": "^2.1.0",
|
|
47
47
|
"jest-diff": "^30.2.0",
|
|
48
48
|
"jest-snapshot": "29.7.0",
|
|
49
49
|
"jsdom": "^26.1.0",
|
|
50
|
-
"memfs": "4.
|
|
50
|
+
"memfs": "4.53.0",
|
|
51
51
|
"path-serializer": "0.5.1",
|
|
52
52
|
"pretty-format": "30.2.0",
|
|
53
53
|
"rimraf": "^5.0.10",
|
|
@@ -65,7 +65,7 @@
|
|
|
65
65
|
"@types/jsdom": "^21.1.7",
|
|
66
66
|
"typescript": "^5.9.3",
|
|
67
67
|
"wast-loader": "^1.14.1",
|
|
68
|
-
"@rspack/core": "npm:@rspack-debug/core@2.0.0-canary
|
|
68
|
+
"@rspack/core": "npm:@rspack-debug/core@2.0.0-canary.20260120"
|
|
69
69
|
},
|
|
70
70
|
"peerDependencies": {
|
|
71
71
|
"@rspack/core": ">=1.0.0"
|