@rspack/core 0.5.9-canary-5be4c34-20240403005129 → 0.5.9-canary-8778e17-20240403045016
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 +0 -1
- package/dist/Compilation.js +1 -2
- package/dist/Compiler.d.ts +8 -3
- package/dist/Compiler.js +34 -31
- package/dist/Stats.js +2 -2
- package/dist/builtin-plugin/EntryPlugin.d.ts +0 -1
- package/dist/builtin-plugin/EntryPlugin.js +1 -2
- package/dist/builtin-plugin/index.d.ts +6 -2
- package/dist/builtin-plugin/index.js +15 -1
- package/dist/config/adapter.js +7 -59
- package/dist/config/defaults.js +28 -57
- package/dist/config/normalization.d.ts +0 -1
- package/dist/config/normalization.js +1 -6
- package/dist/config/zod.d.ts +0 -648
- package/dist/config/zod.js +2 -43
- package/dist/exports.d.ts +0 -51
- package/dist/exports.js +1 -3
- package/dist/lib/EntryOptionPlugin.js +1 -1
- package/dist/rspackOptionsApply.js +1 -4
- package/package.json +5 -5
- package/dist/builtin-plugin/CssModulesPlugin.d.ts +0 -10
- package/dist/builtin-plugin/CssModulesPlugin.js +0 -6
- package/dist/lib/NormalModuleReplacementPlugin.d.ts +0 -19
- package/dist/lib/NormalModuleReplacementPlugin.js +0 -75
package/dist/Compilation.d.ts
CHANGED
|
@@ -90,7 +90,6 @@ export declare class Compilation {
|
|
|
90
90
|
ExecuteModuleContext
|
|
91
91
|
]>;
|
|
92
92
|
runtimeModule: liteTapable.SyncHook<[JsRuntimeModule, Chunk], void>;
|
|
93
|
-
afterSeal: liteTapable.AsyncSeriesHook<[], void>;
|
|
94
93
|
};
|
|
95
94
|
options: RspackOptionsNormalized;
|
|
96
95
|
outputOptions: OutputNormalized;
|
package/dist/Compilation.js
CHANGED
|
@@ -154,8 +154,7 @@ 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"])
|
|
158
|
-
afterSeal: new liteTapable.AsyncSeriesHook([])
|
|
157
|
+
runtimeModule: new liteTapable.SyncHook(["module", "chunk"])
|
|
159
158
|
};
|
|
160
159
|
this.compiler = compiler;
|
|
161
160
|
this.resolverFactory = compiler.resolverFactory;
|
package/dist/Compiler.d.ts
CHANGED
|
@@ -42,6 +42,7 @@ declare class Compiler {
|
|
|
42
42
|
};
|
|
43
43
|
compilation?: Compilation;
|
|
44
44
|
compilationParams?: CompilationParams;
|
|
45
|
+
first: boolean;
|
|
45
46
|
builtinPlugins: binding.BuiltinPlugin[];
|
|
46
47
|
root: Compiler;
|
|
47
48
|
running: boolean;
|
|
@@ -109,10 +110,14 @@ declare class Compiler {
|
|
|
109
110
|
getInfrastructureLogger(name: string | Function): Logger;
|
|
110
111
|
run(callback: Callback<Error, Stats>): void;
|
|
111
112
|
/**
|
|
112
|
-
*
|
|
113
|
-
* @internal
|
|
113
|
+
* Safety: This method is only valid to call if the previous rebuild task is finished, or there will be data races.
|
|
114
114
|
*/
|
|
115
|
-
|
|
115
|
+
build(callback?: (error: Error | null) => void): void;
|
|
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;
|
|
116
121
|
compile(callback: Callback<Error, Compilation>): void;
|
|
117
122
|
watch(watchOptions: WatchOptions, handler: Callback<Error, Stats>): Watching;
|
|
118
123
|
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,
|
|
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;
|
|
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
|
-
|
|
87
|
+
this.first = 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,10 +386,36 @@ class Compiler {
|
|
|
386
386
|
}
|
|
387
387
|
}
|
|
388
388
|
/**
|
|
389
|
-
*
|
|
390
|
-
* @internal
|
|
389
|
+
* Safety: This method is only valid to call if the previous rebuild task is finished, or there will be data races.
|
|
391
390
|
*/
|
|
392
|
-
|
|
391
|
+
build(callback) {
|
|
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) {
|
|
393
419
|
__classPrivateFieldGet(this, _Compiler_instances, "m", _Compiler_getInstance).call(this, (error, instance) => {
|
|
394
420
|
if (error) {
|
|
395
421
|
return callback === null || callback === void 0 ? void 0 : callback(error);
|
|
@@ -411,7 +437,7 @@ class Compiler {
|
|
|
411
437
|
}
|
|
412
438
|
this.hooks.compile.call(params);
|
|
413
439
|
__classPrivateFieldGet(this, _Compiler_instances, "m", _Compiler_resetThisCompilation).call(this);
|
|
414
|
-
|
|
440
|
+
this.build(err => {
|
|
415
441
|
if (err) {
|
|
416
442
|
return callback(err);
|
|
417
443
|
}
|
|
@@ -444,7 +470,7 @@ class Compiler {
|
|
|
444
470
|
}
|
|
445
471
|
close(callback) {
|
|
446
472
|
if (this.watching) {
|
|
447
|
-
// When there is still an active watching, close this
|
|
473
|
+
// When there is still an active watching, close this first
|
|
448
474
|
this.watching.close(() => {
|
|
449
475
|
this.close(callback);
|
|
450
476
|
});
|
|
@@ -471,7 +497,7 @@ class Compiler {
|
|
|
471
497
|
}
|
|
472
498
|
}
|
|
473
499
|
exports.Compiler = Compiler;
|
|
474
|
-
_Compiler_instance = new WeakMap(),
|
|
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) {
|
|
475
501
|
const error = (0, bindingVersionCheck_1.checkVersion)();
|
|
476
502
|
if (error) {
|
|
477
503
|
return callback(error);
|
|
@@ -573,7 +599,6 @@ _Compiler_instance = new WeakMap(), _Compiler_initial = new WeakMap(), _Compiler
|
|
|
573
599
|
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)),
|
|
574
600
|
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)),
|
|
575
601
|
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()),
|
|
577
602
|
registerNormalModuleFactoryBeforeResolveTaps: __classPrivateFieldGet(this, _Compiler_instances, "m", _Compiler_createHookRegisterTaps).call(this, binding.RegisterJsTapKind.NormalModuleFactoryBeforeResolve, () => this.compilationParams.normalModuleFactory.hooks.beforeResolve, queried => async (resolveData) => {
|
|
578
603
|
const normalizedResolveData = {
|
|
579
604
|
request: resolveData.request,
|
|
@@ -726,28 +751,6 @@ _Compiler_instance = new WeakMap(), _Compiler_initial = new WeakMap(), _Compiler
|
|
|
726
751
|
getTaps.registerKind = registerKind;
|
|
727
752
|
getTaps.getHookMap = getHookMap;
|
|
728
753
|
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
|
-
});
|
|
751
754
|
}, _Compiler_createCompilation = function _Compiler_createCompilation(native) {
|
|
752
755
|
const compilation = new Compilation_1.Compilation(this, native);
|
|
753
756
|
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 pn = (typeof name === "string" && name.toLowerCase()) || name;
|
|
107
|
+
switch (pn) {
|
|
108
108
|
case "none":
|
|
109
109
|
return {
|
|
110
110
|
all: false
|
|
@@ -9,7 +9,6 @@ export type EntryOptions = {
|
|
|
9
9
|
baseUri?: string;
|
|
10
10
|
filename?: FilenameTemplate;
|
|
11
11
|
library?: LibraryOptions;
|
|
12
|
-
dependOn?: string[];
|
|
13
12
|
};
|
|
14
13
|
export declare const EntryPlugin: {
|
|
15
14
|
new (context: string, entry: string, options?: string | EntryOptions | undefined): {
|
|
@@ -26,7 +26,6 @@ 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)
|
|
30
|
-
dependOn: entry.dependOn
|
|
29
|
+
library: entry.library && (0, config_1.getRawLibrary)(entry.library)
|
|
31
30
|
};
|
|
32
31
|
}
|
|
@@ -46,15 +46,19 @@ export * from "./FlagDependencyUsagePlugin";
|
|
|
46
46
|
export * from "./MangleExportsPlugin";
|
|
47
47
|
export * from "./BundlerInfoRspackPlugin";
|
|
48
48
|
export * from "./ModuleConcatenationPlugin";
|
|
49
|
-
export * from "./CssModulesPlugin";
|
|
50
49
|
export * from "./HtmlRspackPlugin";
|
|
51
50
|
export * from "./CopyRspackPlugin";
|
|
52
51
|
export * from "./SwcJsMinimizerPlugin";
|
|
53
52
|
export * from "./SwcCssMinimizerPlugin";
|
|
54
53
|
export * from "./JsLoaderRspackPlugin";
|
|
55
|
-
import { RawBuiltins } from "@rspack/binding";
|
|
54
|
+
import { RawBuiltins, RawCssModulesConfig } from "@rspack/binding";
|
|
56
55
|
import { RspackOptionsNormalized } from "..";
|
|
56
|
+
type BuiltinsCssConfig = {
|
|
57
|
+
modules?: Partial<RawCssModulesConfig>;
|
|
58
|
+
namedExports?: boolean;
|
|
59
|
+
};
|
|
57
60
|
export interface Builtins {
|
|
61
|
+
css?: BuiltinsCssConfig;
|
|
58
62
|
treeShaking?: boolean | "module";
|
|
59
63
|
}
|
|
60
64
|
export declare function deprecated_resolveBuiltins(builtins: Builtins, options: RspackOptionsNormalized): RawBuiltins;
|
|
@@ -64,7 +64,6 @@ __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);
|
|
68
67
|
__exportStar(require("./HtmlRspackPlugin"), exports);
|
|
69
68
|
__exportStar(require("./CopyRspackPlugin"), exports);
|
|
70
69
|
__exportStar(require("./SwcJsMinimizerPlugin"), exports);
|
|
@@ -78,8 +77,23 @@ function resolveTreeShaking(treeShaking, production) {
|
|
|
78
77
|
: "false";
|
|
79
78
|
}
|
|
80
79
|
function deprecated_resolveBuiltins(builtins, options) {
|
|
80
|
+
var _a, _b;
|
|
81
81
|
const production = options.mode === "production" || !options.mode;
|
|
82
82
|
return {
|
|
83
|
+
// TODO: discuss with webpack, this should move to css generator options
|
|
84
|
+
css: options.experiments.css
|
|
85
|
+
? {
|
|
86
|
+
modules: {
|
|
87
|
+
localsConvention: "asIs",
|
|
88
|
+
localIdentName: production
|
|
89
|
+
? "[hash]"
|
|
90
|
+
: "[path][name][ext]__[local]",
|
|
91
|
+
exportsOnly: false,
|
|
92
|
+
...(_a = builtins.css) === null || _a === void 0 ? void 0 : _a.modules
|
|
93
|
+
},
|
|
94
|
+
namedExports: (_b = builtins.css) === null || _b === void 0 ? void 0 : _b.namedExports
|
|
95
|
+
}
|
|
96
|
+
: undefined,
|
|
83
97
|
treeShaking: resolveTreeShaking(builtins.treeShaking, production)
|
|
84
98
|
};
|
|
85
99
|
}
|
package/dist/config/adapter.js
CHANGED
|
@@ -336,8 +336,7 @@ const getRawModuleRule = (rule, path, options) => {
|
|
|
336
336
|
if (rule.resourceQuery && !tryMatch(query, rule.resourceQuery)) {
|
|
337
337
|
return false;
|
|
338
338
|
}
|
|
339
|
-
if (rule.resourceFragment &&
|
|
340
|
-
!tryMatch(fragment, rule.resourceFragment)) {
|
|
339
|
+
if (rule.resourceFragment && !tryMatch(fragment, rule.resourceFragment)) {
|
|
341
340
|
return false;
|
|
342
341
|
}
|
|
343
342
|
return true;
|
|
@@ -409,26 +408,9 @@ function getRawParserOptions(parser, type) {
|
|
|
409
408
|
javascript: getRawJavascriptParserOptions(parser)
|
|
410
409
|
};
|
|
411
410
|
}
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
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}`);
|
|
411
|
+
return {
|
|
412
|
+
type: "unknown"
|
|
413
|
+
};
|
|
432
414
|
}
|
|
433
415
|
function getRawJavascriptParserOptions(parser) {
|
|
434
416
|
var _a, _b, _c, _d, _e;
|
|
@@ -461,11 +443,6 @@ function getRawAssetParserDataUrl(dataUrlCondition) {
|
|
|
461
443
|
}
|
|
462
444
|
throw new Error(`unreachable: AssetParserDataUrl type should be one of "options", but got ${dataUrlCondition}`);
|
|
463
445
|
}
|
|
464
|
-
function getRawCssParserOptions(parser) {
|
|
465
|
-
return {
|
|
466
|
-
namedExports: parser.namedExports
|
|
467
|
-
};
|
|
468
|
-
}
|
|
469
446
|
function getRawGeneratorOptions(generator, type) {
|
|
470
447
|
if (type === "asset") {
|
|
471
448
|
return {
|
|
@@ -489,25 +466,9 @@ function getRawGeneratorOptions(generator, type) {
|
|
|
489
466
|
: undefined
|
|
490
467
|
};
|
|
491
468
|
}
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
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}`);
|
|
469
|
+
return {
|
|
470
|
+
type: "unknown"
|
|
471
|
+
};
|
|
511
472
|
}
|
|
512
473
|
function getRawAssetGeneratorOptions(options) {
|
|
513
474
|
return {
|
|
@@ -541,19 +502,6 @@ function getRawAssetGeneratorDataUrl(dataUrl) {
|
|
|
541
502
|
}
|
|
542
503
|
throw new Error(`unreachable: AssetGeneratorDataUrl type should be one of "options", "function", but got ${dataUrl}`);
|
|
543
504
|
}
|
|
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
|
-
}
|
|
557
505
|
function getRawOptimization(optimization) {
|
|
558
506
|
(0, assert_1.default)(!(0, util_1.isNil)(optimization.removeAvailableModules) &&
|
|
559
507
|
!(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,
|
|
58
59
|
asyncWebAssembly: options.experiments.asyncWebAssembly,
|
|
59
|
-
css: options.experiments.css
|
|
60
|
-
targetProperties
|
|
60
|
+
css: options.experiments.css
|
|
61
61
|
});
|
|
62
62
|
applyOutputDefaults(options.output, {
|
|
63
63
|
context: options.context,
|
|
@@ -85,8 +85,7 @@ 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
|
|
89
|
-
css: options.experiments.css
|
|
88
|
+
mode: options.mode
|
|
90
89
|
}), options.resolve);
|
|
91
90
|
options.resolveLoader = (0, cleverMerge_1.cleverMerge)(getResolveLoaderDefaults(), options.resolveLoader);
|
|
92
91
|
};
|
|
@@ -132,9 +131,8 @@ const applySnapshotDefaults = (snapshot, { production }) => {
|
|
|
132
131
|
const applyJavascriptParserOptionsDefaults = (parserOptions) => {
|
|
133
132
|
D(parserOptions, "dynamicImportMode", "lazy");
|
|
134
133
|
};
|
|
135
|
-
const applyModuleDefaults = (module, { asyncWebAssembly, css
|
|
134
|
+
const applyModuleDefaults = (module, { asyncWebAssembly, css }) => {
|
|
136
135
|
(0, assertNotNil_1.assertNotNill)(module.parser);
|
|
137
|
-
(0, assertNotNil_1.assertNotNill)(module.generator);
|
|
138
136
|
F(module.parser, ModuleTypeConstants_1.ASSET_MODULE_TYPE, () => ({}));
|
|
139
137
|
(0, assertNotNil_1.assertNotNill)(module.parser.asset);
|
|
140
138
|
F(module.parser.asset, "dataUrlCondition", () => ({}));
|
|
@@ -144,31 +142,6 @@ const applyModuleDefaults = (module, { asyncWebAssembly, css, targetProperties }
|
|
|
144
142
|
F(module.parser, "javascript", () => ({}));
|
|
145
143
|
(0, assertNotNil_1.assertNotNill)(module.parser.javascript);
|
|
146
144
|
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
|
-
}
|
|
172
145
|
A(module, "defaultRules", () => {
|
|
173
146
|
const esm = {
|
|
174
147
|
type: "javascript/esm",
|
|
@@ -249,24 +222,38 @@ const applyModuleDefaults = (module, { asyncWebAssembly, css, targetProperties }
|
|
|
249
222
|
});
|
|
250
223
|
}
|
|
251
224
|
if (css) {
|
|
252
|
-
const
|
|
253
|
-
|
|
254
|
-
|
|
225
|
+
const cssRule = {
|
|
226
|
+
type: "css",
|
|
227
|
+
resolve: {
|
|
228
|
+
fullySpecified: true,
|
|
229
|
+
preferRelative: true
|
|
230
|
+
}
|
|
231
|
+
};
|
|
232
|
+
const cssModulesRule = {
|
|
233
|
+
type: "css/module",
|
|
234
|
+
resolve: {
|
|
235
|
+
fullySpecified: true
|
|
236
|
+
}
|
|
255
237
|
};
|
|
256
238
|
rules.push({
|
|
257
239
|
test: /\.css$/i,
|
|
258
|
-
|
|
259
|
-
|
|
240
|
+
oneOf: [
|
|
241
|
+
{
|
|
242
|
+
test: /\.module\.css$/i,
|
|
243
|
+
...cssModulesRule
|
|
244
|
+
},
|
|
245
|
+
{
|
|
246
|
+
...cssRule
|
|
247
|
+
}
|
|
248
|
+
]
|
|
260
249
|
});
|
|
261
250
|
rules.push({
|
|
262
251
|
mimetype: "text/css+module",
|
|
263
|
-
|
|
264
|
-
resolve
|
|
252
|
+
...cssModulesRule
|
|
265
253
|
});
|
|
266
254
|
rules.push({
|
|
267
255
|
mimetype: "text/css",
|
|
268
|
-
|
|
269
|
-
resolve
|
|
256
|
+
...cssRule
|
|
270
257
|
});
|
|
271
258
|
}
|
|
272
259
|
rules.push({
|
|
@@ -659,7 +646,7 @@ const getResolveLoaderDefaults = () => {
|
|
|
659
646
|
};
|
|
660
647
|
// The values are aligned with webpack
|
|
661
648
|
// https://github.com/webpack/webpack/blob/b9fb99c63ca433b24233e0bbc9ce336b47872c08/lib/config/defaults.js#L1431
|
|
662
|
-
const getResolveDefaults = ({ targetProperties, mode
|
|
649
|
+
const getResolveDefaults = ({ targetProperties, mode }) => {
|
|
663
650
|
const conditions = ["webpack"];
|
|
664
651
|
conditions.push(mode === "development" ? "development" : "production");
|
|
665
652
|
if (targetProperties) {
|
|
@@ -719,22 +706,6 @@ const getResolveDefaults = ({ targetProperties, mode, css }) => {
|
|
|
719
706
|
unknown: cjsDeps()
|
|
720
707
|
}
|
|
721
708
|
};
|
|
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
|
-
}
|
|
738
709
|
return resolveOptions;
|
|
739
710
|
};
|
|
740
711
|
const D = (obj, prop, value) => {
|
|
@@ -233,12 +233,7 @@ const getNormalizedEntryStatic = (entry) => {
|
|
|
233
233
|
chunkLoading: value.chunkLoading,
|
|
234
234
|
asyncChunks: value.asyncChunks,
|
|
235
235
|
filename: value.filename,
|
|
236
|
-
library: value.library
|
|
237
|
-
dependOn: Array.isArray(value.dependOn)
|
|
238
|
-
? value.dependOn
|
|
239
|
-
: value.dependOn
|
|
240
|
-
? [value.dependOn]
|
|
241
|
-
: undefined
|
|
236
|
+
library: value.library
|
|
242
237
|
};
|
|
243
238
|
}
|
|
244
239
|
}
|