@rspack/core 0.5.9-canary-4297cec-20240402080759 → 0.5.9-canary-5be4c34-20240403005129
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 -0
- package/dist/Compilation.js +2 -1
- package/dist/Compiler.d.ts +3 -8
- package/dist/Compiler.js +31 -34
- package/dist/Stats.js +2 -2
- package/dist/builtin-plugin/{RSCClientEntryPlugin.d.ts → CssModulesPlugin.d.ts} +1 -1
- package/dist/builtin-plugin/CssModulesPlugin.js +6 -0
- package/dist/builtin-plugin/EntryPlugin.d.ts +1 -0
- package/dist/builtin-plugin/EntryPlugin.js +2 -1
- package/dist/builtin-plugin/ExternalsPlugin.d.ts +2 -2
- package/dist/builtin-plugin/HtmlRspackPlugin.d.ts +3 -3
- package/dist/builtin-plugin/index.d.ts +2 -8
- package/dist/builtin-plugin/index.js +1 -17
- package/dist/config/adapter.js +59 -7
- package/dist/config/defaults.js +57 -28
- package/dist/config/normalization.d.ts +1 -0
- package/dist/config/normalization.js +6 -1
- package/dist/config/zod.d.ts +724 -76
- package/dist/config/zod.js +43 -2
- package/dist/container/ContainerReferencePlugin.d.ts +1 -1
- package/dist/exports.d.ts +72 -24
- package/dist/exports.js +1 -5
- package/dist/lib/EntryOptionPlugin.js +1 -1
- package/dist/rspackOptionsApply.js +4 -1
- package/dist/util/comparators.d.ts +1 -1
- package/package.json +4 -4
- package/dist/builtin-plugin/RSCClientEntryPlugin.js +0 -6
- package/dist/builtin-plugin/RSCClientReferenceManifestRspackPlugin.d.ts +0 -10
- package/dist/builtin-plugin/RSCClientReferenceManifestRspackPlugin.js +0 -6
package/dist/Compilation.d.ts
CHANGED
|
@@ -90,6 +90,7 @@ export declare class Compilation {
|
|
|
90
90
|
ExecuteModuleContext
|
|
91
91
|
]>;
|
|
92
92
|
runtimeModule: liteTapable.SyncHook<[JsRuntimeModule, Chunk], void>;
|
|
93
|
+
afterSeal: liteTapable.AsyncSeriesHook<[], void>;
|
|
93
94
|
};
|
|
94
95
|
options: RspackOptionsNormalized;
|
|
95
96
|
outputOptions: OutputNormalized;
|
package/dist/Compilation.js
CHANGED
|
@@ -154,7 +154,8 @@ BREAKING CHANGE: Asset processing hooks in Compilation has been merged into a si
|
|
|
154
154
|
statsPrinter: new tapable.SyncHook(["statsPrinter", "options"]),
|
|
155
155
|
buildModule: new liteTapable.SyncHook(["module"]),
|
|
156
156
|
executeModule: new liteTapable.SyncHook(["options", "context"]),
|
|
157
|
-
runtimeModule: new liteTapable.SyncHook(["module", "chunk"])
|
|
157
|
+
runtimeModule: new liteTapable.SyncHook(["module", "chunk"]),
|
|
158
|
+
afterSeal: new liteTapable.AsyncSeriesHook([])
|
|
158
159
|
};
|
|
159
160
|
this.compiler = compiler;
|
|
160
161
|
this.resolverFactory = compiler.resolverFactory;
|
package/dist/Compiler.d.ts
CHANGED
|
@@ -42,7 +42,6 @@ declare class Compiler {
|
|
|
42
42
|
};
|
|
43
43
|
compilation?: Compilation;
|
|
44
44
|
compilationParams?: CompilationParams;
|
|
45
|
-
first: boolean;
|
|
46
45
|
builtinPlugins: binding.BuiltinPlugin[];
|
|
47
46
|
root: Compiler;
|
|
48
47
|
running: boolean;
|
|
@@ -110,14 +109,10 @@ declare class Compiler {
|
|
|
110
109
|
getInfrastructureLogger(name: string | Function): Logger;
|
|
111
110
|
run(callback: Callback<Error, Stats>): void;
|
|
112
111
|
/**
|
|
113
|
-
*
|
|
112
|
+
* * Note: This is not a webpack public API, maybe removed in future.
|
|
113
|
+
* @internal
|
|
114
114
|
*/
|
|
115
|
-
|
|
116
|
-
/**
|
|
117
|
-
* Safety: This method is only valid to call if the previous rebuild task is finished, or there will be data races.
|
|
118
|
-
* @deprecated This is a low-level incremental rebuild API, which shouldn't be used intentionally. Use `compiler.build` instead.
|
|
119
|
-
*/
|
|
120
|
-
rebuild(modifiedFiles?: ReadonlySet<string>, removedFiles?: ReadonlySet<string>, callback?: (error: Error | null) => void): void;
|
|
115
|
+
__internal__rebuild(modifiedFiles?: ReadonlySet<string>, removedFiles?: ReadonlySet<string>, callback?: (error: Error | null) => void): void;
|
|
121
116
|
compile(callback: Callback<Error, Compilation>): void;
|
|
122
117
|
watch(watchOptions: WatchOptions, handler: Callback<Error, Stats>): Watching;
|
|
123
118
|
purgeInputFileSystem(): void;
|
package/dist/Compiler.js
CHANGED
|
@@ -36,7 +36,7 @@ var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (
|
|
|
36
36
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
37
37
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
38
38
|
};
|
|
39
|
-
var _Compiler_instances, _Compiler_instance, _Compiler_disabledHooks, _Compiler_nonSkippableRegisters, _Compiler_registers, _Compiler_moduleExecutionResultsMap, _Compiler_getInstance, _Compiler_updateNonSkippableRegisters, _Compiler_decorateJsTaps, _Compiler_createHookRegisterTaps, _Compiler_createHookMapRegisterTaps, _Compiler_createCompilation, _Compiler_resetThisCompilation, _Compiler_newCompilationParams;
|
|
39
|
+
var _Compiler_instances, _Compiler_instance, _Compiler_initial, _Compiler_disabledHooks, _Compiler_nonSkippableRegisters, _Compiler_registers, _Compiler_moduleExecutionResultsMap, _Compiler_getInstance, _Compiler_updateNonSkippableRegisters, _Compiler_decorateJsTaps, _Compiler_createHookRegisterTaps, _Compiler_createHookMapRegisterTaps, _Compiler_build, _Compiler_createCompilation, _Compiler_resetThisCompilation, _Compiler_newCompilationParams;
|
|
40
40
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
41
41
|
exports.Compiler = void 0;
|
|
42
42
|
/**
|
|
@@ -84,7 +84,7 @@ class Compiler {
|
|
|
84
84
|
_Compiler_instance.set(this, void 0);
|
|
85
85
|
this.webpack = index_1.rspack;
|
|
86
86
|
// TODO: remove this after remove rebuild on the rust side.
|
|
87
|
-
this
|
|
87
|
+
_Compiler_initial.set(this, true);
|
|
88
88
|
_Compiler_disabledHooks.set(this, void 0);
|
|
89
89
|
_Compiler_nonSkippableRegisters.set(this, void 0);
|
|
90
90
|
_Compiler_registers.set(this, void 0);
|
|
@@ -386,36 +386,10 @@ class Compiler {
|
|
|
386
386
|
}
|
|
387
387
|
}
|
|
388
388
|
/**
|
|
389
|
-
*
|
|
389
|
+
* * Note: This is not a webpack public API, maybe removed in future.
|
|
390
|
+
* @internal
|
|
390
391
|
*/
|
|
391
|
-
|
|
392
|
-
__classPrivateFieldGet(this, _Compiler_instances, "m", _Compiler_getInstance).call(this, (error, instance) => {
|
|
393
|
-
if (error) {
|
|
394
|
-
return callback === null || callback === void 0 ? void 0 : callback(error);
|
|
395
|
-
}
|
|
396
|
-
if (!this.first) {
|
|
397
|
-
instance.rebuild(Array.from(this.modifiedFiles || []), Array.from(this.removedFiles || []), error => {
|
|
398
|
-
if (error) {
|
|
399
|
-
return callback === null || callback === void 0 ? void 0 : callback(error);
|
|
400
|
-
}
|
|
401
|
-
callback === null || callback === void 0 ? void 0 : callback(null);
|
|
402
|
-
});
|
|
403
|
-
return;
|
|
404
|
-
}
|
|
405
|
-
this.first = false;
|
|
406
|
-
instance.build(error => {
|
|
407
|
-
if (error) {
|
|
408
|
-
return callback === null || callback === void 0 ? void 0 : callback(error);
|
|
409
|
-
}
|
|
410
|
-
callback === null || callback === void 0 ? void 0 : callback(null);
|
|
411
|
-
});
|
|
412
|
-
});
|
|
413
|
-
}
|
|
414
|
-
/**
|
|
415
|
-
* Safety: This method is only valid to call if the previous rebuild task is finished, or there will be data races.
|
|
416
|
-
* @deprecated This is a low-level incremental rebuild API, which shouldn't be used intentionally. Use `compiler.build` instead.
|
|
417
|
-
*/
|
|
418
|
-
rebuild(modifiedFiles, removedFiles, callback) {
|
|
392
|
+
__internal__rebuild(modifiedFiles, removedFiles, callback) {
|
|
419
393
|
__classPrivateFieldGet(this, _Compiler_instances, "m", _Compiler_getInstance).call(this, (error, instance) => {
|
|
420
394
|
if (error) {
|
|
421
395
|
return callback === null || callback === void 0 ? void 0 : callback(error);
|
|
@@ -437,7 +411,7 @@ class Compiler {
|
|
|
437
411
|
}
|
|
438
412
|
this.hooks.compile.call(params);
|
|
439
413
|
__classPrivateFieldGet(this, _Compiler_instances, "m", _Compiler_resetThisCompilation).call(this);
|
|
440
|
-
this.
|
|
414
|
+
__classPrivateFieldGet(this, _Compiler_instances, "m", _Compiler_build).call(this, err => {
|
|
441
415
|
if (err) {
|
|
442
416
|
return callback(err);
|
|
443
417
|
}
|
|
@@ -470,7 +444,7 @@ class Compiler {
|
|
|
470
444
|
}
|
|
471
445
|
close(callback) {
|
|
472
446
|
if (this.watching) {
|
|
473
|
-
// When there is still an active watching, close this
|
|
447
|
+
// When there is still an active watching, close this #initial
|
|
474
448
|
this.watching.close(() => {
|
|
475
449
|
this.close(callback);
|
|
476
450
|
});
|
|
@@ -497,7 +471,7 @@ class Compiler {
|
|
|
497
471
|
}
|
|
498
472
|
}
|
|
499
473
|
exports.Compiler = Compiler;
|
|
500
|
-
_Compiler_instance = new WeakMap(), _Compiler_disabledHooks = new WeakMap(), _Compiler_nonSkippableRegisters = new WeakMap(), _Compiler_registers = new WeakMap(), _Compiler_moduleExecutionResultsMap = new WeakMap(), _Compiler_instances = new WeakSet(), _Compiler_getInstance = function _Compiler_getInstance(callback) {
|
|
474
|
+
_Compiler_instance = new WeakMap(), _Compiler_initial = new WeakMap(), _Compiler_disabledHooks = new WeakMap(), _Compiler_nonSkippableRegisters = new WeakMap(), _Compiler_registers = new WeakMap(), _Compiler_moduleExecutionResultsMap = new WeakMap(), _Compiler_instances = new WeakSet(), _Compiler_getInstance = function _Compiler_getInstance(callback) {
|
|
501
475
|
const error = (0, bindingVersionCheck_1.checkVersion)();
|
|
502
476
|
if (error) {
|
|
503
477
|
return callback(error);
|
|
@@ -599,6 +573,7 @@ _Compiler_instance = new WeakMap(), _Compiler_disabledHooks = new WeakMap(), _Co
|
|
|
599
573
|
registerCompilationChunkAssetTaps: __classPrivateFieldGet(this, _Compiler_instances, "m", _Compiler_createHookRegisterTaps).call(this, binding.RegisterJsTapKind.CompilationChunkAsset, () => this.compilation.hooks.chunkAsset, queried => ({ chunk, filename }) => queried.call(Chunk_1.Chunk.__from_binding(chunk, this.compilation), filename)),
|
|
600
574
|
registerCompilationProcessAssetsTaps: __classPrivateFieldGet(this, _Compiler_instances, "m", _Compiler_createHookRegisterTaps).call(this, binding.RegisterJsTapKind.CompilationProcessAssets, () => this.compilation.hooks.processAssets, queried => async () => await queried.promise(this.compilation.assets)),
|
|
601
575
|
registerCompilationAfterProcessAssetsTaps: __classPrivateFieldGet(this, _Compiler_instances, "m", _Compiler_createHookRegisterTaps).call(this, binding.RegisterJsTapKind.CompilationAfterProcessAssets, () => this.compilation.hooks.afterProcessAssets, queried => () => queried.call(this.compilation.assets)),
|
|
576
|
+
registerCompilationAfterSealTaps: __classPrivateFieldGet(this, _Compiler_instances, "m", _Compiler_createHookRegisterTaps).call(this, binding.RegisterJsTapKind.CompilationAfterSeal, () => this.compilation.hooks.afterSeal, queried => async () => await queried.promise()),
|
|
602
577
|
registerNormalModuleFactoryBeforeResolveTaps: __classPrivateFieldGet(this, _Compiler_instances, "m", _Compiler_createHookRegisterTaps).call(this, binding.RegisterJsTapKind.NormalModuleFactoryBeforeResolve, () => this.compilationParams.normalModuleFactory.hooks.beforeResolve, queried => async (resolveData) => {
|
|
603
578
|
const normalizedResolveData = {
|
|
604
579
|
request: resolveData.request,
|
|
@@ -751,6 +726,28 @@ _Compiler_instance = new WeakMap(), _Compiler_disabledHooks = new WeakMap(), _Co
|
|
|
751
726
|
getTaps.registerKind = registerKind;
|
|
752
727
|
getTaps.getHookMap = getHookMap;
|
|
753
728
|
return getTaps;
|
|
729
|
+
}, _Compiler_build = function _Compiler_build(callback) {
|
|
730
|
+
__classPrivateFieldGet(this, _Compiler_instances, "m", _Compiler_getInstance).call(this, (error, instance) => {
|
|
731
|
+
if (error) {
|
|
732
|
+
return callback === null || callback === void 0 ? void 0 : callback(error);
|
|
733
|
+
}
|
|
734
|
+
if (!__classPrivateFieldGet(this, _Compiler_initial, "f")) {
|
|
735
|
+
instance.rebuild(Array.from(this.modifiedFiles || []), Array.from(this.removedFiles || []), error => {
|
|
736
|
+
if (error) {
|
|
737
|
+
return callback === null || callback === void 0 ? void 0 : callback(error);
|
|
738
|
+
}
|
|
739
|
+
callback === null || callback === void 0 ? void 0 : callback(null);
|
|
740
|
+
});
|
|
741
|
+
return;
|
|
742
|
+
}
|
|
743
|
+
__classPrivateFieldSet(this, _Compiler_initial, false, "f");
|
|
744
|
+
instance.build(error => {
|
|
745
|
+
if (error) {
|
|
746
|
+
return callback === null || callback === void 0 ? void 0 : callback(error);
|
|
747
|
+
}
|
|
748
|
+
callback === null || callback === void 0 ? void 0 : callback(null);
|
|
749
|
+
});
|
|
750
|
+
});
|
|
754
751
|
}, _Compiler_createCompilation = function _Compiler_createCompilation(native) {
|
|
755
752
|
const compilation = new Compilation_1.Compilation(this, native);
|
|
756
753
|
compilation.name = this.name;
|
package/dist/Stats.js
CHANGED
|
@@ -103,8 +103,8 @@ function normalizeStatsPreset(options) {
|
|
|
103
103
|
}
|
|
104
104
|
exports.normalizeStatsPreset = normalizeStatsPreset;
|
|
105
105
|
function presetToOptions(name) {
|
|
106
|
-
const
|
|
107
|
-
switch (
|
|
106
|
+
const preset = (typeof name === "string" && name.toLowerCase()) || name;
|
|
107
|
+
switch (preset) {
|
|
108
108
|
case "none":
|
|
109
109
|
return {
|
|
110
110
|
all: false
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.CssModulesPlugin = void 0;
|
|
4
|
+
const binding_1 = require("@rspack/binding");
|
|
5
|
+
const base_1 = require("./base");
|
|
6
|
+
exports.CssModulesPlugin = (0, base_1.create)(binding_1.BuiltinPluginName.CssModulesPlugin, () => { }, "compilation");
|
|
@@ -9,6 +9,7 @@ export type EntryOptions = {
|
|
|
9
9
|
baseUri?: string;
|
|
10
10
|
filename?: FilenameTemplate;
|
|
11
11
|
library?: LibraryOptions;
|
|
12
|
+
dependOn?: string[];
|
|
12
13
|
};
|
|
13
14
|
export declare const EntryPlugin: {
|
|
14
15
|
new (context: string, entry: string, options?: string | EntryOptions | undefined): {
|
|
@@ -26,6 +26,7 @@ function getRawEntryOptions(entry) {
|
|
|
26
26
|
: undefined,
|
|
27
27
|
asyncChunks: entry.asyncChunks,
|
|
28
28
|
filename: entry.filename,
|
|
29
|
-
library: entry.library && (0, config_1.getRawLibrary)(entry.library)
|
|
29
|
+
library: entry.library && (0, config_1.getRawLibrary)(entry.library),
|
|
30
|
+
dependOn: entry.dependOn
|
|
30
31
|
};
|
|
31
32
|
}
|
|
@@ -4,7 +4,7 @@ export declare const ExternalsPlugin: {
|
|
|
4
4
|
context?: string | undefined;
|
|
5
5
|
dependencyType?: string | undefined;
|
|
6
6
|
request?: string | undefined;
|
|
7
|
-
}, args_1: (args_0: Error | undefined, args_1: string | boolean | string[] | Record<string, string | string[]> | undefined, args_2: "promise" | "
|
|
7
|
+
}, args_1: (args_0: Error | undefined, args_1: string | boolean | string[] | Record<string, string | string[]> | undefined, args_2: "module" | "promise" | "script" | "commonjs" | "jsonp" | "import" | "amd" | "commonjs2" | "var" | "assign" | "this" | "window" | "self" | "global" | "commonjs-module" | "commonjs-static" | "amd-require" | "umd" | "umd2" | "system" | "node-commonjs" | undefined, ...args_3: unknown[]) => void, ...args_2: unknown[]) => unknown) | ((args_0: {
|
|
8
8
|
context?: string | undefined;
|
|
9
9
|
dependencyType?: string | undefined;
|
|
10
10
|
request?: string | undefined;
|
|
@@ -12,7 +12,7 @@ export declare const ExternalsPlugin: {
|
|
|
12
12
|
context?: string | undefined;
|
|
13
13
|
dependencyType?: string | undefined;
|
|
14
14
|
request?: string | undefined;
|
|
15
|
-
}, args_1: (args_0: Error | undefined, args_1: string | boolean | string[] | Record<string, string | string[]> | undefined, args_2: "promise" | "
|
|
15
|
+
}, args_1: (args_0: Error | undefined, args_1: string | boolean | string[] | Record<string, string | string[]> | undefined, args_2: "module" | "promise" | "script" | "commonjs" | "jsonp" | "import" | "amd" | "commonjs2" | "var" | "assign" | "this" | "window" | "self" | "global" | "commonjs-module" | "commonjs-static" | "amd-require" | "umd" | "umd2" | "system" | "node-commonjs" | undefined, ...args_3: unknown[]) => void, ...args_2: unknown[]) => unknown) | ((args_0: {
|
|
16
16
|
context?: string | undefined;
|
|
17
17
|
dependencyType?: string | undefined;
|
|
18
18
|
request?: string | undefined;
|
|
@@ -22,7 +22,7 @@ declare const htmlRspackPluginOptions: z.ZodObject<{
|
|
|
22
22
|
templateParameters?: Record<string, string> | undefined;
|
|
23
23
|
inject?: boolean | "head" | "body" | undefined;
|
|
24
24
|
publicPath?: string | undefined;
|
|
25
|
-
scriptLoading?: "
|
|
25
|
+
scriptLoading?: "blocking" | "defer" | "module" | undefined;
|
|
26
26
|
chunks?: string[] | undefined;
|
|
27
27
|
excludedChunks?: string[] | undefined;
|
|
28
28
|
sri?: "sha256" | "sha384" | "sha512" | undefined;
|
|
@@ -37,7 +37,7 @@ declare const htmlRspackPluginOptions: z.ZodObject<{
|
|
|
37
37
|
templateParameters?: Record<string, string> | undefined;
|
|
38
38
|
inject?: boolean | "head" | "body" | undefined;
|
|
39
39
|
publicPath?: string | undefined;
|
|
40
|
-
scriptLoading?: "
|
|
40
|
+
scriptLoading?: "blocking" | "defer" | "module" | undefined;
|
|
41
41
|
chunks?: string[] | undefined;
|
|
42
42
|
excludedChunks?: string[] | undefined;
|
|
43
43
|
sri?: "sha256" | "sha384" | "sha512" | undefined;
|
|
@@ -55,7 +55,7 @@ export declare const HtmlRspackPlugin: {
|
|
|
55
55
|
templateParameters?: Record<string, string> | undefined;
|
|
56
56
|
inject?: boolean | "head" | "body" | undefined;
|
|
57
57
|
publicPath?: string | undefined;
|
|
58
|
-
scriptLoading?: "
|
|
58
|
+
scriptLoading?: "blocking" | "defer" | "module" | undefined;
|
|
59
59
|
chunks?: string[] | undefined;
|
|
60
60
|
excludedChunks?: string[] | undefined;
|
|
61
61
|
sri?: "sha256" | "sha384" | "sha512" | undefined;
|
|
@@ -46,21 +46,15 @@ export * from "./FlagDependencyUsagePlugin";
|
|
|
46
46
|
export * from "./MangleExportsPlugin";
|
|
47
47
|
export * from "./BundlerInfoRspackPlugin";
|
|
48
48
|
export * from "./ModuleConcatenationPlugin";
|
|
49
|
+
export * from "./CssModulesPlugin";
|
|
49
50
|
export * from "./HtmlRspackPlugin";
|
|
50
51
|
export * from "./CopyRspackPlugin";
|
|
51
52
|
export * from "./SwcJsMinimizerPlugin";
|
|
52
53
|
export * from "./SwcCssMinimizerPlugin";
|
|
53
|
-
export * from "./RSCClientEntryPlugin";
|
|
54
|
-
export * from "./RSCClientReferenceManifestRspackPlugin";
|
|
55
54
|
export * from "./JsLoaderRspackPlugin";
|
|
56
|
-
import { RawBuiltins
|
|
55
|
+
import { RawBuiltins } from "@rspack/binding";
|
|
57
56
|
import { RspackOptionsNormalized } from "..";
|
|
58
|
-
type BuiltinsCssConfig = {
|
|
59
|
-
modules?: Partial<RawCssModulesConfig>;
|
|
60
|
-
namedExports?: boolean;
|
|
61
|
-
};
|
|
62
57
|
export interface Builtins {
|
|
63
|
-
css?: BuiltinsCssConfig;
|
|
64
58
|
treeShaking?: boolean | "module";
|
|
65
59
|
}
|
|
66
60
|
export declare function deprecated_resolveBuiltins(builtins: Builtins, options: RspackOptionsNormalized): RawBuiltins;
|
|
@@ -64,12 +64,11 @@ __exportStar(require("./FlagDependencyUsagePlugin"), exports);
|
|
|
64
64
|
__exportStar(require("./MangleExportsPlugin"), exports);
|
|
65
65
|
__exportStar(require("./BundlerInfoRspackPlugin"), exports);
|
|
66
66
|
__exportStar(require("./ModuleConcatenationPlugin"), exports);
|
|
67
|
+
__exportStar(require("./CssModulesPlugin"), exports);
|
|
67
68
|
__exportStar(require("./HtmlRspackPlugin"), exports);
|
|
68
69
|
__exportStar(require("./CopyRspackPlugin"), exports);
|
|
69
70
|
__exportStar(require("./SwcJsMinimizerPlugin"), exports);
|
|
70
71
|
__exportStar(require("./SwcCssMinimizerPlugin"), exports);
|
|
71
|
-
__exportStar(require("./RSCClientEntryPlugin"), exports);
|
|
72
|
-
__exportStar(require("./RSCClientReferenceManifestRspackPlugin"), exports);
|
|
73
72
|
__exportStar(require("./JsLoaderRspackPlugin"), exports);
|
|
74
73
|
function resolveTreeShaking(treeShaking, production) {
|
|
75
74
|
return treeShaking !== undefined
|
|
@@ -79,23 +78,8 @@ function resolveTreeShaking(treeShaking, production) {
|
|
|
79
78
|
: "false";
|
|
80
79
|
}
|
|
81
80
|
function deprecated_resolveBuiltins(builtins, options) {
|
|
82
|
-
var _a, _b;
|
|
83
81
|
const production = options.mode === "production" || !options.mode;
|
|
84
82
|
return {
|
|
85
|
-
// TODO: discuss with webpack, this should move to css generator options
|
|
86
|
-
css: options.experiments.css
|
|
87
|
-
? {
|
|
88
|
-
modules: {
|
|
89
|
-
localsConvention: "asIs",
|
|
90
|
-
localIdentName: production
|
|
91
|
-
? "[hash]"
|
|
92
|
-
: "[path][name][ext]__[local]",
|
|
93
|
-
exportsOnly: false,
|
|
94
|
-
...(_a = builtins.css) === null || _a === void 0 ? void 0 : _a.modules
|
|
95
|
-
},
|
|
96
|
-
namedExports: (_b = builtins.css) === null || _b === void 0 ? void 0 : _b.namedExports
|
|
97
|
-
}
|
|
98
|
-
: undefined,
|
|
99
83
|
treeShaking: resolveTreeShaking(builtins.treeShaking, production)
|
|
100
84
|
};
|
|
101
85
|
}
|
package/dist/config/adapter.js
CHANGED
|
@@ -336,7 +336,8 @@ const getRawModuleRule = (rule, path, options) => {
|
|
|
336
336
|
if (rule.resourceQuery && !tryMatch(query, rule.resourceQuery)) {
|
|
337
337
|
return false;
|
|
338
338
|
}
|
|
339
|
-
if (rule.resourceFragment &&
|
|
339
|
+
if (rule.resourceFragment &&
|
|
340
|
+
!tryMatch(fragment, rule.resourceFragment)) {
|
|
340
341
|
return false;
|
|
341
342
|
}
|
|
342
343
|
return true;
|
|
@@ -408,9 +409,26 @@ function getRawParserOptions(parser, type) {
|
|
|
408
409
|
javascript: getRawJavascriptParserOptions(parser)
|
|
409
410
|
};
|
|
410
411
|
}
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
412
|
+
else if (type === "css") {
|
|
413
|
+
return {
|
|
414
|
+
type: "css",
|
|
415
|
+
css: getRawCssParserOptions(parser)
|
|
416
|
+
};
|
|
417
|
+
}
|
|
418
|
+
else if (type === "css/auto") {
|
|
419
|
+
return {
|
|
420
|
+
type: "css/auto",
|
|
421
|
+
cssAuto: getRawCssParserOptions(parser)
|
|
422
|
+
};
|
|
423
|
+
}
|
|
424
|
+
else if (type === "css/module") {
|
|
425
|
+
return {
|
|
426
|
+
type: "css/module",
|
|
427
|
+
cssModule: getRawCssParserOptions(parser)
|
|
428
|
+
};
|
|
429
|
+
}
|
|
430
|
+
// FIXME: shouldn't depend on module type, for example: `rules: [{ test: /\.css/, generator: {..} }]` will error
|
|
431
|
+
throw new Error(`unreachable: unknow module type: ${type}`);
|
|
414
432
|
}
|
|
415
433
|
function getRawJavascriptParserOptions(parser) {
|
|
416
434
|
var _a, _b, _c, _d, _e;
|
|
@@ -443,6 +461,11 @@ function getRawAssetParserDataUrl(dataUrlCondition) {
|
|
|
443
461
|
}
|
|
444
462
|
throw new Error(`unreachable: AssetParserDataUrl type should be one of "options", but got ${dataUrlCondition}`);
|
|
445
463
|
}
|
|
464
|
+
function getRawCssParserOptions(parser) {
|
|
465
|
+
return {
|
|
466
|
+
namedExports: parser.namedExports
|
|
467
|
+
};
|
|
468
|
+
}
|
|
446
469
|
function getRawGeneratorOptions(generator, type) {
|
|
447
470
|
if (type === "asset") {
|
|
448
471
|
return {
|
|
@@ -466,9 +489,25 @@ function getRawGeneratorOptions(generator, type) {
|
|
|
466
489
|
: undefined
|
|
467
490
|
};
|
|
468
491
|
}
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
492
|
+
if (type === "css") {
|
|
493
|
+
return {
|
|
494
|
+
type: "css",
|
|
495
|
+
css: getRawCssGeneratorOptions(generator)
|
|
496
|
+
};
|
|
497
|
+
}
|
|
498
|
+
if (type === "css/auto") {
|
|
499
|
+
return {
|
|
500
|
+
type: "css/auto",
|
|
501
|
+
cssAuto: getRawCssAutoOrModuleGeneratorOptions(generator)
|
|
502
|
+
};
|
|
503
|
+
}
|
|
504
|
+
if (type === "css/module") {
|
|
505
|
+
return {
|
|
506
|
+
type: "css/module",
|
|
507
|
+
cssModule: getRawCssAutoOrModuleGeneratorOptions(generator)
|
|
508
|
+
};
|
|
509
|
+
}
|
|
510
|
+
throw new Error(`unreachable: unknow module type: ${type}`);
|
|
472
511
|
}
|
|
473
512
|
function getRawAssetGeneratorOptions(options) {
|
|
474
513
|
return {
|
|
@@ -502,6 +541,19 @@ function getRawAssetGeneratorDataUrl(dataUrl) {
|
|
|
502
541
|
}
|
|
503
542
|
throw new Error(`unreachable: AssetGeneratorDataUrl type should be one of "options", "function", but got ${dataUrl}`);
|
|
504
543
|
}
|
|
544
|
+
function getRawCssGeneratorOptions(options) {
|
|
545
|
+
return {
|
|
546
|
+
exportsConvention: options.exportsConvention,
|
|
547
|
+
exportsOnly: options.exportsOnly
|
|
548
|
+
};
|
|
549
|
+
}
|
|
550
|
+
function getRawCssAutoOrModuleGeneratorOptions(options) {
|
|
551
|
+
return {
|
|
552
|
+
localIdentName: options.localIdentName,
|
|
553
|
+
exportsConvention: options.exportsConvention,
|
|
554
|
+
exportsOnly: options.exportsOnly
|
|
555
|
+
};
|
|
556
|
+
}
|
|
505
557
|
function getRawOptimization(optimization) {
|
|
506
558
|
(0, assert_1.default)(!(0, util_1.isNil)(optimization.removeAvailableModules) &&
|
|
507
559
|
!(0, util_1.isNil)(optimization.sideEffects) &&
|
package/dist/config/defaults.js
CHANGED
|
@@ -55,9 +55,9 @@ const applyRspackOptionsDefaults = (options) => {
|
|
|
55
55
|
});
|
|
56
56
|
applySnapshotDefaults(options.snapshot, { production });
|
|
57
57
|
applyModuleDefaults(options.module, {
|
|
58
|
-
// syncWebAssembly: options.experiments.syncWebAssembly,
|
|
59
58
|
asyncWebAssembly: options.experiments.asyncWebAssembly,
|
|
60
|
-
css: options.experiments.css
|
|
59
|
+
css: options.experiments.css,
|
|
60
|
+
targetProperties
|
|
61
61
|
});
|
|
62
62
|
applyOutputDefaults(options.output, {
|
|
63
63
|
context: options.context,
|
|
@@ -85,7 +85,8 @@ const applyRspackOptionsDefaults = (options) => {
|
|
|
85
85
|
applyOptimizationDefaults(options.optimization, { production, development });
|
|
86
86
|
options.resolve = (0, cleverMerge_1.cleverMerge)(getResolveDefaults({
|
|
87
87
|
targetProperties,
|
|
88
|
-
mode: options.mode
|
|
88
|
+
mode: options.mode,
|
|
89
|
+
css: options.experiments.css
|
|
89
90
|
}), options.resolve);
|
|
90
91
|
options.resolveLoader = (0, cleverMerge_1.cleverMerge)(getResolveLoaderDefaults(), options.resolveLoader);
|
|
91
92
|
};
|
|
@@ -131,8 +132,9 @@ const applySnapshotDefaults = (snapshot, { production }) => {
|
|
|
131
132
|
const applyJavascriptParserOptionsDefaults = (parserOptions) => {
|
|
132
133
|
D(parserOptions, "dynamicImportMode", "lazy");
|
|
133
134
|
};
|
|
134
|
-
const applyModuleDefaults = (module, { asyncWebAssembly, css }) => {
|
|
135
|
+
const applyModuleDefaults = (module, { asyncWebAssembly, css, targetProperties }) => {
|
|
135
136
|
(0, assertNotNil_1.assertNotNill)(module.parser);
|
|
137
|
+
(0, assertNotNil_1.assertNotNill)(module.generator);
|
|
136
138
|
F(module.parser, ModuleTypeConstants_1.ASSET_MODULE_TYPE, () => ({}));
|
|
137
139
|
(0, assertNotNil_1.assertNotNill)(module.parser.asset);
|
|
138
140
|
F(module.parser.asset, "dataUrlCondition", () => ({}));
|
|
@@ -142,6 +144,31 @@ const applyModuleDefaults = (module, { asyncWebAssembly, css }) => {
|
|
|
142
144
|
F(module.parser, "javascript", () => ({}));
|
|
143
145
|
(0, assertNotNil_1.assertNotNill)(module.parser.javascript);
|
|
144
146
|
applyJavascriptParserOptionsDefaults(module.parser.javascript);
|
|
147
|
+
if (css) {
|
|
148
|
+
F(module.parser, "css", () => ({}));
|
|
149
|
+
(0, assertNotNil_1.assertNotNill)(module.parser.css);
|
|
150
|
+
D(module.parser.css, "namedExports", true);
|
|
151
|
+
F(module.parser, "css/auto", () => ({}));
|
|
152
|
+
(0, assertNotNil_1.assertNotNill)(module.parser["css/auto"]);
|
|
153
|
+
D(module.parser["css/auto"], "namedExports", true);
|
|
154
|
+
F(module.parser, "css/module", () => ({}));
|
|
155
|
+
(0, assertNotNil_1.assertNotNill)(module.parser["css/module"]);
|
|
156
|
+
D(module.parser["css/module"], "namedExports", true);
|
|
157
|
+
F(module.generator, "css", () => ({}));
|
|
158
|
+
(0, assertNotNil_1.assertNotNill)(module.generator.css);
|
|
159
|
+
D(module.generator["css"], "exportsOnly", !targetProperties || !targetProperties.document);
|
|
160
|
+
D(module.generator["css"], "exportsConvention", "as-is");
|
|
161
|
+
F(module.generator, "css/auto", () => ({}));
|
|
162
|
+
(0, assertNotNil_1.assertNotNill)(module.generator["css/auto"]);
|
|
163
|
+
D(module.generator["css/auto"], "exportsOnly", !targetProperties || !targetProperties.document);
|
|
164
|
+
D(module.generator["css/auto"], "exportsConvention", "as-is");
|
|
165
|
+
D(module.generator["css/auto"], "localIdentName", "[uniqueName]-[id]-[local]");
|
|
166
|
+
F(module.generator, "css/module", () => ({}));
|
|
167
|
+
(0, assertNotNil_1.assertNotNill)(module.generator["css/module"]);
|
|
168
|
+
D(module.generator["css/module"], "exportsOnly", !targetProperties || !targetProperties.document);
|
|
169
|
+
D(module.generator["css/module"], "exportsConvention", "as-is");
|
|
170
|
+
D(module.generator["css/module"], "localIdentName", "[uniqueName]-[id]-[local]");
|
|
171
|
+
}
|
|
145
172
|
A(module, "defaultRules", () => {
|
|
146
173
|
const esm = {
|
|
147
174
|
type: "javascript/esm",
|
|
@@ -222,38 +249,24 @@ const applyModuleDefaults = (module, { asyncWebAssembly, css }) => {
|
|
|
222
249
|
});
|
|
223
250
|
}
|
|
224
251
|
if (css) {
|
|
225
|
-
const
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
fullySpecified: true,
|
|
229
|
-
preferRelative: true
|
|
230
|
-
}
|
|
231
|
-
};
|
|
232
|
-
const cssModulesRule = {
|
|
233
|
-
type: "css/module",
|
|
234
|
-
resolve: {
|
|
235
|
-
fullySpecified: true
|
|
236
|
-
}
|
|
252
|
+
const resolve = {
|
|
253
|
+
fullySpecified: true,
|
|
254
|
+
preferRelative: true
|
|
237
255
|
};
|
|
238
256
|
rules.push({
|
|
239
257
|
test: /\.css$/i,
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
test: /\.module\.css$/i,
|
|
243
|
-
...cssModulesRule
|
|
244
|
-
},
|
|
245
|
-
{
|
|
246
|
-
...cssRule
|
|
247
|
-
}
|
|
248
|
-
]
|
|
258
|
+
type: "css/auto",
|
|
259
|
+
resolve
|
|
249
260
|
});
|
|
250
261
|
rules.push({
|
|
251
262
|
mimetype: "text/css+module",
|
|
252
|
-
|
|
263
|
+
type: "css/module",
|
|
264
|
+
resolve
|
|
253
265
|
});
|
|
254
266
|
rules.push({
|
|
255
267
|
mimetype: "text/css",
|
|
256
|
-
|
|
268
|
+
type: "css",
|
|
269
|
+
resolve
|
|
257
270
|
});
|
|
258
271
|
}
|
|
259
272
|
rules.push({
|
|
@@ -646,7 +659,7 @@ const getResolveLoaderDefaults = () => {
|
|
|
646
659
|
};
|
|
647
660
|
// The values are aligned with webpack
|
|
648
661
|
// https://github.com/webpack/webpack/blob/b9fb99c63ca433b24233e0bbc9ce336b47872c08/lib/config/defaults.js#L1431
|
|
649
|
-
const getResolveDefaults = ({ targetProperties, mode }) => {
|
|
662
|
+
const getResolveDefaults = ({ targetProperties, mode, css }) => {
|
|
650
663
|
const conditions = ["webpack"];
|
|
651
664
|
conditions.push(mode === "development" ? "development" : "production");
|
|
652
665
|
if (targetProperties) {
|
|
@@ -706,6 +719,22 @@ const getResolveDefaults = ({ targetProperties, mode }) => {
|
|
|
706
719
|
unknown: cjsDeps()
|
|
707
720
|
}
|
|
708
721
|
};
|
|
722
|
+
if (css) {
|
|
723
|
+
const styleConditions = [];
|
|
724
|
+
styleConditions.push("webpack");
|
|
725
|
+
styleConditions.push(mode === "development" ? "development" : "production");
|
|
726
|
+
styleConditions.push("style");
|
|
727
|
+
resolveOptions.byDependency["css-import"] = {
|
|
728
|
+
// We avoid using any main files because we have to be consistent with CSS `@import`
|
|
729
|
+
// and CSS `@import` does not handle `main` files in directories,
|
|
730
|
+
// you should always specify the full URL for styles
|
|
731
|
+
mainFiles: [],
|
|
732
|
+
mainFields: ["style", "..."],
|
|
733
|
+
conditionNames: styleConditions,
|
|
734
|
+
extensions: [".css"],
|
|
735
|
+
preferRelative: true
|
|
736
|
+
};
|
|
737
|
+
}
|
|
709
738
|
return resolveOptions;
|
|
710
739
|
};
|
|
711
740
|
const D = (obj, prop, value) => {
|
|
@@ -233,7 +233,12 @@ const getNormalizedEntryStatic = (entry) => {
|
|
|
233
233
|
chunkLoading: value.chunkLoading,
|
|
234
234
|
asyncChunks: value.asyncChunks,
|
|
235
235
|
filename: value.filename,
|
|
236
|
-
library: value.library
|
|
236
|
+
library: value.library,
|
|
237
|
+
dependOn: Array.isArray(value.dependOn)
|
|
238
|
+
? value.dependOn
|
|
239
|
+
: value.dependOn
|
|
240
|
+
? [value.dependOn]
|
|
241
|
+
: undefined
|
|
237
242
|
};
|
|
238
243
|
}
|
|
239
244
|
}
|