@rspack/core 1.0.0-beta.1 → 1.0.0-beta.3
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/ChunkGroup.d.ts +1 -0
- package/dist/ChunkGroup.js +3 -0
- package/dist/Compilation.d.ts +38 -1
- package/dist/Compilation.js +109 -44
- package/dist/Compiler.d.ts +1 -0
- package/dist/Compiler.js +31 -26
- package/dist/ExecuteModulePlugin.d.ts +0 -1
- package/dist/ExecuteModulePlugin.js +0 -1
- package/dist/Module.d.ts +1 -2
- package/dist/Module.js +0 -1
- package/dist/MultiCompiler.js +11 -7
- package/dist/MultiStats.d.ts +1 -1
- package/dist/MultiStats.js +19 -16
- package/dist/NormalModule.js +3 -4
- package/dist/Resolver.d.ts +1 -2
- package/dist/RspackError.js +1 -1
- package/dist/Stats.d.ts +1 -1
- package/dist/Stats.js +22 -2
- package/dist/Template.d.ts +4 -4
- package/dist/Template.js +8 -6
- package/dist/Watching.js +3 -5
- package/dist/builtin-loader/lightningcss/index.js +1 -1
- package/dist/builtin-plugin/DefinePlugin.js +1 -1
- package/dist/builtin-plugin/DynamicEntryPlugin.d.ts +11 -10
- package/dist/builtin-plugin/DynamicEntryPlugin.js +26 -15
- package/dist/builtin-plugin/EnableChunkLoadingPlugin.d.ts +2 -2
- package/dist/builtin-plugin/EnableChunkLoadingPlugin.js +1 -1
- package/dist/builtin-plugin/EnableLibraryPlugin.js +1 -6
- package/dist/builtin-plugin/EnableWasmLoadingPlugin.d.ts +2 -2
- package/dist/builtin-plugin/EnableWasmLoadingPlugin.js +1 -1
- package/dist/builtin-plugin/EntryPlugin.d.ts +2 -2
- package/dist/builtin-plugin/ExternalsPlugin.js +1 -1
- package/dist/builtin-plugin/JavascriptModulesPlugin.d.ts +0 -1
- package/dist/builtin-plugin/JavascriptModulesPlugin.js +1 -1
- package/dist/builtin-plugin/LightningCssMiminizerRspackPlugin.d.ts +21 -4
- package/dist/builtin-plugin/LightningCssMiminizerRspackPlugin.js +29 -5
- package/dist/builtin-plugin/SwcCssMinimizerPlugin.d.ts +4 -6
- package/dist/builtin-plugin/SwcJsMinimizerPlugin.d.ts +17 -12
- package/dist/builtin-plugin/SwcJsMinimizerPlugin.js +11 -9
- package/dist/builtin-plugin/css-extract/hmr/hotModuleReplacement.js +13 -11
- package/dist/builtin-plugin/css-extract/hmr/normalizeUrl.d.ts +1 -1
- package/dist/builtin-plugin/css-extract/hmr/normalizeUrl.js +9 -7
- package/dist/builtin-plugin/css-extract/loader.js +5 -12
- package/dist/builtin-plugin/lazy-compilation/backend.js +4 -4
- package/dist/config/adapter.d.ts +2 -2
- package/dist/config/adapter.js +1 -0
- package/dist/config/adapterRuleUse.d.ts +2 -6
- package/dist/config/adapterRuleUse.js +7 -6
- package/dist/config/defaults.js +21 -32
- package/dist/config/normalization.d.ts +1 -0
- package/dist/config/normalization.js +5 -2
- package/dist/config/zod.d.ts +762 -114
- package/dist/config/zod.js +29 -6
- package/dist/container/default.runtime.js +1 -1
- package/dist/exports.d.ts +4 -3
- package/dist/exports.js +5 -2
- package/dist/lib/AbstractMethodError.js +2 -3
- package/dist/lib/Cache.d.ts +1 -1
- package/dist/lib/Cache.js +6 -4
- package/dist/lib/CacheFacade.js +8 -9
- package/dist/lib/Dependency.d.ts +23 -0
- package/dist/lib/Dependency.js +11 -0
- package/dist/lib/EnvironmentPlugin.js +1 -3
- package/dist/lib/LoaderOptionsPlugin.d.ts +4 -2
- package/dist/lib/LoaderOptionsPlugin.js +0 -2
- package/dist/lib/ModuleFilenameHelpers.js +1 -1
- package/dist/lib/WebpackError.d.ts +0 -6
- package/dist/lib/WebpackError.js +0 -8
- package/dist/lib/cache/MemoryCachePlugin.d.ts +5 -0
- package/dist/lib/cache/MemoryCachePlugin.js +40 -0
- package/dist/lib/cache/mergeEtags.d.ts +3 -3
- package/dist/lib/cache/mergeEtags.js +5 -3
- package/dist/lib/formatLocation.d.ts +1 -1
- package/dist/loader-runner/index.js +10 -9
- package/dist/loader-runner/loadLoader.js +8 -11
- package/dist/logging/Logger.js +3 -3
- package/dist/logging/createConsoleLogger.d.ts +26 -6
- package/dist/logging/createConsoleLogger.js +21 -58
- package/dist/logging/runtime.d.ts +4 -10
- package/dist/logging/runtime.js +8 -23
- package/dist/logging/truncateArgs.d.ts +4 -4
- package/dist/logging/truncateArgs.js +5 -10
- package/dist/node/NodeEnvironmentPlugin.js +2 -2
- package/dist/node/NodeWatchFileSystem.js +6 -6
- package/dist/node/nodeConsole.d.ts +7 -21
- package/dist/node/nodeConsole.js +31 -38
- package/dist/rspackOptionsApply.d.ts +0 -1
- package/dist/rspackOptionsApply.js +8 -7
- package/dist/sharing/ProvideSharedPlugin.d.ts +20 -19
- package/dist/sharing/ProvideSharedPlugin.js +26 -17
- package/dist/sharing/SharePlugin.d.ts +3 -0
- package/dist/sharing/SharePlugin.js +4 -1
- package/dist/stats/DefaultStatsFactoryPlugin.js +187 -96
- package/dist/stats/DefaultStatsPresetPlugin.js +2 -5
- package/dist/stats/DefaultStatsPrinterPlugin.js +18 -19
- package/dist/stats/StatsFactory.d.ts +2 -1
- package/dist/stats/StatsFactory.js +5 -10
- package/dist/stats/StatsPrinter.js +3 -4
- package/dist/stats/statsFactoryUtils.d.ts +155 -28
- package/dist/util/SizeFormatHelpers.js +1 -1
- package/dist/util/assertNotNil.d.ts +1 -1
- package/dist/util/assetCondition.d.ts +2 -0
- package/dist/util/assetCondition.js +2 -0
- package/dist/util/bindingVersionCheck.js +3 -3
- package/dist/util/cleverMerge.js +8 -6
- package/dist/util/comparators.d.ts +1 -1
- package/dist/util/comparators.js +5 -4
- package/dist/util/createHash.js +11 -6
- package/dist/util/fs.js +2 -2
- package/dist/util/hash/wasm-hash.js +5 -4
- package/dist/util/identifier.d.ts +4 -4
- package/dist/util/identifier.js +10 -10
- package/dist/util/index.js +1 -1
- package/dist/util/memoize.js +4 -6
- package/dist/util/smartGrouping.js +4 -6
- package/dist/util/webpack.d.ts +1 -1
- package/dist/util/webpack.js +2 -1
- package/module.d.ts +1 -1
- package/package.json +3 -3
- package/dist/builtin-plugin/css-extract/loader-options.json +0 -37
- package/dist/builtin-plugin/css-extract/plugin-options.json +0 -79
|
@@ -47,11 +47,11 @@ function getRawExtractCommentsOptions(extractComments) {
|
|
|
47
47
|
return undefined;
|
|
48
48
|
}
|
|
49
49
|
exports.SwcJsMinimizerRspackPlugin = (0, base_1.create)(binding_1.BuiltinPluginName.SwcJsMinimizerRspackPlugin, (options) => {
|
|
50
|
-
let compress = options?.compress ?? true;
|
|
51
|
-
const mangle = options?.mangle ?? true;
|
|
50
|
+
let compress = options?.minimizerOptions?.compress ?? true;
|
|
51
|
+
const mangle = options?.minimizerOptions?.mangle ?? true;
|
|
52
52
|
const format = {
|
|
53
53
|
comments: false,
|
|
54
|
-
...options?.format
|
|
54
|
+
...options?.minimizerOptions?.format
|
|
55
55
|
};
|
|
56
56
|
if (compress && typeof compress === "object") {
|
|
57
57
|
compress = {
|
|
@@ -65,13 +65,15 @@ exports.SwcJsMinimizerRspackPlugin = (0, base_1.create)(binding_1.BuiltinPluginN
|
|
|
65
65
|
};
|
|
66
66
|
}
|
|
67
67
|
return {
|
|
68
|
-
extractComments: getRawExtractCommentsOptions(options?.extractComments),
|
|
69
|
-
compress,
|
|
70
|
-
mangle,
|
|
71
|
-
format,
|
|
72
|
-
module: options?.module,
|
|
73
68
|
test: options?.test,
|
|
74
69
|
include: options?.include,
|
|
75
|
-
exclude: options?.exclude
|
|
70
|
+
exclude: options?.exclude,
|
|
71
|
+
extractComments: getRawExtractCommentsOptions(options?.extractComments),
|
|
72
|
+
minimizerOptions: {
|
|
73
|
+
compress,
|
|
74
|
+
mangle,
|
|
75
|
+
format,
|
|
76
|
+
module: options?.minimizerOptions?.module
|
|
77
|
+
}
|
|
76
78
|
};
|
|
77
79
|
}, "compilation");
|
|
@@ -7,10 +7,8 @@ const noDocument = typeof document === "undefined";
|
|
|
7
7
|
const { forEach } = Array.prototype;
|
|
8
8
|
function debounce(fn, time) {
|
|
9
9
|
let timeout = 0;
|
|
10
|
-
return function () {
|
|
11
|
-
// @ts-ignore
|
|
10
|
+
return function (...args) {
|
|
12
11
|
const self = this;
|
|
13
|
-
const args = arguments;
|
|
14
12
|
const functionCall = function functionCall() {
|
|
15
13
|
return fn.apply(self, args);
|
|
16
14
|
};
|
|
@@ -34,12 +32,12 @@ function getCurrentScriptUrl(moduleId) {
|
|
|
34
32
|
}
|
|
35
33
|
srcByModuleId[moduleId] = src;
|
|
36
34
|
}
|
|
37
|
-
return
|
|
35
|
+
return (fileMap) => {
|
|
38
36
|
if (!src) {
|
|
39
37
|
return null;
|
|
40
38
|
}
|
|
41
39
|
const splitResult = src.split(/([^\\/]+)\.js$/);
|
|
42
|
-
const filename = splitResult
|
|
40
|
+
const filename = splitResult?.[1];
|
|
43
41
|
if (!filename) {
|
|
44
42
|
return [src.replace(".js", ".css")];
|
|
45
43
|
}
|
|
@@ -53,13 +51,17 @@ function getCurrentScriptUrl(moduleId) {
|
|
|
53
51
|
};
|
|
54
52
|
}
|
|
55
53
|
function updateCss(el, url) {
|
|
54
|
+
let normalizedUrl;
|
|
56
55
|
if (!url) {
|
|
57
56
|
if (!el.href) {
|
|
58
57
|
return;
|
|
59
58
|
}
|
|
60
|
-
|
|
59
|
+
normalizedUrl = el.href.split("?")[0];
|
|
61
60
|
}
|
|
62
|
-
|
|
61
|
+
else {
|
|
62
|
+
normalizedUrl = url;
|
|
63
|
+
}
|
|
64
|
+
if (!isUrlRequest(normalizedUrl)) {
|
|
63
65
|
return;
|
|
64
66
|
}
|
|
65
67
|
if (el.isLoaded === false) {
|
|
@@ -67,7 +69,7 @@ function updateCss(el, url) {
|
|
|
67
69
|
// We're probably changing the same file more than once.
|
|
68
70
|
return;
|
|
69
71
|
}
|
|
70
|
-
if (!
|
|
72
|
+
if (!normalizedUrl || !(normalizedUrl.indexOf(".css") > -1)) {
|
|
71
73
|
return;
|
|
72
74
|
}
|
|
73
75
|
el.visited = true;
|
|
@@ -87,7 +89,7 @@ function updateCss(el, url) {
|
|
|
87
89
|
newEl.isLoaded = true;
|
|
88
90
|
el.parentNode?.removeChild(el);
|
|
89
91
|
});
|
|
90
|
-
newEl.href = `${
|
|
92
|
+
newEl.href = `${normalizedUrl}?${Date.now()}`;
|
|
91
93
|
if (el.nextSibling) {
|
|
92
94
|
el.parentNode?.insertBefore(newEl, el.nextSibling);
|
|
93
95
|
}
|
|
@@ -97,9 +99,9 @@ function updateCss(el, url) {
|
|
|
97
99
|
}
|
|
98
100
|
function getReloadUrl(href, src) {
|
|
99
101
|
let ret = "";
|
|
100
|
-
|
|
102
|
+
const normalizedHref = (0, normalizeUrl_1.normalizeUrl)(href);
|
|
101
103
|
src.some(url => {
|
|
102
|
-
if (
|
|
104
|
+
if (normalizedHref.indexOf(src) > -1) {
|
|
103
105
|
ret = url;
|
|
104
106
|
}
|
|
105
107
|
});
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
declare function normalizeUrl(
|
|
1
|
+
declare function normalizeUrl(url: string): string;
|
|
2
2
|
export { normalizeUrl };
|
|
@@ -1,17 +1,19 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.normalizeUrl = void 0;
|
|
4
|
-
function normalizeUrl(
|
|
5
|
-
urlString =
|
|
4
|
+
function normalizeUrl(url) {
|
|
5
|
+
const urlString = url.trim();
|
|
6
6
|
if (/^data:/i.test(urlString)) {
|
|
7
7
|
return urlString;
|
|
8
8
|
}
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
9
|
+
const protocol = urlString.indexOf("//") !== -1 ? `${urlString.split("//")[0]}//` : "";
|
|
10
|
+
const components = urlString
|
|
11
|
+
.replace(new RegExp(protocol, "i"), "")
|
|
12
|
+
.split("/");
|
|
13
|
+
const host = components[0].toLowerCase().replace(/\.$/, "");
|
|
12
14
|
components[0] = "";
|
|
13
|
-
|
|
14
|
-
.reduce(
|
|
15
|
+
const path = components
|
|
16
|
+
.reduce((accumulator, item) => {
|
|
15
17
|
switch (item) {
|
|
16
18
|
case "..":
|
|
17
19
|
accumulator.pop();
|
|
@@ -6,12 +6,11 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
6
6
|
exports.pitch = exports.hotLoader = exports.SINGLE_DOT_PATH_SEGMENT = exports.ABSOLUTE_PUBLIC_PATH = exports.AUTO_PUBLIC_PATH = exports.MODULE_TYPE = exports.BASE_URI = void 0;
|
|
7
7
|
const node_path_1 = __importDefault(require("node:path"));
|
|
8
8
|
const index_1 = require("./index");
|
|
9
|
-
const loader_options_json_1 = __importDefault(require("./loader-options.json"));
|
|
10
9
|
const utils_1 = require("./utils");
|
|
11
10
|
exports.BASE_URI = "webpack://";
|
|
12
11
|
exports.MODULE_TYPE = "css/mini-extract";
|
|
13
12
|
exports.AUTO_PUBLIC_PATH = "__mini_css_extract_plugin_public_path_auto__";
|
|
14
|
-
exports.ABSOLUTE_PUBLIC_PATH = exports.BASE_URI
|
|
13
|
+
exports.ABSOLUTE_PUBLIC_PATH = `${exports.BASE_URI}/mini-css-extract-plugin/`;
|
|
15
14
|
exports.SINGLE_DOT_PATH_SEGMENT = "__mini_css_extract_plugin_single_dot_path_segment__";
|
|
16
15
|
const SERIALIZE_SEP = "__RSPACK_CSS_EXTRACT_SEP__";
|
|
17
16
|
function hotLoader(content, context) {
|
|
@@ -42,10 +41,7 @@ function hotLoader(content, context) {
|
|
|
42
41
|
}
|
|
43
42
|
exports.hotLoader = hotLoader;
|
|
44
43
|
const loader = function loader(content) {
|
|
45
|
-
if (this._compiler &&
|
|
46
|
-
this._compiler.options &&
|
|
47
|
-
this._compiler.options.experiments &&
|
|
48
|
-
this._compiler.options.experiments.css &&
|
|
44
|
+
if (this._compiler?.options?.experiments?.css &&
|
|
49
45
|
this._module &&
|
|
50
46
|
(this._module.type === "css" ||
|
|
51
47
|
this._module.type === "css/auto" ||
|
|
@@ -55,10 +51,7 @@ const loader = function loader(content) {
|
|
|
55
51
|
}
|
|
56
52
|
};
|
|
57
53
|
const pitch = function (request, _, data) {
|
|
58
|
-
if (this._compiler &&
|
|
59
|
-
this._compiler.options &&
|
|
60
|
-
this._compiler.options.experiments &&
|
|
61
|
-
this._compiler.options.experiments.css &&
|
|
54
|
+
if (this._compiler?.options?.experiments?.css &&
|
|
62
55
|
this._module &&
|
|
63
56
|
(this._module.type === "css" ||
|
|
64
57
|
this._module.type === "css/auto" ||
|
|
@@ -69,7 +62,7 @@ const pitch = function (request, _, data) {
|
|
|
69
62
|
this.emitWarning(e);
|
|
70
63
|
return;
|
|
71
64
|
}
|
|
72
|
-
const options = this.getOptions(
|
|
65
|
+
const options = this.getOptions();
|
|
73
66
|
const emit = typeof options.emit !== "undefined" ? options.emit : true;
|
|
74
67
|
const callback = this.async();
|
|
75
68
|
const filepath = this.resourcePath;
|
|
@@ -122,7 +115,7 @@ const pitch = function (request, _, data) {
|
|
|
122
115
|
}
|
|
123
116
|
}
|
|
124
117
|
else {
|
|
125
|
-
locals = exports
|
|
118
|
+
locals = exports?.locals;
|
|
126
119
|
}
|
|
127
120
|
if (Array.isArray(exports) && emit) {
|
|
128
121
|
const identifierCountMap = new Map();
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
/*
|
|
2
|
-
MIT License http://www.opensource.org/licenses/mit-license.php
|
|
3
|
-
Author Tobias Koppers @sokra
|
|
4
|
-
*/
|
|
5
1
|
"use strict";
|
|
2
|
+
/*
|
|
3
|
+
* MIT License http://www.opensource.org/licenses/mit-license.php
|
|
4
|
+
* Author Tobias Koppers @sokra
|
|
5
|
+
*/
|
|
6
6
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
7
|
exports.moduleImpl = exports.dispose = void 0;
|
|
8
8
|
const getBackend = (options) => (compiler, callback) => {
|
package/dist/config/adapter.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { type
|
|
1
|
+
import { type JsLibraryOptions, type RawOptions } from "@rspack/binding";
|
|
2
2
|
import type { Compiler } from "../Compiler";
|
|
3
3
|
import { type LoaderContext, type LoaderDefinition, type LoaderDefinitionFunction } from "./adapterRuleUse";
|
|
4
4
|
import type { RspackOptionsNormalized } from "./normalization";
|
|
@@ -6,5 +6,5 @@ import type { ChunkLoading, LibraryOptions, Resolve } from "./zod";
|
|
|
6
6
|
export type { LoaderContext, LoaderDefinition, LoaderDefinitionFunction };
|
|
7
7
|
export declare const getRawOptions: (options: RspackOptionsNormalized, compiler: Compiler) => RawOptions;
|
|
8
8
|
export declare function getRawResolve(resolve: Resolve): RawOptions["resolve"];
|
|
9
|
-
export declare function getRawLibrary(library: LibraryOptions):
|
|
9
|
+
export declare function getRawLibrary(library: LibraryOptions): JsLibraryOptions;
|
|
10
10
|
export declare function getRawChunkLoading(chunkLoading: ChunkLoading): string;
|
package/dist/config/adapter.js
CHANGED
|
@@ -129,6 +129,7 @@ function getRawOutput(output) {
|
|
|
129
129
|
crossOriginLoading: getRawCrossOriginLoading(output.crossOriginLoading),
|
|
130
130
|
cssFilename: output.cssFilename,
|
|
131
131
|
cssChunkFilename: output.cssChunkFilename,
|
|
132
|
+
cssHeadDataCompression: output.cssHeadDataCompression,
|
|
132
133
|
hotUpdateChunkFilename: output.hotUpdateChunkFilename,
|
|
133
134
|
hotUpdateMainFilename: output.hotUpdateMainFilename,
|
|
134
135
|
hotUpdateGlobal: output.hotUpdateGlobal,
|
|
@@ -102,12 +102,8 @@ export interface LoaderContext<OptionsType = {}> {
|
|
|
102
102
|
_compilation: Compilation;
|
|
103
103
|
_module: Module;
|
|
104
104
|
}
|
|
105
|
-
export
|
|
106
|
-
|
|
107
|
-
}
|
|
108
|
-
export interface PitchLoaderDefinitionFunction<OptionsType = {}, ContextAdditions = {}> {
|
|
109
|
-
(this: LoaderContext<OptionsType> & ContextAdditions, remainingRequest: string, previousRequest: string, data: object): string | void | Buffer | Promise<string | Buffer>;
|
|
110
|
-
}
|
|
105
|
+
export type LoaderDefinitionFunction<OptionsType = {}, ContextAdditions = {}> = (this: LoaderContext<OptionsType> & ContextAdditions, content: string, sourceMap?: string | SourceMap, additionalData?: AdditionalData) => string | void | Buffer | Promise<string | Buffer>;
|
|
106
|
+
export type PitchLoaderDefinitionFunction<OptionsType = {}, ContextAdditions = {}> = (this: LoaderContext<OptionsType> & ContextAdditions, remainingRequest: string, previousRequest: string, data: object) => string | void | Buffer | Promise<string | Buffer>;
|
|
111
107
|
export type LoaderDefinition<OptionsType = {}, ContextAdditions = {}> = LoaderDefinitionFunction<OptionsType, ContextAdditions> & {
|
|
112
108
|
raw?: false;
|
|
113
109
|
pitch?: PitchLoaderDefinitionFunction;
|
|
@@ -55,7 +55,8 @@ function createRawModuleRuleUsesImpl(uses, path, options) {
|
|
|
55
55
|
return [];
|
|
56
56
|
}
|
|
57
57
|
return uses.map((use, index) => {
|
|
58
|
-
let o
|
|
58
|
+
let o;
|
|
59
|
+
let isBuiltin = false;
|
|
59
60
|
if (use.loader.startsWith(exports.BUILTIN_LOADER_PREFIX)) {
|
|
60
61
|
o = getBuiltinLoaderOptions(use.loader, use.options, options);
|
|
61
62
|
o = (0, util_1.isNil)(o) ? undefined : typeof o === "string" ? o : JSON.stringify(o);
|
|
@@ -75,15 +76,15 @@ function resolveStringifyLoaders(use, path, compiler, isBuiltin) {
|
|
|
75
76
|
else if (use.options === undefined) {
|
|
76
77
|
}
|
|
77
78
|
else if (typeof use.options === "string")
|
|
78
|
-
obj.query =
|
|
79
|
+
obj.query = `?${use.options}`;
|
|
79
80
|
else if (use.ident)
|
|
80
|
-
obj.query =
|
|
81
|
+
obj.query = `??${(ident = use.ident)}`;
|
|
81
82
|
else if (typeof use.options === "object" && use.options.ident)
|
|
82
|
-
obj.query =
|
|
83
|
+
obj.query = `??${(ident = use.options.ident)}`;
|
|
83
84
|
else if (typeof use.options === "object")
|
|
84
|
-
obj.query =
|
|
85
|
+
obj.query = `??${(ident = path)}`;
|
|
85
86
|
else
|
|
86
|
-
obj.query =
|
|
87
|
+
obj.query = `?${JSON.stringify(use.options)}`;
|
|
87
88
|
if (use.options && typeof use.options === "object") {
|
|
88
89
|
if (!ident)
|
|
89
90
|
ident = "[[missing ident]]";
|
package/dist/config/defaults.js
CHANGED
|
@@ -403,8 +403,9 @@ const applyOutputDefaults = (output, { context, outputModule, targetProperties:
|
|
|
403
403
|
D(output, "hotUpdateChunkFilename", `[id].[fullhash].hot-update.${output.module ? "mjs" : "js"}`);
|
|
404
404
|
D(output, "hotUpdateMainFilename", "[runtime].[fullhash].hot-update.json");
|
|
405
405
|
const uniqueNameId = Template_1.Template.toIdentifier(output.uniqueName);
|
|
406
|
-
F(output, "hotUpdateGlobal", () =>
|
|
407
|
-
F(output, "chunkLoadingGlobal", () =>
|
|
406
|
+
F(output, "hotUpdateGlobal", () => `webpackHotUpdate${uniqueNameId}`);
|
|
407
|
+
F(output, "chunkLoadingGlobal", () => `webpackChunk${uniqueNameId}`);
|
|
408
|
+
D(output, "cssHeadDataCompression", !development);
|
|
408
409
|
D(output, "assetModuleFilename", "[hash][ext][query]");
|
|
409
410
|
D(output, "webassemblyModuleFilename", "[hash].module.wasm");
|
|
410
411
|
F(output, "path", () => node_path_1.default.join(process.cwd(), "dist"));
|
|
@@ -427,10 +428,7 @@ const applyOutputDefaults = (output, { context, outputModule, targetProperties:
|
|
|
427
428
|
return "module";
|
|
428
429
|
if (tp.document)
|
|
429
430
|
return "array-push";
|
|
430
|
-
throw new Error(
|
|
431
|
-
"ESM exports can be chosen when 'import()' is available.\n" +
|
|
432
|
-
"JSONP Array push can be chosen when 'document' is available.\n" +
|
|
433
|
-
helpMessage);
|
|
431
|
+
throw new Error(`For the selected environment is no default ESM chunk format available:\nESM exports can be chosen when 'import()' is available.\nJSONP Array push can be chosen when 'document' is available.\n${helpMessage}`);
|
|
434
432
|
}
|
|
435
433
|
if (tp.document)
|
|
436
434
|
return "array-push";
|
|
@@ -440,10 +438,7 @@ const applyOutputDefaults = (output, { context, outputModule, targetProperties:
|
|
|
440
438
|
return "commonjs";
|
|
441
439
|
if (tp.importScripts)
|
|
442
440
|
return "array-push";
|
|
443
|
-
throw new Error(
|
|
444
|
-
"JSONP Array push can be chosen when 'document' or 'importScripts' is available.\n" +
|
|
445
|
-
"CommonJs exports can be chosen when 'require' or node builtins are available.\n" +
|
|
446
|
-
helpMessage);
|
|
441
|
+
throw new Error(`For the selected environment is no default script chunk format available:\nJSONP Array push can be chosen when 'document' or 'importScripts' is available.\nCommonJs exports can be chosen when 'require' or node builtins are available.\n${helpMessage}`);
|
|
447
442
|
}
|
|
448
443
|
throw new Error("Chunk format can't be selected by default when no target is specified");
|
|
449
444
|
});
|
|
@@ -592,8 +587,8 @@ const applyOutputDefaults = (output, { context, outputModule, targetProperties:
|
|
|
592
587
|
const environment = output.environment;
|
|
593
588
|
const optimistic = (v) => v || v === undefined;
|
|
594
589
|
const conditionallyOptimistic = (v, c) => (v === undefined && c) || v;
|
|
595
|
-
F(environment, "globalThis", () => tp
|
|
596
|
-
F(environment, "bigIntLiteral", () => tp
|
|
590
|
+
F(environment, "globalThis", () => tp?.globalThis);
|
|
591
|
+
F(environment, "bigIntLiteral", () => tp?.bigIntLiteral);
|
|
597
592
|
F(environment, "const", () => tp && optimistic(tp.const));
|
|
598
593
|
F(environment, "arrowFunction", () => tp && optimistic(tp.arrowFunction));
|
|
599
594
|
F(environment, "asyncFunction", () => tp && optimistic(tp.asyncFunction));
|
|
@@ -602,25 +597,19 @@ const applyOutputDefaults = (output, { context, outputModule, targetProperties:
|
|
|
602
597
|
F(environment, "optionalChaining", () => tp && optimistic(tp.optionalChaining));
|
|
603
598
|
F(environment, "nodePrefixForCoreModules", () => tp && optimistic(tp.nodePrefixForCoreModules));
|
|
604
599
|
F(environment, "templateLiteral", () => tp && optimistic(tp.templateLiteral));
|
|
605
|
-
F(environment, "dynamicImport", () => conditionallyOptimistic(tp
|
|
606
|
-
F(environment, "dynamicImportInWorker", () => conditionallyOptimistic(tp
|
|
607
|
-
F(environment, "module", () => conditionallyOptimistic(tp
|
|
600
|
+
F(environment, "dynamicImport", () => conditionallyOptimistic(tp?.dynamicImport, output.module));
|
|
601
|
+
F(environment, "dynamicImportInWorker", () => conditionallyOptimistic(tp?.dynamicImportInWorker, output.module));
|
|
602
|
+
F(environment, "module", () => conditionallyOptimistic(tp?.module, output.module));
|
|
608
603
|
F(environment, "document", () => tp && optimistic(tp.document));
|
|
609
604
|
};
|
|
610
605
|
const applyExternalsPresetsDefaults = (externalsPresets, { targetProperties }) => {
|
|
611
|
-
D(externalsPresets, "web", targetProperties
|
|
612
|
-
D(externalsPresets, "node", targetProperties
|
|
613
|
-
D(externalsPresets, "electron", targetProperties
|
|
614
|
-
D(externalsPresets, "electronMain", targetProperties &&
|
|
615
|
-
|
|
616
|
-
|
|
617
|
-
D(externalsPresets, "
|
|
618
|
-
targetProperties.electron &&
|
|
619
|
-
targetProperties.electronPreload);
|
|
620
|
-
D(externalsPresets, "electronRenderer", targetProperties &&
|
|
621
|
-
targetProperties.electron &&
|
|
622
|
-
targetProperties.electronRenderer);
|
|
623
|
-
D(externalsPresets, "nwjs", targetProperties && targetProperties.nwjs);
|
|
606
|
+
D(externalsPresets, "web", targetProperties?.web);
|
|
607
|
+
D(externalsPresets, "node", targetProperties?.node);
|
|
608
|
+
D(externalsPresets, "electron", targetProperties?.electron);
|
|
609
|
+
D(externalsPresets, "electronMain", targetProperties?.electron && targetProperties.electronMain);
|
|
610
|
+
D(externalsPresets, "electronPreload", targetProperties?.electron && targetProperties.electronPreload);
|
|
611
|
+
D(externalsPresets, "electronRenderer", targetProperties?.electron && targetProperties.electronRenderer);
|
|
612
|
+
D(externalsPresets, "nwjs", targetProperties?.nwjs);
|
|
624
613
|
};
|
|
625
614
|
const applyLoaderDefaults = (loader, { targetProperties, environment }) => {
|
|
626
615
|
F(loader, "target", () => {
|
|
@@ -649,19 +638,19 @@ const applyNodeDefaults = (node, { targetProperties }) => {
|
|
|
649
638
|
return;
|
|
650
639
|
// IGNORE(node.global): The default value of `global` is determined by `futureDefaults` in webpack.
|
|
651
640
|
F(node, "global", () => {
|
|
652
|
-
if (targetProperties
|
|
641
|
+
if (targetProperties?.global)
|
|
653
642
|
return false;
|
|
654
643
|
return "warn";
|
|
655
644
|
});
|
|
656
645
|
// IGNORE(node.__dirname): The default value of `__dirname` is determined by `futureDefaults` in webpack.
|
|
657
646
|
F(node, "__dirname", () => {
|
|
658
|
-
if (targetProperties
|
|
647
|
+
if (targetProperties?.node)
|
|
659
648
|
return "eval-only";
|
|
660
649
|
return "warn-mock";
|
|
661
650
|
});
|
|
662
651
|
// IGNORE(node.__filename): The default value of `__filename` is determined by `futureDefaults` in webpack.
|
|
663
652
|
F(node, "__filename", () => {
|
|
664
|
-
if (targetProperties
|
|
653
|
+
if (targetProperties?.node)
|
|
665
654
|
return "eval-only";
|
|
666
655
|
return "warn-mock";
|
|
667
656
|
});
|
|
@@ -772,7 +761,7 @@ const getResolveDefaults = ({ context, targetProperties, mode, css }) => {
|
|
|
772
761
|
}
|
|
773
762
|
const jsExtensions = [".js", ".json", ".wasm"];
|
|
774
763
|
const tp = targetProperties;
|
|
775
|
-
const browserField = tp
|
|
764
|
+
const browserField = tp?.web && (!tp.node || (tp.electron && tp.electronRenderer));
|
|
776
765
|
const aliasFields = browserField ? ["browser"] : [];
|
|
777
766
|
const mainFields = browserField
|
|
778
767
|
? ["browser", "module", "..."]
|
|
@@ -54,6 +54,7 @@ const getNormalizedRspackOptions = (config) => {
|
|
|
54
54
|
chunkLoading: output.chunkLoading,
|
|
55
55
|
chunkFilename: output.chunkFilename,
|
|
56
56
|
crossOriginLoading: output.crossOriginLoading,
|
|
57
|
+
cssHeadDataCompression: output.cssHeadDataCompression,
|
|
57
58
|
cssFilename: output.cssFilename,
|
|
58
59
|
cssChunkFilename: output.cssChunkFilename,
|
|
59
60
|
hotUpdateMainFilename: output.hotUpdateMainFilename,
|
|
@@ -282,8 +283,10 @@ const cloneObject = (value) => ({ ...value });
|
|
|
282
283
|
const keyedNestedConfig = (value, fn, customKeys) => {
|
|
283
284
|
const result = value === undefined
|
|
284
285
|
? {}
|
|
285
|
-
: Object.keys(value).reduce((obj, key) =>
|
|
286
|
-
obj
|
|
286
|
+
: Object.keys(value).reduce((obj, key) => {
|
|
287
|
+
obj[key] = (customKeys && key in customKeys ? customKeys[key] : fn)(value[key]);
|
|
288
|
+
return obj;
|
|
289
|
+
}, {});
|
|
287
290
|
if (customKeys) {
|
|
288
291
|
for (const key of Object.keys(customKeys)) {
|
|
289
292
|
if (!(key in result)) {
|