@rspack/core 0.6.3 → 0.6.4
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 -26
- package/dist/Compilation.js +165 -52
- package/dist/Compiler.js +15 -13
- package/dist/builtin-plugin/DynamicEntryPlugin.d.ts +11 -0
- package/dist/builtin-plugin/DynamicEntryPlugin.js +25 -0
- package/dist/builtin-plugin/EntryPlugin.d.ts +2 -1
- package/dist/builtin-plugin/EntryPlugin.js +3 -2
- package/dist/builtin-plugin/RuntimeChunkPlugin.d.ts +11 -0
- package/dist/builtin-plugin/RuntimeChunkPlugin.js +6 -0
- package/dist/builtin-plugin/css-extract/index.js +1 -3
- package/dist/builtin-plugin/index.d.ts +2 -0
- package/dist/builtin-plugin/index.js +2 -0
- package/dist/config/adapter.d.ts +1 -2
- package/dist/config/adapter.js +24 -7
- package/dist/config/defaults.js +44 -10
- package/dist/config/normalization.d.ts +6 -2
- package/dist/config/normalization.js +12 -8
- package/dist/config/zod.d.ts +725 -15
- package/dist/config/zod.js +15 -3
- package/dist/container/ContainerPlugin.js +1 -2
- package/dist/container/ModuleFederationPluginV1.js +2 -0
- package/dist/exports.d.ts +5 -0
- package/dist/exports.js +24 -21
- package/dist/lib/EntryOptionPlugin.js +1 -3
- package/dist/rspackOptionsApply.js +1 -5
- package/hot/emitter.js +20 -1
- package/package.json +4 -6
package/dist/config/defaults.js
CHANGED
|
@@ -67,6 +67,7 @@ const applyRspackOptionsDefaults = (options) => {
|
|
|
67
67
|
(Array.isArray(target) &&
|
|
68
68
|
target.some(target => target.startsWith("browserslist"))),
|
|
69
69
|
outputModule: options.experiments.outputModule,
|
|
70
|
+
development,
|
|
70
71
|
entry: options.entry,
|
|
71
72
|
futureDefaults
|
|
72
73
|
});
|
|
@@ -88,6 +89,7 @@ const applyRspackOptionsDefaults = (options) => {
|
|
|
88
89
|
css: options.experiments.css
|
|
89
90
|
});
|
|
90
91
|
options.resolve = (0, cleverMerge_1.cleverMerge)(getResolveDefaults({
|
|
92
|
+
context: options.context,
|
|
91
93
|
targetProperties,
|
|
92
94
|
mode: options.mode,
|
|
93
95
|
css: options.experiments.css
|
|
@@ -125,15 +127,33 @@ const applyExperimentsDefaults = (experiments, { cache }) => {
|
|
|
125
127
|
}
|
|
126
128
|
};
|
|
127
129
|
const applySnapshotDefaults = (snapshot, { production }) => {
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
130
|
+
if (typeof snapshot.module === "object") {
|
|
131
|
+
D(snapshot.module, "timestamp", false);
|
|
132
|
+
D(snapshot.module, "hash", false);
|
|
133
|
+
}
|
|
134
|
+
else {
|
|
135
|
+
F(snapshot, "module", () => production
|
|
136
|
+
? { timestamp: true, hash: true }
|
|
137
|
+
: { timestamp: true, hash: false });
|
|
138
|
+
}
|
|
139
|
+
if (typeof snapshot.resolve === "object") {
|
|
140
|
+
D(snapshot.resolve, "timestamp", false);
|
|
141
|
+
D(snapshot.resolve, "hash", false);
|
|
142
|
+
}
|
|
143
|
+
else {
|
|
144
|
+
F(snapshot, "resolve", () => production
|
|
145
|
+
? { timestamp: true, hash: true }
|
|
146
|
+
: { timestamp: true, hash: false });
|
|
147
|
+
}
|
|
134
148
|
};
|
|
135
|
-
const applyJavascriptParserOptionsDefaults = (parserOptions) => {
|
|
136
|
-
|
|
149
|
+
const applyJavascriptParserOptionsDefaults = (parserOptions, fallback) => {
|
|
150
|
+
var _a, _b, _c, _d, _e, _f;
|
|
151
|
+
D(parserOptions, "dynamicImportMode", (_a = fallback === null || fallback === void 0 ? void 0 : fallback.dynamicImportMode) !== null && _a !== void 0 ? _a : "lazy");
|
|
152
|
+
D(parserOptions, "dynamicImportPrefetch", (_b = fallback === null || fallback === void 0 ? void 0 : fallback.dynamicImportPrefetch) !== null && _b !== void 0 ? _b : false);
|
|
153
|
+
D(parserOptions, "dynamicImportPreload", (_c = fallback === null || fallback === void 0 ? void 0 : fallback.dynamicImportPreload) !== null && _c !== void 0 ? _c : false);
|
|
154
|
+
D(parserOptions, "url", (_d = fallback === null || fallback === void 0 ? void 0 : fallback.url) !== null && _d !== void 0 ? _d : true);
|
|
155
|
+
D(parserOptions, "exprContextCritical", (_e = fallback === null || fallback === void 0 ? void 0 : fallback.exprContextCritical) !== null && _e !== void 0 ? _e : true);
|
|
156
|
+
D(parserOptions, "wrappedContextCritical", (_f = fallback === null || fallback === void 0 ? void 0 : fallback.wrappedContextCritical) !== null && _f !== void 0 ? _f : false);
|
|
137
157
|
};
|
|
138
158
|
const applyModuleDefaults = (module, { asyncWebAssembly, css, targetProperties }) => {
|
|
139
159
|
(0, assertNotNil_1.assertNotNill)(module.parser);
|
|
@@ -147,6 +167,15 @@ const applyModuleDefaults = (module, { asyncWebAssembly, css, targetProperties }
|
|
|
147
167
|
F(module.parser, "javascript", () => ({}));
|
|
148
168
|
(0, assertNotNil_1.assertNotNill)(module.parser.javascript);
|
|
149
169
|
applyJavascriptParserOptionsDefaults(module.parser.javascript);
|
|
170
|
+
F(module.parser, "javascript/auto", () => ({}));
|
|
171
|
+
(0, assertNotNil_1.assertNotNill)(module.parser["javascript/auto"]);
|
|
172
|
+
applyJavascriptParserOptionsDefaults(module.parser["javascript/auto"], module.parser.javascript);
|
|
173
|
+
F(module.parser, "javascript/dynamic", () => ({}));
|
|
174
|
+
(0, assertNotNil_1.assertNotNill)(module.parser["javascript/dynamic"]);
|
|
175
|
+
applyJavascriptParserOptionsDefaults(module.parser["javascript/dynamic"], module.parser.javascript);
|
|
176
|
+
F(module.parser, "javascript/esm", () => ({}));
|
|
177
|
+
(0, assertNotNil_1.assertNotNill)(module.parser["javascript/esm"]);
|
|
178
|
+
applyJavascriptParserOptionsDefaults(module.parser["javascript/esm"], module.parser.javascript);
|
|
150
179
|
if (css) {
|
|
151
180
|
F(module.parser, "css", () => ({}));
|
|
152
181
|
(0, assertNotNil_1.assertNotNill)(module.parser.css);
|
|
@@ -287,7 +316,7 @@ const applyModuleDefaults = (module, { asyncWebAssembly, css, targetProperties }
|
|
|
287
316
|
return rules;
|
|
288
317
|
});
|
|
289
318
|
};
|
|
290
|
-
const applyOutputDefaults = (output, { context, outputModule, targetProperties: tp, isAffectedByBrowserslist, entry, futureDefaults }) => {
|
|
319
|
+
const applyOutputDefaults = (output, { context, outputModule, targetProperties: tp, isAffectedByBrowserslist, development, entry, futureDefaults }) => {
|
|
291
320
|
const getLibraryName = (library) => {
|
|
292
321
|
const libraryName = typeof library === "object" &&
|
|
293
322
|
library &&
|
|
@@ -371,6 +400,7 @@ const applyOutputDefaults = (output, { context, outputModule, targetProperties:
|
|
|
371
400
|
D(output, "assetModuleFilename", "[hash][ext][query]");
|
|
372
401
|
D(output, "webassemblyModuleFilename", "[hash].module.wasm");
|
|
373
402
|
F(output, "path", () => path_1.default.join(process.cwd(), "dist"));
|
|
403
|
+
F(output, "pathinfo", () => development);
|
|
374
404
|
D(output, "publicPath", tp && (tp.document || tp.importScripts) ? "auto" : "");
|
|
375
405
|
D(output, "hashFunction", futureDefaults ? "xxhash64" : "md4");
|
|
376
406
|
D(output, "hashDigest", "hex");
|
|
@@ -502,6 +532,9 @@ const applyOutputDefaults = (output, { context, outputModule, targetProperties:
|
|
|
502
532
|
F(trustedTypes, "policyName", () => output.uniqueName.replace(/[^a-zA-Z0-9\-#=_/@.%]+/g, "_") || "webpack");
|
|
503
533
|
}
|
|
504
534
|
const forEachEntry = (fn) => {
|
|
535
|
+
if (typeof entry === "function") {
|
|
536
|
+
return;
|
|
537
|
+
}
|
|
505
538
|
for (const name of Object.keys(entry)) {
|
|
506
539
|
fn(entry[name]);
|
|
507
540
|
}
|
|
@@ -660,7 +693,7 @@ const getResolveLoaderDefaults = () => {
|
|
|
660
693
|
};
|
|
661
694
|
// The values are aligned with webpack
|
|
662
695
|
// https://github.com/webpack/webpack/blob/b9fb99c63ca433b24233e0bbc9ce336b47872c08/lib/config/defaults.js#L1431
|
|
663
|
-
const getResolveDefaults = ({ targetProperties, mode, css }) => {
|
|
696
|
+
const getResolveDefaults = ({ context, targetProperties, mode, css }) => {
|
|
664
697
|
const conditions = ["webpack"];
|
|
665
698
|
conditions.push(mode === "development" ? "development" : "production");
|
|
666
699
|
if (targetProperties) {
|
|
@@ -701,6 +734,7 @@ const getResolveDefaults = ({ targetProperties, mode, css }) => {
|
|
|
701
734
|
extensions: [],
|
|
702
735
|
aliasFields: [],
|
|
703
736
|
exportsFields: ["exports"],
|
|
737
|
+
roots: [context],
|
|
704
738
|
mainFields: ["main"],
|
|
705
739
|
byDependency: {
|
|
706
740
|
wasm: esmDeps(),
|
|
@@ -10,7 +10,8 @@
|
|
|
10
10
|
import type { Compilation } from "../Compilation";
|
|
11
11
|
import type { Context, Dependencies, Node, DevTool, Externals, ExternalsPresets, ExternalsType, InfrastructureLogging, LibraryOptions, Mode, Name, Resolve, Target, SnapshotOptions, CacheOptions, StatsValue, Optimization, Plugins, Watch, WatchOptions, DevServer, Profile, Bail, Builtins, EntryRuntime, ChunkLoading, PublicPath, EntryFilename, Path, Clean, Filename, ChunkFilename, CrossOriginLoading, CssFilename, CssChunkFilename, HotUpdateMainFilename, HotUpdateChunkFilename, AssetModuleFilename, UniqueName, ChunkLoadingGlobal, EnabledLibraryTypes, OutputModule, StrictModuleErrorHandling, GlobalObject, ImportFunctionName, Iife, WasmLoading, EnabledWasmLoadingTypes, WebassemblyModuleFilename, TrustedTypes, SourceMapFilename, HashDigest, HashDigestLength, HashFunction, HashSalt, WorkerPublicPath, RuleSetRules, ParserOptionsByModuleType, GeneratorOptionsByModuleType, RspackFutureOptions, HotUpdateGlobal, ScriptType, NoParseOption, DevtoolNamespace, DevtoolModuleFilenameTemplate, DevtoolFallbackModuleFilenameTemplate, RspackOptions } from "./zod";
|
|
12
12
|
export declare const getNormalizedRspackOptions: (config: RspackOptions) => RspackOptionsNormalized;
|
|
13
|
-
export type
|
|
13
|
+
export type EntryDynamicNormalized = () => Promise<EntryStaticNormalized>;
|
|
14
|
+
export type EntryNormalized = EntryDynamicNormalized | EntryStaticNormalized;
|
|
14
15
|
export interface EntryStaticNormalized {
|
|
15
16
|
[k: string]: EntryDescriptionNormalized;
|
|
16
17
|
}
|
|
@@ -27,6 +28,7 @@ export interface EntryDescriptionNormalized {
|
|
|
27
28
|
}
|
|
28
29
|
export interface OutputNormalized {
|
|
29
30
|
path?: Path;
|
|
31
|
+
pathinfo?: boolean | "verbose";
|
|
30
32
|
clean?: Clean;
|
|
31
33
|
publicPath?: PublicPath;
|
|
32
34
|
filename?: Filename;
|
|
@@ -87,7 +89,9 @@ export interface ExperimentsNormalized {
|
|
|
87
89
|
}
|
|
88
90
|
export type IgnoreWarningsNormalized = ((warning: Error, compilation: Compilation) => boolean)[];
|
|
89
91
|
export type OptimizationRuntimeChunkNormalized = false | {
|
|
90
|
-
name:
|
|
92
|
+
name: string | ((entrypoint: {
|
|
93
|
+
name: string;
|
|
94
|
+
}) => string);
|
|
91
95
|
};
|
|
92
96
|
export interface RspackOptionsNormalized {
|
|
93
97
|
name?: Name;
|
|
@@ -30,7 +30,9 @@ const getNormalizedRspackOptions = (config) => {
|
|
|
30
30
|
mode: config.mode,
|
|
31
31
|
entry: config.entry === undefined
|
|
32
32
|
? { main: {} }
|
|
33
|
-
:
|
|
33
|
+
: typeof config.entry === "function"
|
|
34
|
+
? (fn => () => Promise.resolve().then(fn).then(getNormalizedEntryStatic))(config.entry)
|
|
35
|
+
: getNormalizedEntryStatic(config.entry),
|
|
34
36
|
output: nestedConfig(config.output, output => {
|
|
35
37
|
var _a;
|
|
36
38
|
const { library } = output;
|
|
@@ -47,6 +49,7 @@ const getNormalizedRspackOptions = (config) => {
|
|
|
47
49
|
: undefined;
|
|
48
50
|
return {
|
|
49
51
|
path: output.path,
|
|
52
|
+
pathinfo: output.pathinfo,
|
|
50
53
|
publicPath: output.publicPath,
|
|
51
54
|
filename: output.filename,
|
|
52
55
|
clean: output.clean,
|
|
@@ -254,19 +257,20 @@ const getNormalizedOptimizationRuntimeChunk = (runtimeChunk) => {
|
|
|
254
257
|
return false;
|
|
255
258
|
if (runtimeChunk === "single") {
|
|
256
259
|
return {
|
|
257
|
-
name:
|
|
260
|
+
name: "single"
|
|
258
261
|
};
|
|
259
262
|
}
|
|
260
263
|
if (runtimeChunk === true || runtimeChunk === "multiple") {
|
|
261
264
|
return {
|
|
262
|
-
name:
|
|
265
|
+
name: "multiple"
|
|
263
266
|
};
|
|
264
267
|
}
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
268
|
+
if (runtimeChunk.name) {
|
|
269
|
+
const opts = {
|
|
270
|
+
name: runtimeChunk.name
|
|
271
|
+
};
|
|
272
|
+
return opts;
|
|
273
|
+
}
|
|
270
274
|
};
|
|
271
275
|
const nestedConfig = (value, fn) => value === undefined ? fn({}) : fn(value);
|
|
272
276
|
const optionalNestedConfig = (value, fn) => (value === undefined ? undefined : fn(value));
|