@rspack/core 0.5.7 → 0.5.8
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/Compilation.d.ts +1 -2
- package/dist/Compiler.d.ts +7 -6
- package/dist/Compiler.js +101 -164
- package/dist/NormalModuleFactory.d.ts +2 -1
- package/dist/NormalModuleFactory.js +25 -1
- package/dist/Watching.js +2 -2
- package/dist/builtin-plugin/JsLoaderRspackPlugin.d.ts +11 -0
- package/dist/builtin-plugin/JsLoaderRspackPlugin.js +7 -0
- package/dist/builtin-plugin/index.d.ts +1 -0
- package/dist/builtin-plugin/index.js +1 -0
- package/dist/config/adapter.js +9 -8
- package/dist/config/zod.d.ts +324 -70
- package/dist/config/zod.js +8 -1
- package/dist/exports.d.ts +16 -4
- package/dist/lite-tapable/index.d.ts +14 -1
- package/dist/lite-tapable/index.js +168 -1
- package/dist/loader-runner/index.d.ts +2 -2
- package/dist/loader-runner/index.js +4 -4
- package/dist/rspackOptionsApply.js +1 -0
- package/package.json +5 -5
package/dist/config/zod.js
CHANGED
|
@@ -329,7 +329,14 @@ const assetGeneratorDataUrlOptions = zod_1.z.strictObject({
|
|
|
329
329
|
encoding: zod_1.z.literal(false).or(zod_1.z.literal("base64")).optional(),
|
|
330
330
|
mimetype: zod_1.z.string().optional()
|
|
331
331
|
});
|
|
332
|
-
const
|
|
332
|
+
const assetGeneratorDataUrlFunction = zod_1.z
|
|
333
|
+
.function()
|
|
334
|
+
.args(zod_1.z.strictObject({
|
|
335
|
+
content: zod_1.z.string(),
|
|
336
|
+
filename: zod_1.z.string()
|
|
337
|
+
}))
|
|
338
|
+
.returns(zod_1.z.string());
|
|
339
|
+
const assetGeneratorDataUrl = assetGeneratorDataUrlOptions.or(assetGeneratorDataUrlFunction);
|
|
333
340
|
const assetInlineGeneratorOptions = zod_1.z.strictObject({
|
|
334
341
|
dataUrl: assetGeneratorDataUrl.optional()
|
|
335
342
|
});
|
package/dist/exports.d.ts
CHANGED
|
@@ -329,7 +329,10 @@ export declare const config: {
|
|
|
329
329
|
dataUrl?: {
|
|
330
330
|
encoding?: false | "base64" | undefined;
|
|
331
331
|
mimetype?: string | undefined;
|
|
332
|
-
} |
|
|
332
|
+
} | ((args_0: {
|
|
333
|
+
filename: string;
|
|
334
|
+
content: string;
|
|
335
|
+
}, ...args_1: unknown[]) => string) | undefined;
|
|
333
336
|
filename?: string | undefined;
|
|
334
337
|
publicPath?: string | undefined;
|
|
335
338
|
} | undefined;
|
|
@@ -337,7 +340,10 @@ export declare const config: {
|
|
|
337
340
|
dataUrl?: {
|
|
338
341
|
encoding?: false | "base64" | undefined;
|
|
339
342
|
mimetype?: string | undefined;
|
|
340
|
-
} |
|
|
343
|
+
} | ((args_0: {
|
|
344
|
+
filename: string;
|
|
345
|
+
content: string;
|
|
346
|
+
}, ...args_1: unknown[]) => string) | undefined;
|
|
341
347
|
} | undefined;
|
|
342
348
|
"asset/resource"?: {
|
|
343
349
|
filename?: string | undefined;
|
|
@@ -657,7 +663,10 @@ export declare const config: {
|
|
|
657
663
|
dataUrl?: {
|
|
658
664
|
encoding?: false | "base64" | undefined;
|
|
659
665
|
mimetype?: string | undefined;
|
|
660
|
-
} |
|
|
666
|
+
} | ((args_0: {
|
|
667
|
+
filename: string;
|
|
668
|
+
content: string;
|
|
669
|
+
}, ...args_1: unknown[]) => string) | undefined;
|
|
661
670
|
filename?: string | undefined;
|
|
662
671
|
publicPath?: string | undefined;
|
|
663
672
|
} | undefined;
|
|
@@ -665,7 +674,10 @@ export declare const config: {
|
|
|
665
674
|
dataUrl?: {
|
|
666
675
|
encoding?: false | "base64" | undefined;
|
|
667
676
|
mimetype?: string | undefined;
|
|
668
|
-
} |
|
|
677
|
+
} | ((args_0: {
|
|
678
|
+
filename: string;
|
|
679
|
+
content: string;
|
|
680
|
+
}, ...args_1: unknown[]) => string) | undefined;
|
|
669
681
|
} | undefined;
|
|
670
682
|
"asset/resource"?: {
|
|
671
683
|
filename?: string | undefined;
|
|
@@ -46,7 +46,7 @@ export interface HookInterceptor<T, R, AdditionalOptions = UnsetAdditionalOption
|
|
|
46
46
|
register?: (tap: FullTap & IfSet<AdditionalOptions>) => FullTap & IfSet<AdditionalOptions>;
|
|
47
47
|
}
|
|
48
48
|
type ArgumentNames<T extends any[]> = FixedSizeArray<T["length"], string>;
|
|
49
|
-
declare class Hook<T, R, AdditionalOptions = UnsetAdditionalOptions> {
|
|
49
|
+
export declare class Hook<T, R, AdditionalOptions = UnsetAdditionalOptions> {
|
|
50
50
|
args?: ArgumentNames<AsArray<T>>;
|
|
51
51
|
name?: string;
|
|
52
52
|
taps: (FullTap & IfSet<AdditionalOptions>)[];
|
|
@@ -58,6 +58,7 @@ declare class Hook<T, R, AdditionalOptions = UnsetAdditionalOptions> {
|
|
|
58
58
|
_runErrorInterceptors(e: Error): void;
|
|
59
59
|
_runTapInterceptors(tap: FullTap & IfSet<AdditionalOptions>): void;
|
|
60
60
|
_runDoneInterceptors(): void;
|
|
61
|
+
_runResultInterceptors(r: R): void;
|
|
61
62
|
isUsed(): boolean;
|
|
62
63
|
queryStageRange(stageRange: StageRange): QueriedHook<T, R, AdditionalOptions>;
|
|
63
64
|
callAsyncStageRange(queried: QueriedHook<T, R, AdditionalOptions>, ...args: Append<AsArray<T>, Callback<Error, R>>): void;
|
|
@@ -89,6 +90,13 @@ export declare class SyncHook<T, R = void, AdditionalOptions = UnsetAdditionalOp
|
|
|
89
90
|
tapAsync(): never;
|
|
90
91
|
tapPromise(): never;
|
|
91
92
|
}
|
|
93
|
+
export declare class SyncBailHook<T, R, AdditionalOptions = UnsetAdditionalOptions> extends Hook<T, R, AdditionalOptions> {
|
|
94
|
+
callAsyncStageRange(queried: QueriedHook<T, R, AdditionalOptions>, ...args: Append<AsArray<T>, Callback<Error, R>>): void;
|
|
95
|
+
call(...args: AsArray<T>): R;
|
|
96
|
+
callStageRange(queried: QueriedHook<T, R, AdditionalOptions>, ...args: AsArray<T>): R;
|
|
97
|
+
tapAsync(): never;
|
|
98
|
+
tapPromise(): never;
|
|
99
|
+
}
|
|
92
100
|
export declare class AsyncParallelHook<T, AdditionalOptions = UnsetAdditionalOptions> extends Hook<T, void, AdditionalOptions> {
|
|
93
101
|
callAsyncStageRange(queried: QueriedHook<T, void, AdditionalOptions>, ...args: Append<AsArray<T>, Callback<Error, void>>): void;
|
|
94
102
|
tapAsync(options: Options<AdditionalOptions>, fn: FnWithCallback<T, void>): void;
|
|
@@ -99,4 +107,9 @@ export declare class AsyncSeriesHook<T, AdditionalOptions = UnsetAdditionalOptio
|
|
|
99
107
|
tapAsync(options: Options<AdditionalOptions>, fn: FnWithCallback<T, void>): void;
|
|
100
108
|
tapPromise(options: Options<AdditionalOptions>, fn: Fn<T, void>): void;
|
|
101
109
|
}
|
|
110
|
+
export declare class AsyncSeriesBailHook<T, R, AdditionalOptions = UnsetAdditionalOptions> extends Hook<T, R, AdditionalOptions> {
|
|
111
|
+
callAsyncStageRange(queried: QueriedHook<T, R, AdditionalOptions>, ...args: Append<AsArray<T>, Callback<Error, R>>): void;
|
|
112
|
+
tapAsync(options: Options<AdditionalOptions>, fn: FnWithCallback<T, void>): void;
|
|
113
|
+
tapPromise(options: Options<AdditionalOptions>, fn: Fn<T, void>): void;
|
|
114
|
+
}
|
|
102
115
|
export {};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.AsyncSeriesHook = exports.AsyncParallelHook = exports.SyncHook = exports.QueriedHook = exports.safeStage = exports.maxStage = exports.minStage = void 0;
|
|
3
|
+
exports.AsyncSeriesBailHook = exports.AsyncSeriesHook = exports.AsyncParallelHook = exports.SyncBailHook = exports.SyncHook = exports.QueriedHook = exports.safeStage = exports.maxStage = exports.minStage = exports.Hook = void 0;
|
|
4
4
|
class Hook {
|
|
5
5
|
constructor(args, name) {
|
|
6
6
|
this.args = args;
|
|
@@ -55,6 +55,13 @@ class Hook {
|
|
|
55
55
|
}
|
|
56
56
|
}
|
|
57
57
|
}
|
|
58
|
+
_runResultInterceptors(r) {
|
|
59
|
+
for (const interceptor of this.interceptors) {
|
|
60
|
+
if (interceptor.result) {
|
|
61
|
+
interceptor.result(r);
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
}
|
|
58
65
|
isUsed() {
|
|
59
66
|
return this.taps.length > 0 || this.interceptors.length > 0;
|
|
60
67
|
}
|
|
@@ -136,6 +143,7 @@ class Hook {
|
|
|
136
143
|
this.taps[i] = item;
|
|
137
144
|
}
|
|
138
145
|
}
|
|
146
|
+
exports.Hook = Hook;
|
|
139
147
|
exports.minStage = -Infinity;
|
|
140
148
|
exports.maxStage = Infinity;
|
|
141
149
|
const allStageRange = [exports.minStage, exports.maxStage];
|
|
@@ -241,6 +249,59 @@ class SyncHook extends Hook {
|
|
|
241
249
|
}
|
|
242
250
|
}
|
|
243
251
|
exports.SyncHook = SyncHook;
|
|
252
|
+
class SyncBailHook extends Hook {
|
|
253
|
+
callAsyncStageRange(queried, ...args) {
|
|
254
|
+
const { stageRange: [from, to], tapsInRange } = queried;
|
|
255
|
+
const args2 = [...args];
|
|
256
|
+
const cb = args2.pop();
|
|
257
|
+
if (from === exports.minStage) {
|
|
258
|
+
this._runCallInterceptors(...args2);
|
|
259
|
+
}
|
|
260
|
+
for (let tap of tapsInRange) {
|
|
261
|
+
this._runTapInterceptors(tap);
|
|
262
|
+
let r = undefined;
|
|
263
|
+
try {
|
|
264
|
+
r = tap.fn(...args2);
|
|
265
|
+
}
|
|
266
|
+
catch (e) {
|
|
267
|
+
const err = e;
|
|
268
|
+
this._runErrorInterceptors(err);
|
|
269
|
+
return cb(err);
|
|
270
|
+
}
|
|
271
|
+
if (r !== undefined) {
|
|
272
|
+
this._runResultInterceptors(r);
|
|
273
|
+
return cb(null, r);
|
|
274
|
+
}
|
|
275
|
+
}
|
|
276
|
+
if (to === exports.maxStage) {
|
|
277
|
+
this._runDoneInterceptors();
|
|
278
|
+
cb(null);
|
|
279
|
+
}
|
|
280
|
+
}
|
|
281
|
+
call(...args) {
|
|
282
|
+
return this.callStageRange(this.queryStageRange(allStageRange), ...args);
|
|
283
|
+
}
|
|
284
|
+
callStageRange(queried, ...args) {
|
|
285
|
+
let result, error;
|
|
286
|
+
this.callAsyncStageRange(queried,
|
|
287
|
+
// @ts-expect-error
|
|
288
|
+
...args, (e, r) => {
|
|
289
|
+
error = e;
|
|
290
|
+
result = r;
|
|
291
|
+
});
|
|
292
|
+
if (error) {
|
|
293
|
+
throw error;
|
|
294
|
+
}
|
|
295
|
+
return result;
|
|
296
|
+
}
|
|
297
|
+
tapAsync() {
|
|
298
|
+
throw new Error("tapAsync is not supported on a SyncBailHook");
|
|
299
|
+
}
|
|
300
|
+
tapPromise() {
|
|
301
|
+
throw new Error("tapPromise is not supported on a SyncBailHook");
|
|
302
|
+
}
|
|
303
|
+
}
|
|
304
|
+
exports.SyncBailHook = SyncBailHook;
|
|
244
305
|
class AsyncParallelHook extends Hook {
|
|
245
306
|
callAsyncStageRange(queried, ...args) {
|
|
246
307
|
const { stageRange: [from, to], tapsInRange } = queried;
|
|
@@ -411,3 +472,109 @@ class AsyncSeriesHook extends Hook {
|
|
|
411
472
|
}
|
|
412
473
|
}
|
|
413
474
|
exports.AsyncSeriesHook = AsyncSeriesHook;
|
|
475
|
+
class AsyncSeriesBailHook extends Hook {
|
|
476
|
+
callAsyncStageRange(queried, ...args) {
|
|
477
|
+
const { stageRange: [from, to], tapsInRange } = queried;
|
|
478
|
+
const args2 = [...args];
|
|
479
|
+
const cb = args2.pop();
|
|
480
|
+
if (from === exports.minStage) {
|
|
481
|
+
this._runCallInterceptors(...args2);
|
|
482
|
+
}
|
|
483
|
+
const done = () => {
|
|
484
|
+
this._runDoneInterceptors();
|
|
485
|
+
cb(null);
|
|
486
|
+
};
|
|
487
|
+
const error = (e) => {
|
|
488
|
+
this._runErrorInterceptors(e);
|
|
489
|
+
cb(e);
|
|
490
|
+
};
|
|
491
|
+
const result = (r) => {
|
|
492
|
+
this._runResultInterceptors(r);
|
|
493
|
+
cb(null, r);
|
|
494
|
+
};
|
|
495
|
+
if (tapsInRange.length === 0)
|
|
496
|
+
return done();
|
|
497
|
+
let index = 0;
|
|
498
|
+
const next = () => {
|
|
499
|
+
const tap = tapsInRange[index];
|
|
500
|
+
this._runTapInterceptors(tap);
|
|
501
|
+
if (tap.type === "promise") {
|
|
502
|
+
const promise = tap.fn(...args2);
|
|
503
|
+
if (!promise || !promise.then) {
|
|
504
|
+
throw new Error("Tap function (tapPromise) did not return promise (returned " +
|
|
505
|
+
promise +
|
|
506
|
+
")");
|
|
507
|
+
}
|
|
508
|
+
promise.then((r) => {
|
|
509
|
+
index += 1;
|
|
510
|
+
if (r !== undefined) {
|
|
511
|
+
result(r);
|
|
512
|
+
}
|
|
513
|
+
else if (index === tapsInRange.length) {
|
|
514
|
+
done();
|
|
515
|
+
}
|
|
516
|
+
else {
|
|
517
|
+
next();
|
|
518
|
+
}
|
|
519
|
+
}, (e) => {
|
|
520
|
+
index = tapsInRange.length;
|
|
521
|
+
error(e);
|
|
522
|
+
});
|
|
523
|
+
}
|
|
524
|
+
else if (tap.type === "async") {
|
|
525
|
+
tap.fn(...args2, (e, r) => {
|
|
526
|
+
if (e) {
|
|
527
|
+
index = tapsInRange.length;
|
|
528
|
+
error(e);
|
|
529
|
+
}
|
|
530
|
+
else {
|
|
531
|
+
index += 1;
|
|
532
|
+
if (r !== undefined) {
|
|
533
|
+
result(r);
|
|
534
|
+
}
|
|
535
|
+
else if (index === tapsInRange.length) {
|
|
536
|
+
done();
|
|
537
|
+
}
|
|
538
|
+
else {
|
|
539
|
+
next();
|
|
540
|
+
}
|
|
541
|
+
}
|
|
542
|
+
});
|
|
543
|
+
}
|
|
544
|
+
else {
|
|
545
|
+
let hasError = false;
|
|
546
|
+
let r = undefined;
|
|
547
|
+
try {
|
|
548
|
+
r = tap.fn(...args2);
|
|
549
|
+
}
|
|
550
|
+
catch (e) {
|
|
551
|
+
hasError = true;
|
|
552
|
+
index = tapsInRange.length;
|
|
553
|
+
error(e);
|
|
554
|
+
}
|
|
555
|
+
if (!hasError) {
|
|
556
|
+
index += 1;
|
|
557
|
+
if (r !== undefined) {
|
|
558
|
+
result(r);
|
|
559
|
+
}
|
|
560
|
+
else if (index === tapsInRange.length) {
|
|
561
|
+
done();
|
|
562
|
+
}
|
|
563
|
+
else {
|
|
564
|
+
next();
|
|
565
|
+
}
|
|
566
|
+
}
|
|
567
|
+
}
|
|
568
|
+
if (index === tapsInRange.length)
|
|
569
|
+
return;
|
|
570
|
+
};
|
|
571
|
+
next();
|
|
572
|
+
}
|
|
573
|
+
tapAsync(options, fn) {
|
|
574
|
+
this._tap("async", options, fn);
|
|
575
|
+
}
|
|
576
|
+
tapPromise(options, fn) {
|
|
577
|
+
this._tap("promise", options, fn);
|
|
578
|
+
}
|
|
579
|
+
}
|
|
580
|
+
exports.AsyncSeriesBailHook = AsyncSeriesBailHook;
|
|
@@ -7,11 +7,11 @@
|
|
|
7
7
|
* Copyright (c) JS Foundation and other contributors
|
|
8
8
|
* https://github.com/webpack/loader-runner/blob/main/LICENSE
|
|
9
9
|
*/
|
|
10
|
-
import type { JsLoaderContext } from "@rspack/binding";
|
|
10
|
+
import type { JsLoaderContext, JsLoaderResult } from "@rspack/binding";
|
|
11
11
|
import { Compiler } from "../Compiler";
|
|
12
12
|
export declare function parsePathQueryFragment(str: string): {
|
|
13
13
|
path: string;
|
|
14
14
|
query: string;
|
|
15
15
|
fragment: string;
|
|
16
16
|
};
|
|
17
|
-
export declare function runLoaders(compiler: Compiler, rawContext: JsLoaderContext): Promise<
|
|
17
|
+
export declare function runLoaders(compiler: Compiler, rawContext: JsLoaderContext): Promise<JsLoaderResult>;
|
|
@@ -200,8 +200,8 @@ async function runLoaders(compiler, rawContext) {
|
|
|
200
200
|
loaderContext.importModule = function importModule(request, options, callback) {
|
|
201
201
|
if (!callback) {
|
|
202
202
|
return new Promise((resolve, reject) => {
|
|
203
|
-
compiler
|
|
204
|
-
.__internal_getInner()
|
|
203
|
+
compiler
|
|
204
|
+
.compilation.__internal_getInner()
|
|
205
205
|
.importModule(request, options.publicPath, options.baseUri, rawContext._moduleIdentifier, loaderContext.context, (err, res) => {
|
|
206
206
|
if (err)
|
|
207
207
|
reject(err);
|
|
@@ -224,8 +224,8 @@ async function runLoaders(compiler, rawContext) {
|
|
|
224
224
|
});
|
|
225
225
|
});
|
|
226
226
|
}
|
|
227
|
-
return compiler
|
|
228
|
-
.__internal_getInner()
|
|
227
|
+
return compiler
|
|
228
|
+
.compilation.__internal_getInner()
|
|
229
229
|
.importModule(request, options.publicPath, options.baseUri, rawContext._moduleIdentifier, loaderContext.context, (err, res) => {
|
|
230
230
|
if (err) {
|
|
231
231
|
callback(err, undefined);
|
|
@@ -137,6 +137,7 @@ class RspackOptionsApply {
|
|
|
137
137
|
if (options.experiments.asyncWebAssembly) {
|
|
138
138
|
new builtin_plugin_1.AsyncWebAssemblyModulesPlugin().apply(compiler);
|
|
139
139
|
}
|
|
140
|
+
new builtin_plugin_1.JsLoaderRspackPlugin(compiler).apply(compiler);
|
|
140
141
|
if (options.experiments.rspackFuture.disableApplyEntryLazily) {
|
|
141
142
|
applyEntryOptions(compiler, options);
|
|
142
143
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rspack/core",
|
|
3
|
-
"version": "0.5.
|
|
3
|
+
"version": "0.5.8",
|
|
4
4
|
"webpackVersion": "5.75.0",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"description": "A Fast Rust-based Web Bundler",
|
|
@@ -55,9 +55,9 @@
|
|
|
55
55
|
"styled-components": "^6.0.8",
|
|
56
56
|
"terser": "5.27.2",
|
|
57
57
|
"wast-loader": "^1.11.4",
|
|
58
|
-
"@rspack/plugin-minify": "^0.5.
|
|
59
|
-
"@rspack/
|
|
60
|
-
"@rspack/
|
|
58
|
+
"@rspack/plugin-minify": "^0.5.8",
|
|
59
|
+
"@rspack/plugin-node-polyfill": "^0.5.8",
|
|
60
|
+
"@rspack/core": "0.5.8"
|
|
61
61
|
},
|
|
62
62
|
"dependencies": {
|
|
63
63
|
"@module-federation/runtime-tools": "0.0.8",
|
|
@@ -72,7 +72,7 @@
|
|
|
72
72
|
"webpack-sources": "3.2.3",
|
|
73
73
|
"zod": "^3.21.4",
|
|
74
74
|
"zod-validation-error": "1.3.1",
|
|
75
|
-
"@rspack/binding": "0.5.
|
|
75
|
+
"@rspack/binding": "0.5.8"
|
|
76
76
|
},
|
|
77
77
|
"peerDependencies": {
|
|
78
78
|
"@swc/helpers": ">=0.5.1"
|