@rspack/core 0.5.9 → 0.6.0-canary-f5973db-20240409131230
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 +3 -8
- package/dist/Compilation.js +6 -10
- 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/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,
|
|
@@ -82,10 +82,15 @@ const applyRspackOptionsDefaults = (options) => {
|
|
|
82
82
|
: "var";
|
|
83
83
|
});
|
|
84
84
|
applyNodeDefaults(options.node, { targetProperties });
|
|
85
|
-
applyOptimizationDefaults(options.optimization, {
|
|
85
|
+
applyOptimizationDefaults(options.optimization, {
|
|
86
|
+
production,
|
|
87
|
+
development,
|
|
88
|
+
css: options.experiments.css
|
|
89
|
+
});
|
|
86
90
|
options.resolve = (0, cleverMerge_1.cleverMerge)(getResolveDefaults({
|
|
87
91
|
targetProperties,
|
|
88
|
-
mode: options.mode
|
|
92
|
+
mode: options.mode,
|
|
93
|
+
css: options.experiments.css
|
|
89
94
|
}), options.resolve);
|
|
90
95
|
options.resolveLoader = (0, cleverMerge_1.cleverMerge)(getResolveLoaderDefaults(), options.resolveLoader);
|
|
91
96
|
};
|
|
@@ -111,8 +116,7 @@ const applyExperimentsDefaults = (experiments, { cache }) => {
|
|
|
111
116
|
D(experiments, "topLevelAwait", true);
|
|
112
117
|
D(experiments, "rspackFuture", {});
|
|
113
118
|
if (typeof experiments.rspackFuture === "object") {
|
|
114
|
-
D(experiments.rspackFuture, "newTreeshaking",
|
|
115
|
-
D(experiments.rspackFuture, "disableApplyEntryLazily", true);
|
|
119
|
+
D(experiments.rspackFuture, "newTreeshaking", true);
|
|
116
120
|
D(experiments.rspackFuture, "bundlerInfo", {});
|
|
117
121
|
if (typeof experiments.rspackFuture.bundlerInfo === "object") {
|
|
118
122
|
D(experiments.rspackFuture.bundlerInfo, "version", require("../../package.json").version);
|
|
@@ -131,8 +135,9 @@ const applySnapshotDefaults = (snapshot, { production }) => {
|
|
|
131
135
|
const applyJavascriptParserOptionsDefaults = (parserOptions) => {
|
|
132
136
|
D(parserOptions, "dynamicImportMode", "lazy");
|
|
133
137
|
};
|
|
134
|
-
const applyModuleDefaults = (module, { asyncWebAssembly, css }) => {
|
|
138
|
+
const applyModuleDefaults = (module, { asyncWebAssembly, css, targetProperties }) => {
|
|
135
139
|
(0, assertNotNil_1.assertNotNill)(module.parser);
|
|
140
|
+
(0, assertNotNil_1.assertNotNill)(module.generator);
|
|
136
141
|
F(module.parser, ModuleTypeConstants_1.ASSET_MODULE_TYPE, () => ({}));
|
|
137
142
|
(0, assertNotNil_1.assertNotNill)(module.parser.asset);
|
|
138
143
|
F(module.parser.asset, "dataUrlCondition", () => ({}));
|
|
@@ -142,6 +147,31 @@ const applyModuleDefaults = (module, { asyncWebAssembly, css }) => {
|
|
|
142
147
|
F(module.parser, "javascript", () => ({}));
|
|
143
148
|
(0, assertNotNil_1.assertNotNill)(module.parser.javascript);
|
|
144
149
|
applyJavascriptParserOptionsDefaults(module.parser.javascript);
|
|
150
|
+
if (css) {
|
|
151
|
+
F(module.parser, "css", () => ({}));
|
|
152
|
+
(0, assertNotNil_1.assertNotNill)(module.parser.css);
|
|
153
|
+
D(module.parser.css, "namedExports", true);
|
|
154
|
+
F(module.parser, "css/auto", () => ({}));
|
|
155
|
+
(0, assertNotNil_1.assertNotNill)(module.parser["css/auto"]);
|
|
156
|
+
D(module.parser["css/auto"], "namedExports", true);
|
|
157
|
+
F(module.parser, "css/module", () => ({}));
|
|
158
|
+
(0, assertNotNil_1.assertNotNill)(module.parser["css/module"]);
|
|
159
|
+
D(module.parser["css/module"], "namedExports", true);
|
|
160
|
+
F(module.generator, "css", () => ({}));
|
|
161
|
+
(0, assertNotNil_1.assertNotNill)(module.generator.css);
|
|
162
|
+
D(module.generator["css"], "exportsOnly", !targetProperties || !targetProperties.document);
|
|
163
|
+
D(module.generator["css"], "exportsConvention", "as-is");
|
|
164
|
+
F(module.generator, "css/auto", () => ({}));
|
|
165
|
+
(0, assertNotNil_1.assertNotNill)(module.generator["css/auto"]);
|
|
166
|
+
D(module.generator["css/auto"], "exportsOnly", !targetProperties || !targetProperties.document);
|
|
167
|
+
D(module.generator["css/auto"], "exportsConvention", "as-is");
|
|
168
|
+
D(module.generator["css/auto"], "localIdentName", "[uniqueName]-[id]-[local]");
|
|
169
|
+
F(module.generator, "css/module", () => ({}));
|
|
170
|
+
(0, assertNotNil_1.assertNotNill)(module.generator["css/module"]);
|
|
171
|
+
D(module.generator["css/module"], "exportsOnly", !targetProperties || !targetProperties.document);
|
|
172
|
+
D(module.generator["css/module"], "exportsConvention", "as-is");
|
|
173
|
+
D(module.generator["css/module"], "localIdentName", "[uniqueName]-[id]-[local]");
|
|
174
|
+
}
|
|
145
175
|
A(module, "defaultRules", () => {
|
|
146
176
|
const esm = {
|
|
147
177
|
type: "javascript/esm",
|
|
@@ -222,38 +252,24 @@ const applyModuleDefaults = (module, { asyncWebAssembly, css }) => {
|
|
|
222
252
|
});
|
|
223
253
|
}
|
|
224
254
|
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
|
-
}
|
|
255
|
+
const resolve = {
|
|
256
|
+
fullySpecified: true,
|
|
257
|
+
preferRelative: true
|
|
237
258
|
};
|
|
238
259
|
rules.push({
|
|
239
260
|
test: /\.css$/i,
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
test: /\.module\.css$/i,
|
|
243
|
-
...cssModulesRule
|
|
244
|
-
},
|
|
245
|
-
{
|
|
246
|
-
...cssRule
|
|
247
|
-
}
|
|
248
|
-
]
|
|
261
|
+
type: "css/auto",
|
|
262
|
+
resolve
|
|
249
263
|
});
|
|
250
264
|
rules.push({
|
|
251
265
|
mimetype: "text/css+module",
|
|
252
|
-
|
|
266
|
+
type: "css/module",
|
|
267
|
+
resolve
|
|
253
268
|
});
|
|
254
269
|
rules.push({
|
|
255
270
|
mimetype: "text/css",
|
|
256
|
-
|
|
271
|
+
type: "css",
|
|
272
|
+
resolve
|
|
257
273
|
});
|
|
258
274
|
}
|
|
259
275
|
rules.push({
|
|
@@ -566,7 +582,7 @@ const applyNodeDefaults = (node, { targetProperties }) => {
|
|
|
566
582
|
return "warn-mock";
|
|
567
583
|
});
|
|
568
584
|
};
|
|
569
|
-
const applyOptimizationDefaults = (optimization, { production, development }) => {
|
|
585
|
+
const applyOptimizationDefaults = (optimization, { production, development, css }) => {
|
|
570
586
|
D(optimization, "removeAvailableModules", true);
|
|
571
587
|
D(optimization, "removeEmptyChunks", true);
|
|
572
588
|
D(optimization, "mergeDuplicateChunks", true);
|
|
@@ -604,9 +620,7 @@ const applyOptimizationDefaults = (optimization, { production, development }) =>
|
|
|
604
620
|
});
|
|
605
621
|
const { splitChunks } = optimization;
|
|
606
622
|
if (splitChunks) {
|
|
607
|
-
|
|
608
|
-
// css ? ["javascript", "css", "unknown"] : ["javascript", "unknown"]
|
|
609
|
-
// );
|
|
623
|
+
A(splitChunks, "defaultSizeTypes", () => css ? ["javascript", "css", "unknown"] : ["javascript", "unknown"]);
|
|
610
624
|
D(splitChunks, "hidePathInfo", production);
|
|
611
625
|
D(splitChunks, "chunks", "async");
|
|
612
626
|
// D(splitChunks, "usedExports", optimization.usedExports === true);
|
|
@@ -646,7 +660,7 @@ const getResolveLoaderDefaults = () => {
|
|
|
646
660
|
};
|
|
647
661
|
// The values are aligned with webpack
|
|
648
662
|
// https://github.com/webpack/webpack/blob/b9fb99c63ca433b24233e0bbc9ce336b47872c08/lib/config/defaults.js#L1431
|
|
649
|
-
const getResolveDefaults = ({ targetProperties, mode }) => {
|
|
663
|
+
const getResolveDefaults = ({ targetProperties, mode, css }) => {
|
|
650
664
|
const conditions = ["webpack"];
|
|
651
665
|
conditions.push(mode === "development" ? "development" : "production");
|
|
652
666
|
if (targetProperties) {
|
|
@@ -706,6 +720,22 @@ const getResolveDefaults = ({ targetProperties, mode }) => {
|
|
|
706
720
|
unknown: cjsDeps()
|
|
707
721
|
}
|
|
708
722
|
};
|
|
723
|
+
if (css) {
|
|
724
|
+
const styleConditions = [];
|
|
725
|
+
styleConditions.push("webpack");
|
|
726
|
+
styleConditions.push(mode === "development" ? "development" : "production");
|
|
727
|
+
styleConditions.push("style");
|
|
728
|
+
resolveOptions.byDependency["css-import"] = {
|
|
729
|
+
// We avoid using any main files because we have to be consistent with CSS `@import`
|
|
730
|
+
// and CSS `@import` does not handle `main` files in directories,
|
|
731
|
+
// you should always specify the full URL for styles
|
|
732
|
+
mainFiles: [],
|
|
733
|
+
mainFields: ["style", "..."],
|
|
734
|
+
conditionNames: styleConditions,
|
|
735
|
+
extensions: [".css"],
|
|
736
|
+
preferRelative: true
|
|
737
|
+
};
|
|
738
|
+
}
|
|
709
739
|
return resolveOptions;
|
|
710
740
|
};
|
|
711
741
|
const D = (obj, prop, value) => {
|
|
@@ -177,6 +177,9 @@ const getNormalizedRspackOptions = (config) => {
|
|
|
177
177
|
runtimeChunk: getNormalizedOptimizationRuntimeChunk(optimization.runtimeChunk),
|
|
178
178
|
splitChunks: nestedConfig(optimization.splitChunks, splitChunks => splitChunks && {
|
|
179
179
|
...splitChunks,
|
|
180
|
+
defaultSizeTypes: splitChunks.defaultSizeTypes
|
|
181
|
+
? [...splitChunks.defaultSizeTypes]
|
|
182
|
+
: ["..."],
|
|
180
183
|
cacheGroups: cloneObject(splitChunks.cacheGroups)
|
|
181
184
|
})
|
|
182
185
|
};
|
|
@@ -233,7 +236,12 @@ const getNormalizedEntryStatic = (entry) => {
|
|
|
233
236
|
chunkLoading: value.chunkLoading,
|
|
234
237
|
asyncChunks: value.asyncChunks,
|
|
235
238
|
filename: value.filename,
|
|
236
|
-
library: value.library
|
|
239
|
+
library: value.library,
|
|
240
|
+
dependOn: Array.isArray(value.dependOn)
|
|
241
|
+
? value.dependOn
|
|
242
|
+
: value.dependOn
|
|
243
|
+
? [value.dependOn]
|
|
244
|
+
: undefined
|
|
237
245
|
};
|
|
238
246
|
}
|
|
239
247
|
}
|