@rspack/core 0.5.9 → 0.6.0-canary-77faf73-20240410004447
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 +4 -13
- package/dist/Compilation.js +11 -17
- package/dist/Compiler.d.ts +3 -8
- package/dist/Compiler.js +165 -144
- package/dist/ContextModuleFactory.d.ts +4 -8
- package/dist/ContextModuleFactory.js +26 -3
- package/dist/ExecuteModulePlugin.js +2 -2
- package/dist/Module.d.ts +20 -1
- package/dist/Module.js +1 -0
- package/dist/NormalModuleFactory.d.ts +8 -23
- package/dist/NormalModuleFactory.js +6 -4
- package/dist/Stats.js +2 -2
- package/dist/builtin-plugin/APIPlugin.d.ts +10 -0
- package/dist/builtin-plugin/APIPlugin.js +6 -0
- package/dist/builtin-plugin/CssModulesPlugin.d.ts +10 -0
- package/dist/builtin-plugin/CssModulesPlugin.js +6 -0
- package/dist/builtin-plugin/EntryPlugin.d.ts +1 -0
- package/dist/builtin-plugin/EntryPlugin.js +3 -2
- package/dist/builtin-plugin/ExternalsPlugin.d.ts +2 -2
- package/dist/builtin-plugin/JsLoaderRspackPlugin.js +3 -1
- package/dist/builtin-plugin/SplitChunksPlugin.js +2 -1
- package/dist/builtin-plugin/css-extract/hmr/hotModuleReplacement.d.ts +3 -0
- package/dist/builtin-plugin/css-extract/hmr/hotModuleReplacement.js +222 -0
- package/dist/builtin-plugin/css-extract/hmr/normalize-url.d.ts +2 -0
- package/dist/builtin-plugin/css-extract/hmr/normalize-url.js +38 -0
- package/dist/builtin-plugin/css-extract/index.d.ts +22 -0
- package/dist/builtin-plugin/css-extract/index.js +109 -0
- package/dist/builtin-plugin/css-extract/loader-options.json +32 -0
- package/dist/builtin-plugin/css-extract/loader.d.ts +15 -0
- package/dist/builtin-plugin/css-extract/loader.js +191 -0
- package/dist/builtin-plugin/css-extract/plugin-options.json +79 -0
- package/dist/builtin-plugin/css-extract/utils.d.ts +5 -0
- package/dist/builtin-plugin/css-extract/utils.js +51 -0
- package/dist/builtin-plugin/index.d.ts +4 -6
- package/dist/builtin-plugin/index.js +3 -15
- package/dist/config/adapter.js +58 -8
- package/dist/config/adapterRuleUse.d.ts +2 -2
- package/dist/config/defaults.js +65 -35
- package/dist/config/normalization.d.ts +1 -0
- package/dist/config/normalization.js +9 -1
- package/dist/config/zod.d.ts +706 -23
- package/dist/config/zod.js +47 -4
- package/dist/container/ContainerReferencePlugin.d.ts +1 -1
- package/dist/exports.d.ts +67 -11
- package/dist/exports.js +7 -1
- package/dist/lib/EntryOptionPlugin.js +1 -1
- package/dist/lib/NormalModuleReplacementPlugin.d.ts +19 -0
- package/dist/lib/NormalModuleReplacementPlugin.js +75 -0
- package/dist/lite-tapable/index.d.ts +25 -0
- package/dist/lite-tapable/index.js +70 -1
- package/dist/rspackOptionsApply.d.ts +0 -1
- package/dist/rspackOptionsApply.js +8 -21
- package/dist/util/comparators.d.ts +1 -1
- package/package.json +10 -7
package/dist/config/zod.js
CHANGED
|
@@ -98,6 +98,7 @@ const filename = filenameTemplate.or(zod_1.z
|
|
|
98
98
|
const entryFilename = filenameTemplate;
|
|
99
99
|
const entryRuntime = zod_1.z.literal(false).or(zod_1.z.string());
|
|
100
100
|
const entryItem = zod_1.z.string().or(zod_1.z.array(zod_1.z.string()));
|
|
101
|
+
const entryDependOn = zod_1.z.string().or(zod_1.z.array(zod_1.z.string()));
|
|
101
102
|
const entryDescription = zod_1.z.strictObject({
|
|
102
103
|
import: entryItem,
|
|
103
104
|
runtime: entryRuntime.optional(),
|
|
@@ -107,7 +108,8 @@ const entryDescription = zod_1.z.strictObject({
|
|
|
107
108
|
asyncChunks: asyncChunks.optional(),
|
|
108
109
|
wasmLoading: wasmLoading.optional(),
|
|
109
110
|
filename: entryFilename.optional(),
|
|
110
|
-
library: libraryOptions.optional()
|
|
111
|
+
library: libraryOptions.optional(),
|
|
112
|
+
dependOn: entryDependOn.optional()
|
|
111
113
|
});
|
|
112
114
|
const entryUnnamed = entryItem;
|
|
113
115
|
const entryObject = zod_1.z.record(entryItem.or(entryDescription));
|
|
@@ -311,6 +313,16 @@ const assetParserDataUrl = assetParserDataUrlOptions;
|
|
|
311
313
|
const assetParserOptions = zod_1.z.strictObject({
|
|
312
314
|
dataUrlCondition: assetParserDataUrl.optional()
|
|
313
315
|
});
|
|
316
|
+
const cssParserNamedExports = zod_1.z.boolean();
|
|
317
|
+
const cssParserOptions = zod_1.z.strictObject({
|
|
318
|
+
namedExports: cssParserNamedExports.optional()
|
|
319
|
+
});
|
|
320
|
+
const cssAutoParserOptions = zod_1.z.strictObject({
|
|
321
|
+
namedExports: cssParserNamedExports.optional()
|
|
322
|
+
});
|
|
323
|
+
const cssModuleParserOptions = zod_1.z.strictObject({
|
|
324
|
+
namedExports: cssParserNamedExports.optional()
|
|
325
|
+
});
|
|
314
326
|
//TODO: "weak", "lazy-once"
|
|
315
327
|
const dynamicImportMode = zod_1.z.enum(["eager", "lazy"]);
|
|
316
328
|
const dynamicImportPreload = zod_1.z.union([zod_1.z.boolean(), zod_1.z.number()]);
|
|
@@ -324,6 +336,9 @@ const javascriptParserOptions = zod_1.z.strictObject({
|
|
|
324
336
|
});
|
|
325
337
|
const parserOptionsByModuleTypeKnown = zod_1.z.strictObject({
|
|
326
338
|
asset: assetParserOptions.optional(),
|
|
339
|
+
css: cssParserOptions.optional(),
|
|
340
|
+
"css/auto": cssAutoParserOptions.optional(),
|
|
341
|
+
"css/module": cssModuleParserOptions.optional(),
|
|
327
342
|
javascript: javascriptParserOptions.optional()
|
|
328
343
|
});
|
|
329
344
|
const parserOptionsByModuleTypeUnknown = zod_1.z.record(zod_1.z.record(zod_1.z.any()));
|
|
@@ -348,10 +363,36 @@ const assetResourceGeneratorOptions = zod_1.z.strictObject({
|
|
|
348
363
|
publicPath: publicPath.optional()
|
|
349
364
|
});
|
|
350
365
|
const assetGeneratorOptions = assetInlineGeneratorOptions.merge(assetResourceGeneratorOptions);
|
|
366
|
+
const cssGeneratorExportsConvention = zod_1.z.enum([
|
|
367
|
+
"as-is",
|
|
368
|
+
"camel-case",
|
|
369
|
+
"camel-case-only",
|
|
370
|
+
"dashes",
|
|
371
|
+
"dashes-only"
|
|
372
|
+
]);
|
|
373
|
+
const cssGeneratorExportsOnly = zod_1.z.boolean();
|
|
374
|
+
const cssGeneratorLocalIdentName = zod_1.z.string();
|
|
375
|
+
const cssGeneratorOptions = zod_1.z.strictObject({
|
|
376
|
+
exportsConvention: cssGeneratorExportsConvention.optional(),
|
|
377
|
+
exportsOnly: cssGeneratorExportsOnly.optional()
|
|
378
|
+
});
|
|
379
|
+
const cssAutoGeneratorOptions = zod_1.z.strictObject({
|
|
380
|
+
exportsConvention: cssGeneratorExportsConvention.optional(),
|
|
381
|
+
exportsOnly: cssGeneratorExportsOnly.optional(),
|
|
382
|
+
localIdentName: cssGeneratorLocalIdentName.optional()
|
|
383
|
+
});
|
|
384
|
+
const cssModuleGeneratorOptions = zod_1.z.strictObject({
|
|
385
|
+
exportsConvention: cssGeneratorExportsConvention.optional(),
|
|
386
|
+
exportsOnly: cssGeneratorExportsOnly.optional(),
|
|
387
|
+
localIdentName: cssGeneratorLocalIdentName.optional()
|
|
388
|
+
});
|
|
351
389
|
const generatorOptionsByModuleTypeKnown = zod_1.z.strictObject({
|
|
352
390
|
asset: assetGeneratorOptions.optional(),
|
|
353
391
|
"asset/inline": assetInlineGeneratorOptions.optional(),
|
|
354
|
-
"asset/resource": assetResourceGeneratorOptions.optional()
|
|
392
|
+
"asset/resource": assetResourceGeneratorOptions.optional(),
|
|
393
|
+
css: cssGeneratorOptions.optional(),
|
|
394
|
+
"css/auto": cssAutoGeneratorOptions.optional(),
|
|
395
|
+
"css/module": cssModuleGeneratorOptions.optional()
|
|
355
396
|
});
|
|
356
397
|
const generatorOptionsByModuleTypeUnknown = zod_1.z.record(zod_1.z.record(zod_1.z.any()));
|
|
357
398
|
const generatorOptionsByModuleType = generatorOptionsByModuleTypeKnown.or(generatorOptionsByModuleTypeUnknown);
|
|
@@ -585,7 +626,8 @@ const statsOptions = zod_1.z.strictObject({
|
|
|
585
626
|
children: zod_1.z.boolean().optional(),
|
|
586
627
|
usedExports: zod_1.z.boolean().optional(),
|
|
587
628
|
providedExports: zod_1.z.boolean().optional(),
|
|
588
|
-
optimizationBailout: zod_1.z.boolean().optional()
|
|
629
|
+
optimizationBailout: zod_1.z.boolean().optional(),
|
|
630
|
+
orphanModules: zod_1.z.boolean().optional()
|
|
589
631
|
});
|
|
590
632
|
const statsValue = zod_1.z
|
|
591
633
|
.enum(["none", "errors-only", "errors-warnings", "normal", "verbose"])
|
|
@@ -621,8 +663,10 @@ const optimizationSplitChunksChunks = zod_1.z
|
|
|
621
663
|
.or(zod_1.z.instanceof(RegExp))
|
|
622
664
|
.or(zod_1.z.function().args(zod_1.z.instanceof(Chunk_1.Chunk)).returns(zod_1.z.boolean()));
|
|
623
665
|
const optimizationSplitChunksSizes = zod_1.z.number();
|
|
666
|
+
const optimizationSplitChunksDefaultSizeTypes = zod_1.z.array(zod_1.z.string());
|
|
624
667
|
const sharedOptimizationSplitChunksCacheGroup = {
|
|
625
668
|
chunks: optimizationSplitChunksChunks.optional(),
|
|
669
|
+
defaultSizeTypes: optimizationSplitChunksDefaultSizeTypes.optional(),
|
|
626
670
|
minChunks: zod_1.z.number().min(1).optional(),
|
|
627
671
|
name: optimizationSplitChunksName.optional(),
|
|
628
672
|
minSize: optimizationSplitChunksSizes.optional(),
|
|
@@ -689,7 +733,6 @@ const optimization = zod_1.z.strictObject({
|
|
|
689
733
|
//#region Experiments
|
|
690
734
|
const rspackFutureOptions = zod_1.z.strictObject({
|
|
691
735
|
newTreeshaking: zod_1.z.boolean().optional(),
|
|
692
|
-
disableApplyEntryLazily: zod_1.z.boolean().optional(),
|
|
693
736
|
bundlerInfo: zod_1.z
|
|
694
737
|
.strictObject({
|
|
695
738
|
version: zod_1.z.string().optional(),
|
|
@@ -21,7 +21,7 @@ export type RemotesConfig = {
|
|
|
21
21
|
export declare class ContainerReferencePlugin extends RspackBuiltinPlugin {
|
|
22
22
|
name: BuiltinPluginName;
|
|
23
23
|
_options: {
|
|
24
|
-
remoteType: "module" | "promise" | "script" | "commonjs" | "
|
|
24
|
+
remoteType: "module" | "promise" | "script" | "commonjs" | "global" | "import" | "amd" | "commonjs2" | "var" | "assign" | "this" | "window" | "self" | "commonjs-module" | "commonjs-static" | "amd-require" | "umd" | "umd2" | "jsonp" | "system" | "node-commonjs";
|
|
25
25
|
remotes: [string, {
|
|
26
26
|
external: string[];
|
|
27
27
|
shareScope: string;
|
package/dist/exports.d.ts
CHANGED
|
@@ -11,7 +11,7 @@ export { RspackOptionsApply, RspackOptionsApply as WebpackOptionsApply };
|
|
|
11
11
|
export { RuntimeGlobals } from "./RuntimeGlobals";
|
|
12
12
|
export { Stats } from "./Stats";
|
|
13
13
|
export type { StatsCompilation, StatsAsset, StatsChunk, StatsError, StatsModule, StatsWarnings } from "./Stats";
|
|
14
|
-
export
|
|
14
|
+
export { MultiStats } from "./MultiStats";
|
|
15
15
|
export type { ChunkGroup } from "./ChunkGroup";
|
|
16
16
|
export type { NormalModuleFactory } from "./NormalModuleFactory";
|
|
17
17
|
export { NormalModule } from "./NormalModule";
|
|
@@ -51,6 +51,7 @@ export declare const config: {
|
|
|
51
51
|
} | undefined;
|
|
52
52
|
umdNamedDefine?: boolean | undefined;
|
|
53
53
|
} | undefined;
|
|
54
|
+
dependOn?: string | string[] | undefined;
|
|
54
55
|
}> | ((...args: unknown[]) => string | string[] | Record<string, string | string[] | {
|
|
55
56
|
import: (string | string[]) & (string | string[] | undefined);
|
|
56
57
|
runtime?: string | false | undefined;
|
|
@@ -77,6 +78,7 @@ export declare const config: {
|
|
|
77
78
|
} | undefined;
|
|
78
79
|
umdNamedDefine?: boolean | undefined;
|
|
79
80
|
} | undefined;
|
|
81
|
+
dependOn?: string | string[] | undefined;
|
|
80
82
|
}>) | undefined;
|
|
81
83
|
output?: {
|
|
82
84
|
path?: string | undefined;
|
|
@@ -154,7 +156,7 @@ export declare const config: {
|
|
|
154
156
|
devtoolModuleFilenameTemplate?: string | ((args_0: any) => any) | undefined;
|
|
155
157
|
devtoolFallbackModuleFilenameTemplate?: string | ((args_0: any) => any) | undefined;
|
|
156
158
|
} | undefined;
|
|
157
|
-
target?: false | "node" | "
|
|
159
|
+
target?: false | "node" | "web" | "webworker" | "es3" | "es5" | "es2015" | "es2016" | "es2017" | "es2018" | "es2019" | "es2020" | "es2021" | "es2022" | "browserslist" | "async-node" | `node${number}` | `async-node${number}` | `node${number}.${number}` | `async-node${number}.${number}` | "electron-main" | `electron${number}-main` | `electron${number}.${number}-main` | "electron-renderer" | `electron${number}-renderer` | `electron${number}.${number}-renderer` | "electron-preload" | `electron${number}-preload` | `electron${number}.${number}-preload` | ("node" | "web" | "webworker" | "es3" | "es5" | "es2015" | "es2016" | "es2017" | "es2018" | "es2019" | "es2020" | "es2021" | "es2022" | "browserslist" | "async-node" | `node${number}` | `async-node${number}` | `node${number}.${number}` | `async-node${number}.${number}` | "electron-main" | `electron${number}-main` | `electron${number}.${number}-main` | "electron-renderer" | `electron${number}-renderer` | `electron${number}.${number}-renderer` | "electron-preload" | `electron${number}-preload` | `electron${number}.${number}-preload`)[] | undefined;
|
|
158
160
|
mode?: "production" | "development" | "none" | undefined;
|
|
159
161
|
experiments?: {
|
|
160
162
|
lazyCompilation?: boolean | undefined;
|
|
@@ -166,7 +168,6 @@ export declare const config: {
|
|
|
166
168
|
futureDefaults?: boolean | undefined;
|
|
167
169
|
rspackFuture?: {
|
|
168
170
|
newTreeshaking?: boolean | undefined;
|
|
169
|
-
disableApplyEntryLazily?: boolean | undefined;
|
|
170
171
|
bundlerInfo?: {
|
|
171
172
|
version?: string | undefined;
|
|
172
173
|
force?: boolean | "version"[] | undefined;
|
|
@@ -177,7 +178,7 @@ export declare const config: {
|
|
|
177
178
|
context?: string | undefined;
|
|
178
179
|
dependencyType?: string | undefined;
|
|
179
180
|
request?: string | undefined;
|
|
180
|
-
}, args_1: (args_0: Error | undefined, args_1: string | boolean | string[] | Record<string, string | string[]> | undefined, args_2: "module" | "promise" | "script" | "commonjs" | "
|
|
181
|
+
}, args_1: (args_0: Error | undefined, args_1: string | boolean | string[] | Record<string, string | string[]> | undefined, args_2: "module" | "promise" | "script" | "commonjs" | "global" | "import" | "amd" | "commonjs2" | "var" | "assign" | "this" | "window" | "self" | "commonjs-module" | "commonjs-static" | "amd-require" | "umd" | "umd2" | "jsonp" | "system" | "node-commonjs" | undefined, ...args_3: unknown[]) => void, ...args_2: unknown[]) => unknown) | ((args_0: {
|
|
181
182
|
context?: string | undefined;
|
|
182
183
|
dependencyType?: string | undefined;
|
|
183
184
|
request?: string | undefined;
|
|
@@ -185,12 +186,12 @@ export declare const config: {
|
|
|
185
186
|
context?: string | undefined;
|
|
186
187
|
dependencyType?: string | undefined;
|
|
187
188
|
request?: string | undefined;
|
|
188
|
-
}, args_1: (args_0: Error | undefined, args_1: string | boolean | string[] | Record<string, string | string[]> | undefined, args_2: "module" | "promise" | "script" | "commonjs" | "
|
|
189
|
+
}, args_1: (args_0: Error | undefined, args_1: string | boolean | string[] | Record<string, string | string[]> | undefined, args_2: "module" | "promise" | "script" | "commonjs" | "global" | "import" | "amd" | "commonjs2" | "var" | "assign" | "this" | "window" | "self" | "commonjs-module" | "commonjs-static" | "amd-require" | "umd" | "umd2" | "jsonp" | "system" | "node-commonjs" | undefined, ...args_3: unknown[]) => void, ...args_2: unknown[]) => unknown) | ((args_0: {
|
|
189
190
|
context?: string | undefined;
|
|
190
191
|
dependencyType?: string | undefined;
|
|
191
192
|
request?: string | undefined;
|
|
192
193
|
}, ...args_1: unknown[]) => Promise<string | boolean | string[] | Record<string, string | string[]>>))[] | undefined;
|
|
193
|
-
externalsType?: "module" | "promise" | "script" | "commonjs" | "
|
|
194
|
+
externalsType?: "module" | "promise" | "script" | "commonjs" | "global" | "import" | "amd" | "commonjs2" | "var" | "assign" | "this" | "window" | "self" | "commonjs-module" | "commonjs-static" | "amd-require" | "umd" | "umd2" | "jsonp" | "system" | "node-commonjs" | undefined;
|
|
194
195
|
externalsPresets?: {
|
|
195
196
|
node?: boolean | undefined;
|
|
196
197
|
web?: boolean | undefined;
|
|
@@ -260,6 +261,7 @@ export declare const config: {
|
|
|
260
261
|
usedExports?: boolean | undefined;
|
|
261
262
|
providedExports?: boolean | undefined;
|
|
262
263
|
optimizationBailout?: boolean | undefined;
|
|
264
|
+
orphanModules?: boolean | undefined;
|
|
263
265
|
} | undefined;
|
|
264
266
|
snapshot?: {
|
|
265
267
|
module?: {
|
|
@@ -279,6 +281,7 @@ export declare const config: {
|
|
|
279
281
|
mergeDuplicateChunks?: boolean | undefined;
|
|
280
282
|
splitChunks?: false | {
|
|
281
283
|
chunks?: RegExp | "async" | "initial" | "all" | ((args_0: import("./Chunk").Chunk, ...args_1: unknown[]) => boolean) | undefined;
|
|
284
|
+
defaultSizeTypes?: string[] | undefined;
|
|
282
285
|
minChunks?: number | undefined;
|
|
283
286
|
name?: string | false | ((args_0: import("./Module").Module | undefined, ...args_1: unknown[]) => unknown) | undefined;
|
|
284
287
|
minSize?: number | undefined;
|
|
@@ -288,6 +291,7 @@ export declare const config: {
|
|
|
288
291
|
automaticNameDelimiter?: string | undefined;
|
|
289
292
|
cacheGroups?: Record<string, false | {
|
|
290
293
|
chunks?: RegExp | "async" | "initial" | "all" | ((args_0: import("./Chunk").Chunk, ...args_1: unknown[]) => boolean) | undefined;
|
|
294
|
+
defaultSizeTypes?: string[] | undefined;
|
|
291
295
|
minChunks?: number | undefined;
|
|
292
296
|
name?: string | false | ((args_0: import("./Module").Module | undefined, ...args_1: unknown[]) => unknown) | undefined;
|
|
293
297
|
minSize?: number | undefined;
|
|
@@ -343,6 +347,15 @@ export declare const config: {
|
|
|
343
347
|
maxSize?: number | undefined;
|
|
344
348
|
} | undefined;
|
|
345
349
|
} | undefined;
|
|
350
|
+
css?: {
|
|
351
|
+
namedExports?: boolean | undefined;
|
|
352
|
+
} | undefined;
|
|
353
|
+
"css/auto"?: {
|
|
354
|
+
namedExports?: boolean | undefined;
|
|
355
|
+
} | undefined;
|
|
356
|
+
"css/module"?: {
|
|
357
|
+
namedExports?: boolean | undefined;
|
|
358
|
+
} | undefined;
|
|
346
359
|
javascript?: {
|
|
347
360
|
dynamicImportMode?: "eager" | "lazy" | undefined;
|
|
348
361
|
dynamicImportPreload?: number | boolean | undefined;
|
|
@@ -375,6 +388,20 @@ export declare const config: {
|
|
|
375
388
|
filename?: string | undefined;
|
|
376
389
|
publicPath?: string | undefined;
|
|
377
390
|
} | undefined;
|
|
391
|
+
css?: {
|
|
392
|
+
exportsConvention?: "as-is" | "camel-case" | "camel-case-only" | "dashes" | "dashes-only" | undefined;
|
|
393
|
+
exportsOnly?: boolean | undefined;
|
|
394
|
+
} | undefined;
|
|
395
|
+
"css/auto"?: {
|
|
396
|
+
exportsConvention?: "as-is" | "camel-case" | "camel-case-only" | "dashes" | "dashes-only" | undefined;
|
|
397
|
+
exportsOnly?: boolean | undefined;
|
|
398
|
+
localIdentName?: string | undefined;
|
|
399
|
+
} | undefined;
|
|
400
|
+
"css/module"?: {
|
|
401
|
+
exportsConvention?: "as-is" | "camel-case" | "camel-case-only" | "dashes" | "dashes-only" | undefined;
|
|
402
|
+
exportsOnly?: boolean | undefined;
|
|
403
|
+
localIdentName?: string | undefined;
|
|
404
|
+
} | undefined;
|
|
378
405
|
} | undefined;
|
|
379
406
|
noParse?: string | RegExp | ((args_0: string, ...args_1: unknown[]) => boolean) | (string | RegExp | ((args_0: string, ...args_1: unknown[]) => boolean))[] | undefined;
|
|
380
407
|
} | undefined;
|
|
@@ -411,6 +438,7 @@ export declare const config: {
|
|
|
411
438
|
} | undefined;
|
|
412
439
|
umdNamedDefine?: boolean | undefined;
|
|
413
440
|
} | undefined;
|
|
441
|
+
dependOn?: string | string[] | undefined;
|
|
414
442
|
}> | ((...args: unknown[]) => string | string[] | Record<string, string | string[] | {
|
|
415
443
|
import: (string | string[]) & (string | string[] | undefined);
|
|
416
444
|
runtime?: string | false | undefined;
|
|
@@ -437,6 +465,7 @@ export declare const config: {
|
|
|
437
465
|
} | undefined;
|
|
438
466
|
umdNamedDefine?: boolean | undefined;
|
|
439
467
|
} | undefined;
|
|
468
|
+
dependOn?: string | string[] | undefined;
|
|
440
469
|
}>) | undefined;
|
|
441
470
|
output?: {
|
|
442
471
|
path?: string | undefined;
|
|
@@ -514,7 +543,7 @@ export declare const config: {
|
|
|
514
543
|
devtoolModuleFilenameTemplate?: string | ((args_0: any) => any) | undefined;
|
|
515
544
|
devtoolFallbackModuleFilenameTemplate?: string | ((args_0: any) => any) | undefined;
|
|
516
545
|
} | undefined;
|
|
517
|
-
target?: false | "node" | "
|
|
546
|
+
target?: false | "node" | "web" | "webworker" | "es3" | "es5" | "es2015" | "es2016" | "es2017" | "es2018" | "es2019" | "es2020" | "es2021" | "es2022" | "browserslist" | "async-node" | `node${number}` | `async-node${number}` | `node${number}.${number}` | `async-node${number}.${number}` | "electron-main" | `electron${number}-main` | `electron${number}.${number}-main` | "electron-renderer" | `electron${number}-renderer` | `electron${number}.${number}-renderer` | "electron-preload" | `electron${number}-preload` | `electron${number}.${number}-preload` | ("node" | "web" | "webworker" | "es3" | "es5" | "es2015" | "es2016" | "es2017" | "es2018" | "es2019" | "es2020" | "es2021" | "es2022" | "browserslist" | "async-node" | `node${number}` | `async-node${number}` | `node${number}.${number}` | `async-node${number}.${number}` | "electron-main" | `electron${number}-main` | `electron${number}.${number}-main` | "electron-renderer" | `electron${number}-renderer` | `electron${number}.${number}-renderer` | "electron-preload" | `electron${number}-preload` | `electron${number}.${number}-preload`)[] | undefined;
|
|
518
547
|
mode?: "production" | "development" | "none" | undefined;
|
|
519
548
|
experiments?: {
|
|
520
549
|
lazyCompilation?: boolean | undefined;
|
|
@@ -526,7 +555,6 @@ export declare const config: {
|
|
|
526
555
|
futureDefaults?: boolean | undefined;
|
|
527
556
|
rspackFuture?: {
|
|
528
557
|
newTreeshaking?: boolean | undefined;
|
|
529
|
-
disableApplyEntryLazily?: boolean | undefined;
|
|
530
558
|
bundlerInfo?: {
|
|
531
559
|
version?: string | undefined;
|
|
532
560
|
force?: boolean | "version"[] | undefined;
|
|
@@ -537,7 +565,7 @@ export declare const config: {
|
|
|
537
565
|
context?: string | undefined;
|
|
538
566
|
dependencyType?: string | undefined;
|
|
539
567
|
request?: string | undefined;
|
|
540
|
-
}, args_1: (args_0: Error | undefined, args_1: string | boolean | string[] | Record<string, string | string[]> | undefined, args_2: "module" | "promise" | "script" | "commonjs" | "
|
|
568
|
+
}, args_1: (args_0: Error | undefined, args_1: string | boolean | string[] | Record<string, string | string[]> | undefined, args_2: "module" | "promise" | "script" | "commonjs" | "global" | "import" | "amd" | "commonjs2" | "var" | "assign" | "this" | "window" | "self" | "commonjs-module" | "commonjs-static" | "amd-require" | "umd" | "umd2" | "jsonp" | "system" | "node-commonjs" | undefined, ...args_3: unknown[]) => void, ...args_2: unknown[]) => unknown) | ((args_0: {
|
|
541
569
|
context?: string | undefined;
|
|
542
570
|
dependencyType?: string | undefined;
|
|
543
571
|
request?: string | undefined;
|
|
@@ -545,12 +573,12 @@ export declare const config: {
|
|
|
545
573
|
context?: string | undefined;
|
|
546
574
|
dependencyType?: string | undefined;
|
|
547
575
|
request?: string | undefined;
|
|
548
|
-
}, args_1: (args_0: Error | undefined, args_1: string | boolean | string[] | Record<string, string | string[]> | undefined, args_2: "module" | "promise" | "script" | "commonjs" | "
|
|
576
|
+
}, args_1: (args_0: Error | undefined, args_1: string | boolean | string[] | Record<string, string | string[]> | undefined, args_2: "module" | "promise" | "script" | "commonjs" | "global" | "import" | "amd" | "commonjs2" | "var" | "assign" | "this" | "window" | "self" | "commonjs-module" | "commonjs-static" | "amd-require" | "umd" | "umd2" | "jsonp" | "system" | "node-commonjs" | undefined, ...args_3: unknown[]) => void, ...args_2: unknown[]) => unknown) | ((args_0: {
|
|
549
577
|
context?: string | undefined;
|
|
550
578
|
dependencyType?: string | undefined;
|
|
551
579
|
request?: string | undefined;
|
|
552
580
|
}, ...args_1: unknown[]) => Promise<string | boolean | string[] | Record<string, string | string[]>>))[] | undefined;
|
|
553
|
-
externalsType?: "module" | "promise" | "script" | "commonjs" | "
|
|
581
|
+
externalsType?: "module" | "promise" | "script" | "commonjs" | "global" | "import" | "amd" | "commonjs2" | "var" | "assign" | "this" | "window" | "self" | "commonjs-module" | "commonjs-static" | "amd-require" | "umd" | "umd2" | "jsonp" | "system" | "node-commonjs" | undefined;
|
|
554
582
|
externalsPresets?: {
|
|
555
583
|
node?: boolean | undefined;
|
|
556
584
|
web?: boolean | undefined;
|
|
@@ -620,6 +648,7 @@ export declare const config: {
|
|
|
620
648
|
usedExports?: boolean | undefined;
|
|
621
649
|
providedExports?: boolean | undefined;
|
|
622
650
|
optimizationBailout?: boolean | undefined;
|
|
651
|
+
orphanModules?: boolean | undefined;
|
|
623
652
|
} | undefined;
|
|
624
653
|
snapshot?: {
|
|
625
654
|
module?: {
|
|
@@ -639,6 +668,7 @@ export declare const config: {
|
|
|
639
668
|
mergeDuplicateChunks?: boolean | undefined;
|
|
640
669
|
splitChunks?: false | {
|
|
641
670
|
chunks?: RegExp | "async" | "initial" | "all" | ((args_0: import("./Chunk").Chunk, ...args_1: unknown[]) => boolean) | undefined;
|
|
671
|
+
defaultSizeTypes?: string[] | undefined;
|
|
642
672
|
minChunks?: number | undefined;
|
|
643
673
|
name?: string | false | ((args_0: import("./Module").Module | undefined, ...args_1: unknown[]) => unknown) | undefined;
|
|
644
674
|
minSize?: number | undefined;
|
|
@@ -648,6 +678,7 @@ export declare const config: {
|
|
|
648
678
|
automaticNameDelimiter?: string | undefined;
|
|
649
679
|
cacheGroups?: Record<string, false | {
|
|
650
680
|
chunks?: RegExp | "async" | "initial" | "all" | ((args_0: import("./Chunk").Chunk, ...args_1: unknown[]) => boolean) | undefined;
|
|
681
|
+
defaultSizeTypes?: string[] | undefined;
|
|
651
682
|
minChunks?: number | undefined;
|
|
652
683
|
name?: string | false | ((args_0: import("./Module").Module | undefined, ...args_1: unknown[]) => unknown) | undefined;
|
|
653
684
|
minSize?: number | undefined;
|
|
@@ -703,6 +734,15 @@ export declare const config: {
|
|
|
703
734
|
maxSize?: number | undefined;
|
|
704
735
|
} | undefined;
|
|
705
736
|
} | undefined;
|
|
737
|
+
css?: {
|
|
738
|
+
namedExports?: boolean | undefined;
|
|
739
|
+
} | undefined;
|
|
740
|
+
"css/auto"?: {
|
|
741
|
+
namedExports?: boolean | undefined;
|
|
742
|
+
} | undefined;
|
|
743
|
+
"css/module"?: {
|
|
744
|
+
namedExports?: boolean | undefined;
|
|
745
|
+
} | undefined;
|
|
706
746
|
javascript?: {
|
|
707
747
|
dynamicImportMode?: "eager" | "lazy" | undefined;
|
|
708
748
|
dynamicImportPreload?: number | boolean | undefined;
|
|
@@ -735,6 +775,20 @@ export declare const config: {
|
|
|
735
775
|
filename?: string | undefined;
|
|
736
776
|
publicPath?: string | undefined;
|
|
737
777
|
} | undefined;
|
|
778
|
+
css?: {
|
|
779
|
+
exportsConvention?: "as-is" | "camel-case" | "camel-case-only" | "dashes" | "dashes-only" | undefined;
|
|
780
|
+
exportsOnly?: boolean | undefined;
|
|
781
|
+
} | undefined;
|
|
782
|
+
"css/auto"?: {
|
|
783
|
+
exportsConvention?: "as-is" | "camel-case" | "camel-case-only" | "dashes" | "dashes-only" | undefined;
|
|
784
|
+
exportsOnly?: boolean | undefined;
|
|
785
|
+
localIdentName?: string | undefined;
|
|
786
|
+
} | undefined;
|
|
787
|
+
"css/module"?: {
|
|
788
|
+
exportsConvention?: "as-is" | "camel-case" | "camel-case-only" | "dashes" | "dashes-only" | undefined;
|
|
789
|
+
exportsOnly?: boolean | undefined;
|
|
790
|
+
localIdentName?: string | undefined;
|
|
791
|
+
} | undefined;
|
|
738
792
|
} | undefined;
|
|
739
793
|
noParse?: string | RegExp | ((args_0: string, ...args_1: unknown[]) => boolean) | (string | RegExp | ((args_0: string, ...args_1: unknown[]) => boolean))[] | undefined;
|
|
740
794
|
} | undefined;
|
|
@@ -765,6 +819,7 @@ export { HotModuleReplacementPlugin } from "./builtin-plugin";
|
|
|
765
819
|
export { LoaderOptionsPlugin } from "./lib/LoaderOptionsPlugin";
|
|
766
820
|
export { LoaderTargetPlugin } from "./lib/LoaderTargetPlugin";
|
|
767
821
|
export { EnvironmentPlugin } from "./lib/EnvironmentPlugin";
|
|
822
|
+
export { NormalModuleReplacementPlugin } from "./lib/NormalModuleReplacementPlugin";
|
|
768
823
|
import NodeTemplatePlugin from "./node/NodeTemplatePlugin";
|
|
769
824
|
export declare const node: {
|
|
770
825
|
NodeTargetPlugin: {
|
|
@@ -874,3 +929,4 @@ export { EvalSourceMapDevToolPlugin } from "./builtin-plugin";
|
|
|
874
929
|
export type { SourceMapDevToolPluginOptions } from "./builtin-plugin";
|
|
875
930
|
export { EvalDevToolModulePlugin } from "./builtin-plugin";
|
|
876
931
|
export type { EvalDevToolModulePluginOptions } from "./builtin-plugin";
|
|
932
|
+
export { CssExtractRspackPlugin } from "./builtin-plugin";
|
package/dist/exports.js
CHANGED
|
@@ -3,7 +3,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.EvalDevToolModulePlugin = exports.EvalSourceMapDevToolPlugin = exports.SourceMapDevToolPlugin = exports.CopyRspackPlugin = exports.SwcCssMinimizerRspackPlugin = exports.SwcJsMinimizerRspackPlugin = exports.HtmlRspackPlugin = exports.sharing = exports.container = exports.optimize = exports.webworker = exports.javascript = exports.wasm = exports.library = exports.electron = exports.node = exports.EnvironmentPlugin = exports.LoaderTargetPlugin = exports.LoaderOptionsPlugin = exports.HotModuleReplacementPlugin = exports.ExternalsPlugin = exports.EntryPlugin = exports.ProgressPlugin = exports.DefinePlugin = exports.ProvidePlugin = exports.BannerPlugin = exports.EntryOptionPlugin = exports.experimental_cleanupGlobalTrace = exports.experimental_registerGlobalTrace = exports.util = exports.config = exports.sources = exports.WebpackError = exports.Template = exports.ModuleFilenameHelpers = exports.NormalModule = exports.Stats = exports.RuntimeGlobals = exports.WebpackOptionsApply = exports.RspackOptionsApply = exports.MultiCompiler = exports.Compilation = exports.Compiler = exports.rspackVersion = exports.version = void 0;
|
|
6
|
+
exports.CssExtractRspackPlugin = exports.EvalDevToolModulePlugin = exports.EvalSourceMapDevToolPlugin = exports.SourceMapDevToolPlugin = exports.CopyRspackPlugin = exports.SwcCssMinimizerRspackPlugin = exports.SwcJsMinimizerRspackPlugin = exports.HtmlRspackPlugin = exports.sharing = exports.container = exports.optimize = exports.webworker = exports.javascript = exports.wasm = exports.library = exports.electron = exports.node = exports.NormalModuleReplacementPlugin = exports.EnvironmentPlugin = exports.LoaderTargetPlugin = exports.LoaderOptionsPlugin = exports.HotModuleReplacementPlugin = exports.ExternalsPlugin = exports.EntryPlugin = exports.ProgressPlugin = exports.DefinePlugin = exports.ProvidePlugin = exports.BannerPlugin = exports.EntryOptionPlugin = exports.experimental_cleanupGlobalTrace = exports.experimental_registerGlobalTrace = exports.util = exports.config = exports.sources = exports.WebpackError = exports.Template = exports.ModuleFilenameHelpers = exports.NormalModule = exports.MultiStats = exports.Stats = exports.RuntimeGlobals = exports.WebpackOptionsApply = exports.RspackOptionsApply = exports.MultiCompiler = exports.Compilation = exports.Compiler = exports.rspackVersion = exports.version = void 0;
|
|
7
7
|
const { version: rspackVersion, webpackVersion } = require("../package.json");
|
|
8
8
|
exports.rspackVersion = rspackVersion;
|
|
9
9
|
exports.version = webpackVersion;
|
|
@@ -20,6 +20,8 @@ var RuntimeGlobals_1 = require("./RuntimeGlobals");
|
|
|
20
20
|
Object.defineProperty(exports, "RuntimeGlobals", { enumerable: true, get: function () { return RuntimeGlobals_1.RuntimeGlobals; } });
|
|
21
21
|
var Stats_1 = require("./Stats");
|
|
22
22
|
Object.defineProperty(exports, "Stats", { enumerable: true, get: function () { return Stats_1.Stats; } });
|
|
23
|
+
var MultiStats_1 = require("./MultiStats");
|
|
24
|
+
Object.defineProperty(exports, "MultiStats", { enumerable: true, get: function () { return MultiStats_1.MultiStats; } });
|
|
23
25
|
var NormalModule_1 = require("./NormalModule");
|
|
24
26
|
Object.defineProperty(exports, "NormalModule", { enumerable: true, get: function () { return NormalModule_1.NormalModule; } });
|
|
25
27
|
var ModuleFilenameHelpers_1 = require("./lib/ModuleFilenameHelpers");
|
|
@@ -65,6 +67,8 @@ var LoaderTargetPlugin_1 = require("./lib/LoaderTargetPlugin");
|
|
|
65
67
|
Object.defineProperty(exports, "LoaderTargetPlugin", { enumerable: true, get: function () { return LoaderTargetPlugin_1.LoaderTargetPlugin; } });
|
|
66
68
|
var EnvironmentPlugin_1 = require("./lib/EnvironmentPlugin");
|
|
67
69
|
Object.defineProperty(exports, "EnvironmentPlugin", { enumerable: true, get: function () { return EnvironmentPlugin_1.EnvironmentPlugin; } });
|
|
70
|
+
var NormalModuleReplacementPlugin_1 = require("./lib/NormalModuleReplacementPlugin");
|
|
71
|
+
Object.defineProperty(exports, "NormalModuleReplacementPlugin", { enumerable: true, get: function () { return NormalModuleReplacementPlugin_1.NormalModuleReplacementPlugin; } });
|
|
68
72
|
const NodeTemplatePlugin_1 = __importDefault(require("./node/NodeTemplatePlugin"));
|
|
69
73
|
const builtin_plugin_8 = require("./builtin-plugin");
|
|
70
74
|
exports.node = { NodeTargetPlugin: builtin_plugin_8.NodeTargetPlugin, NodeTemplatePlugin: NodeTemplatePlugin_1.default };
|
|
@@ -113,3 +117,5 @@ var builtin_plugin_20 = require("./builtin-plugin");
|
|
|
113
117
|
Object.defineProperty(exports, "EvalSourceMapDevToolPlugin", { enumerable: true, get: function () { return builtin_plugin_20.EvalSourceMapDevToolPlugin; } });
|
|
114
118
|
var builtin_plugin_21 = require("./builtin-plugin");
|
|
115
119
|
Object.defineProperty(exports, "EvalDevToolModulePlugin", { enumerable: true, get: function () { return builtin_plugin_21.EvalDevToolModulePlugin; } });
|
|
120
|
+
var builtin_plugin_22 = require("./builtin-plugin");
|
|
121
|
+
Object.defineProperty(exports, "CssExtractRspackPlugin", { enumerable: true, get: function () { return builtin_plugin_22.CssExtractRspackPlugin; } });
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Based on [webpack/lib/NormalModuleReplacementPlugin.js]{@link https://github.com/webpack/webpack/blob/29cc4ead7eb6aafc3a5f6d0b10ce41d33d1ad874/lib/NormalModuleReplacementPlugin.js}
|
|
3
|
+
* Licensed with [MIT License]{@link http://www.opensource.org/licenses/mit-license.php}
|
|
4
|
+
* Original Author Tobias Koppers @sokra
|
|
5
|
+
*/
|
|
6
|
+
import { Compiler } from "../Compiler";
|
|
7
|
+
import { ResolveData } from "../Module";
|
|
8
|
+
type ModuleReplacer = (createData: ResolveData) => void;
|
|
9
|
+
export declare class NormalModuleReplacementPlugin {
|
|
10
|
+
readonly resourceRegExp: RegExp;
|
|
11
|
+
readonly newResource: string | ModuleReplacer;
|
|
12
|
+
/**
|
|
13
|
+
* @param {RegExp} resourceRegExp the resource matcher
|
|
14
|
+
* @param {string|ModuleReplacer} newResource the resource replacement
|
|
15
|
+
*/
|
|
16
|
+
constructor(resourceRegExp: RegExp, newResource: string | ModuleReplacer);
|
|
17
|
+
apply(compiler: Compiler): void;
|
|
18
|
+
}
|
|
19
|
+
export {};
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Based on [webpack/lib/NormalModuleReplacementPlugin.js]{@link https://github.com/webpack/webpack/blob/29cc4ead7eb6aafc3a5f6d0b10ce41d33d1ad874/lib/NormalModuleReplacementPlugin.js}
|
|
4
|
+
* Licensed with [MIT License]{@link http://www.opensource.org/licenses/mit-license.php}
|
|
5
|
+
* Original Author Tobias Koppers @sokra
|
|
6
|
+
*/
|
|
7
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
8
|
+
if (k2 === undefined) k2 = k;
|
|
9
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
10
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
11
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
12
|
+
}
|
|
13
|
+
Object.defineProperty(o, k2, desc);
|
|
14
|
+
}) : (function(o, m, k, k2) {
|
|
15
|
+
if (k2 === undefined) k2 = k;
|
|
16
|
+
o[k2] = m[k];
|
|
17
|
+
}));
|
|
18
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
19
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
20
|
+
}) : function(o, v) {
|
|
21
|
+
o["default"] = v;
|
|
22
|
+
});
|
|
23
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
24
|
+
if (mod && mod.__esModule) return mod;
|
|
25
|
+
var result = {};
|
|
26
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
27
|
+
__setModuleDefault(result, mod);
|
|
28
|
+
return result;
|
|
29
|
+
};
|
|
30
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
31
|
+
exports.NormalModuleReplacementPlugin = void 0;
|
|
32
|
+
const NodePath = __importStar(require("node:path"));
|
|
33
|
+
class NormalModuleReplacementPlugin {
|
|
34
|
+
/**
|
|
35
|
+
* @param {RegExp} resourceRegExp the resource matcher
|
|
36
|
+
* @param {string|ModuleReplacer} newResource the resource replacement
|
|
37
|
+
*/
|
|
38
|
+
constructor(resourceRegExp, newResource) {
|
|
39
|
+
this.resourceRegExp = resourceRegExp;
|
|
40
|
+
this.newResource = newResource;
|
|
41
|
+
}
|
|
42
|
+
apply(compiler) {
|
|
43
|
+
const { resourceRegExp, newResource } = this;
|
|
44
|
+
compiler.hooks.normalModuleFactory.tap("NormalModuleReplacementPlugin", nmf => {
|
|
45
|
+
nmf.hooks.beforeResolve.tap("NormalModuleReplacementPlugin", result => {
|
|
46
|
+
if (resourceRegExp.test(result.request)) {
|
|
47
|
+
if (typeof newResource === "function") {
|
|
48
|
+
newResource(result);
|
|
49
|
+
}
|
|
50
|
+
else {
|
|
51
|
+
result.request = newResource;
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
});
|
|
55
|
+
nmf.hooks.afterResolve.tap("NormalModuleReplacementPlugin", result => {
|
|
56
|
+
const createData = result.createData || {};
|
|
57
|
+
if (resourceRegExp.test(createData.resource || "")) {
|
|
58
|
+
if (typeof newResource === "function") {
|
|
59
|
+
newResource(result);
|
|
60
|
+
}
|
|
61
|
+
else {
|
|
62
|
+
if (NodePath.posix.isAbsolute(newResource) ||
|
|
63
|
+
NodePath.win32.isAbsolute(newResource)) {
|
|
64
|
+
createData.resource = newResource;
|
|
65
|
+
}
|
|
66
|
+
else {
|
|
67
|
+
createData.resource = NodePath.join(NodePath.dirname(createData.resource || ""), newResource);
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
});
|
|
72
|
+
});
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
exports.NormalModuleReplacementPlugin = NormalModuleReplacementPlugin;
|
|
@@ -112,4 +112,29 @@ export declare class AsyncSeriesBailHook<T, R, AdditionalOptions = UnsetAddition
|
|
|
112
112
|
tapAsync(options: Options<AdditionalOptions>, fn: FnWithCallback<T, void>): void;
|
|
113
113
|
tapPromise(options: Options<AdditionalOptions>, fn: Fn<T, void>): void;
|
|
114
114
|
}
|
|
115
|
+
export type HookMapKey = any;
|
|
116
|
+
export type HookFactory<H> = (key: HookMapKey, hook?: H) => H;
|
|
117
|
+
export interface HookMapInterceptor<H> {
|
|
118
|
+
factory?: HookFactory<H>;
|
|
119
|
+
}
|
|
120
|
+
export declare class HookMap<H extends Hook<any, any, any>> {
|
|
121
|
+
_map: Map<HookMapKey, H>;
|
|
122
|
+
_factory: HookFactory<H>;
|
|
123
|
+
name?: string;
|
|
124
|
+
_interceptors: HookMapInterceptor<H>[];
|
|
125
|
+
constructor(factory: HookFactory<H>, name?: string);
|
|
126
|
+
get(key: HookMapKey): H | undefined;
|
|
127
|
+
for(key: HookMapKey): H;
|
|
128
|
+
intercept(interceptor: HookMapInterceptor<H>): void;
|
|
129
|
+
isUsed(): boolean;
|
|
130
|
+
queryStageRange(stageRange: StageRange): QueriedHookMap<H>;
|
|
131
|
+
}
|
|
132
|
+
export declare class QueriedHookMap<H extends Hook<any, any, any>> {
|
|
133
|
+
stageRange: StageRange;
|
|
134
|
+
hookMap: HookMap<H>;
|
|
135
|
+
constructor(stageRange: StageRange, hookMap: HookMap<H>);
|
|
136
|
+
get(key: HookMapKey): QueriedHook<any, any, any> | undefined;
|
|
137
|
+
for(key: HookMapKey): QueriedHook<any, any, any>;
|
|
138
|
+
isUsed(): boolean;
|
|
139
|
+
}
|
|
115
140
|
export {};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.AsyncSeriesBailHook = exports.AsyncSeriesHook = exports.AsyncParallelHook = exports.SyncBailHook = exports.SyncHook = exports.QueriedHook = exports.safeStage = exports.maxStage = exports.minStage = exports.Hook = void 0;
|
|
3
|
+
exports.QueriedHookMap = exports.HookMap = 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;
|
|
@@ -578,3 +578,72 @@ class AsyncSeriesBailHook extends Hook {
|
|
|
578
578
|
}
|
|
579
579
|
}
|
|
580
580
|
exports.AsyncSeriesBailHook = AsyncSeriesBailHook;
|
|
581
|
+
const defaultFactory = (key, hook) => hook;
|
|
582
|
+
class HookMap {
|
|
583
|
+
constructor(factory, name) {
|
|
584
|
+
this._map = new Map();
|
|
585
|
+
this.name = name;
|
|
586
|
+
this._factory = factory;
|
|
587
|
+
this._interceptors = [];
|
|
588
|
+
}
|
|
589
|
+
get(key) {
|
|
590
|
+
return this._map.get(key);
|
|
591
|
+
}
|
|
592
|
+
for(key) {
|
|
593
|
+
const hook = this.get(key);
|
|
594
|
+
if (hook !== undefined) {
|
|
595
|
+
return hook;
|
|
596
|
+
}
|
|
597
|
+
let newHook = this._factory(key);
|
|
598
|
+
const interceptors = this._interceptors;
|
|
599
|
+
for (let i = 0; i < interceptors.length; i++) {
|
|
600
|
+
const factory = interceptors[i].factory;
|
|
601
|
+
if (factory) {
|
|
602
|
+
newHook = factory(key, newHook);
|
|
603
|
+
}
|
|
604
|
+
}
|
|
605
|
+
this._map.set(key, newHook);
|
|
606
|
+
return newHook;
|
|
607
|
+
}
|
|
608
|
+
intercept(interceptor) {
|
|
609
|
+
this._interceptors.push(Object.assign({
|
|
610
|
+
factory: defaultFactory
|
|
611
|
+
}, interceptor));
|
|
612
|
+
}
|
|
613
|
+
isUsed() {
|
|
614
|
+
for (const key of this._map.keys()) {
|
|
615
|
+
const hook = this.get(key);
|
|
616
|
+
if (hook === null || hook === void 0 ? void 0 : hook.isUsed()) {
|
|
617
|
+
return true;
|
|
618
|
+
}
|
|
619
|
+
}
|
|
620
|
+
return false;
|
|
621
|
+
}
|
|
622
|
+
queryStageRange(stageRange) {
|
|
623
|
+
return new QueriedHookMap(stageRange, this);
|
|
624
|
+
}
|
|
625
|
+
}
|
|
626
|
+
exports.HookMap = HookMap;
|
|
627
|
+
class QueriedHookMap {
|
|
628
|
+
constructor(stageRange, hookMap) {
|
|
629
|
+
this.stageRange = stageRange;
|
|
630
|
+
this.hookMap = hookMap;
|
|
631
|
+
}
|
|
632
|
+
get(key) {
|
|
633
|
+
var _a;
|
|
634
|
+
return (_a = this.hookMap.get(key)) === null || _a === void 0 ? void 0 : _a.queryStageRange(this.stageRange);
|
|
635
|
+
}
|
|
636
|
+
for(key) {
|
|
637
|
+
return this.hookMap.for(key).queryStageRange(this.stageRange);
|
|
638
|
+
}
|
|
639
|
+
isUsed() {
|
|
640
|
+
var _a;
|
|
641
|
+
for (const key in this.hookMap._map.keys()) {
|
|
642
|
+
if ((_a = this.get(key)) === null || _a === void 0 ? void 0 : _a.isUsed()) {
|
|
643
|
+
return true;
|
|
644
|
+
}
|
|
645
|
+
}
|
|
646
|
+
return false;
|
|
647
|
+
}
|
|
648
|
+
}
|
|
649
|
+
exports.QueriedHookMap = QueriedHookMap;
|