@rspack/core 1.0.0-alpha.5 → 1.0.0-beta.1
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/compiled/zod/index.d.ts +138 -52
- package/compiled/zod/index.js +300 -103
- package/compiled/zod/package.json +1 -1
- package/compiled/zod-validation-error/index.js +6 -6
- package/dist/Compilation.d.ts +22 -4
- package/dist/Compilation.js +64 -49
- package/dist/Compiler.d.ts +11 -10
- package/dist/Compiler.js +42 -42
- package/dist/ErrorHelpers.js +2 -4
- package/dist/Module.d.ts +1 -0
- package/dist/Module.js +3 -6
- package/dist/ModuleTypeConstants.d.ts +45 -69
- package/dist/ModuleTypeConstants.js +24 -77
- package/dist/NormalModule.d.ts +1 -0
- package/dist/NormalModule.js +1 -0
- package/dist/Stats.js +4 -6
- package/dist/Template.d.ts +31 -147
- package/dist/Template.js +40 -236
- package/dist/builtin-loader/lightningcss/index.d.ts +89 -0
- package/dist/builtin-loader/lightningcss/index.js +175 -0
- package/dist/builtin-plugin/APIPlugin.d.ts +1 -1
- package/dist/builtin-plugin/ArrayPushCallbackChunkFormatPlugin.d.ts +1 -1
- package/dist/builtin-plugin/AssetModulesPlugin.d.ts +1 -1
- package/dist/builtin-plugin/AsyncWebAssemblyModulesPlugin.d.ts +1 -1
- package/dist/builtin-plugin/BannerPlugin.d.ts +25 -49
- package/dist/builtin-plugin/BundlerInfoRspackPlugin.d.ts +1 -1
- package/dist/builtin-plugin/ChunkPrefetchPreloadPlugin.d.ts +1 -1
- package/dist/builtin-plugin/CommonJsChunkFormatPlugin.d.ts +1 -1
- package/dist/builtin-plugin/CopyRspackPlugin.d.ts +1 -1
- package/dist/builtin-plugin/CssModulesPlugin.d.ts +1 -1
- package/dist/builtin-plugin/DataUriPlugin.d.ts +1 -1
- package/dist/builtin-plugin/DefinePlugin.d.ts +1 -1
- package/dist/builtin-plugin/DefinePlugin.js +9 -13
- package/dist/builtin-plugin/DeterministicChunkIdsPlugin.d.ts +1 -1
- package/dist/builtin-plugin/DeterministicModuleIdsPlugin.d.ts +1 -1
- package/dist/builtin-plugin/DynamicEntryPlugin.d.ts +1 -1
- package/dist/builtin-plugin/ElectronTargetPlugin.d.ts +1 -1
- package/dist/builtin-plugin/EnableChunkLoadingPlugin.d.ts +1 -1
- package/dist/builtin-plugin/EnableWasmLoadingPlugin.d.ts +1 -1
- package/dist/builtin-plugin/EnsureChunkConditionsPlugin.d.ts +1 -1
- package/dist/builtin-plugin/EntryPlugin.d.ts +4 -3
- package/dist/builtin-plugin/EntryPlugin.js +1 -0
- package/dist/builtin-plugin/EvalDevToolModulePlugin.d.ts +1 -1
- package/dist/builtin-plugin/EvalSourceMapDevToolPlugin.d.ts +1 -1
- package/dist/builtin-plugin/ExternalsPlugin.d.ts +29 -5
- package/dist/builtin-plugin/FetchCompileAsyncWasmPlugin.d.ts +1 -1
- package/dist/builtin-plugin/FileUriPlugin.d.ts +1 -1
- package/dist/builtin-plugin/FlagDependencyExportsPlugin.d.ts +1 -1
- package/dist/builtin-plugin/FlagDependencyUsagePlugin.d.ts +1 -1
- package/dist/builtin-plugin/HtmlRspackPlugin.d.ts +9 -9
- package/dist/builtin-plugin/HttpExternalsRspackPlugin.d.ts +1 -1
- package/dist/builtin-plugin/IgnorePlugin.d.ts +1 -1
- package/dist/builtin-plugin/InferAsyncModulesPlugin.d.ts +1 -1
- package/dist/builtin-plugin/JavascriptModulesPlugin.d.ts +2 -2
- package/dist/builtin-plugin/JsLoaderRspackPlugin.d.ts +1 -1
- package/dist/builtin-plugin/JsonModulesPlugin.d.ts +1 -1
- package/dist/builtin-plugin/LightningCssMiminizerRspackPlugin.d.ts +1 -1
- package/dist/builtin-plugin/LightningCssMiminizerRspackPlugin.js +4 -1
- package/dist/builtin-plugin/LimitChunkCountPlugin.d.ts +1 -1
- package/dist/builtin-plugin/MangleExportsPlugin.d.ts +1 -1
- package/dist/builtin-plugin/MergeDuplicateChunksPlugin.d.ts +1 -1
- package/dist/builtin-plugin/ModuleChunkFormatPlugin.d.ts +1 -1
- package/dist/builtin-plugin/ModuleConcatenationPlugin.d.ts +1 -1
- package/dist/builtin-plugin/NamedChunkIdsPlugin.d.ts +1 -1
- package/dist/builtin-plugin/NamedModuleIdsPlugin.d.ts +1 -1
- package/dist/builtin-plugin/NaturalChunkIdsPlugin.d.ts +1 -1
- package/dist/builtin-plugin/NaturalModuleIdsPlugin.d.ts +1 -1
- package/dist/builtin-plugin/NodeTargetPlugin.d.ts +1 -1
- package/dist/builtin-plugin/ProgressPlugin.d.ts +1 -1
- package/dist/builtin-plugin/ProvidePlugin.d.ts +1 -1
- package/dist/builtin-plugin/RealContentHashPlugin.d.ts +1 -1
- package/dist/builtin-plugin/RemoveEmptyChunksPlugin.d.ts +1 -1
- package/dist/builtin-plugin/RuntimeChunkPlugin.d.ts +1 -1
- package/dist/builtin-plugin/RuntimePlugin.d.ts +1 -1
- package/dist/builtin-plugin/SideEffectsFlagPlugin.d.ts +1 -1
- package/dist/builtin-plugin/SizeLimitsPlugin.d.ts +1 -1
- package/dist/builtin-plugin/SourceMapDevToolPlugin.d.ts +1 -1
- package/dist/builtin-plugin/SplitChunksPlugin.js +5 -15
- package/dist/builtin-plugin/SwcCssMinimizerPlugin.d.ts +1 -1
- package/dist/builtin-plugin/SwcJsMinimizerPlugin.d.ts +1 -1
- package/dist/builtin-plugin/SwcJsMinimizerPlugin.js +15 -23
- package/dist/builtin-plugin/WarnCaseSensitiveModulesPlugin.d.ts +1 -1
- package/dist/builtin-plugin/WebWorkerTemplatePlugin.d.ts +1 -1
- package/dist/builtin-plugin/base.d.ts +1 -1
- package/dist/builtin-plugin/base.js +1 -3
- package/dist/builtin-plugin/css-extract/hmr/hotModuleReplacement.d.ts +3 -3
- package/dist/builtin-plugin/css-extract/hmr/hotModuleReplacement.js +17 -66
- package/dist/builtin-plugin/css-extract/hmr/normalizeUrl.d.ts +2 -0
- package/dist/builtin-plugin/css-extract/hmr/{normalize-url.js → normalizeUrl.js} +15 -24
- package/dist/builtin-plugin/css-extract/loader.d.ts +8 -3
- package/dist/builtin-plugin/css-extract/loader.js +28 -17
- package/dist/builtin-plugin/lazy-compilation/lazyCompilation.d.ts +1 -1
- package/dist/config/adapter.d.ts +1 -1
- package/dist/config/adapter.js +39 -25
- package/dist/config/adapterRuleUse.d.ts +5 -5
- package/dist/config/adapterRuleUse.js +23 -1
- package/dist/config/browserslistTargetHandler.d.ts +17 -15
- package/dist/config/browserslistTargetHandler.js +27 -33
- package/dist/config/defaults.js +27 -31
- package/dist/config/normalization.d.ts +8 -3
- package/dist/config/normalization.js +7 -5
- package/dist/config/target.d.ts +48 -109
- package/dist/config/target.js +50 -86
- package/dist/config/zod.d.ts +2660 -2305
- package/dist/config/zod.js +38 -19
- package/dist/container/ContainerPlugin.d.ts +7 -7
- package/dist/container/ContainerReferencePlugin.d.ts +1 -1
- package/dist/container/ModuleFederationRuntimePlugin.d.ts +1 -1
- package/dist/container/options.js +1 -1
- package/dist/exports.d.ts +4 -4
- package/dist/exports.js +2 -2
- package/dist/lib/AbstractMethodError.d.ts +12 -3
- package/dist/lib/AbstractMethodError.js +29 -21
- package/dist/lib/Cache.d.ts +40 -46
- package/dist/lib/Cache.js +43 -78
- package/dist/lib/CacheFacade.d.ts +119 -143
- package/dist/lib/CacheFacade.js +123 -123
- package/dist/lib/EntryOptionPlugin.d.ts +19 -2
- package/dist/lib/EntryOptionPlugin.js +22 -6
- package/dist/lib/EnvironmentPlugin.d.ts +17 -10
- package/dist/lib/EnvironmentPlugin.js +16 -15
- package/dist/lib/HookWebpackError.d.ts +27 -33
- package/dist/lib/HookWebpackError.js +33 -34
- package/dist/lib/IgnoreWarningsPlugin.d.ts +25 -0
- package/dist/lib/{ignoreWarningsPlugin.js → IgnoreWarningsPlugin.js} +17 -0
- package/dist/lib/LoaderOptionsPlugin.d.ts +18 -9
- package/dist/lib/LoaderOptionsPlugin.js +38 -14
- package/dist/lib/LoaderTargetPlugin.d.ts +17 -8
- package/dist/lib/LoaderTargetPlugin.js +17 -15
- package/dist/lib/ModuleFilenameHelpers.d.ts +10 -1
- package/dist/lib/ModuleFilenameHelpers.js +10 -3
- package/dist/lib/NormalModuleReplacementPlugin.d.ts +15 -5
- package/dist/lib/NormalModuleReplacementPlugin.js +15 -5
- package/dist/lib/WebpackError.d.ts +29 -22
- package/dist/lib/WebpackError.js +17 -29
- package/dist/lib/cache/getLazyHashedEtag.d.ts +24 -24
- package/dist/lib/cache/getLazyHashedEtag.js +20 -23
- package/dist/lib/cache/mergeEtags.d.ts +15 -9
- package/dist/lib/cache/mergeEtags.js +23 -22
- package/dist/lib/formatLocation.d.ts +13 -8
- package/dist/lib/formatLocation.js +20 -20
- package/dist/loader-runner/LoaderLoadingError.d.ts +11 -1
- package/dist/loader-runner/LoaderLoadingError.js +3 -5
- package/dist/loader-runner/index.js +7 -9
- package/dist/loader-runner/loadLoader.d.ts +11 -2
- package/dist/loader-runner/loadLoader.js +17 -19
- package/dist/logging/createConsoleLogger.js +2 -6
- package/dist/logging/truncateArgs.js +5 -9
- package/dist/node/nodeConsole.js +1 -3
- package/dist/rspackOptionsApply.js +2 -2
- package/dist/stats/DefaultStatsFactoryPlugin.js +18 -8
- package/dist/stats/DefaultStatsPresetPlugin.js +4 -4
- package/dist/stats/DefaultStatsPrinterPlugin.js +11 -16
- package/dist/stats/StatsFactory.js +13 -17
- package/dist/stats/StatsPrinter.js +7 -9
- package/dist/util/AssetInfo.js +11 -7
- package/dist/util/SplitChunkSize.js +1 -1
- package/dist/util/cleverMerge.d.ts +33 -57
- package/dist/util/cleverMerge.js +89 -145
- package/dist/util/comparators.d.ts +1 -1
- package/dist/util/comparators.js +3 -5
- package/dist/util/createHash.d.ts +4 -3
- package/dist/util/createHash.js +31 -45
- package/dist/util/fs.js +9 -13
- package/dist/util/hash/BatchedHash.d.ts +24 -9
- package/dist/util/hash/BatchedHash.js +16 -13
- package/dist/util/hash/index.d.ts +9 -9
- package/dist/util/hash/index.js +14 -11
- package/dist/util/hash/md4.d.ts +29 -2
- package/dist/util/hash/md4.js +7 -3
- package/dist/util/hash/wasm-hash.d.ts +52 -5
- package/dist/util/hash/wasm-hash.js +19 -22
- package/dist/util/hash/xxhash64.d.ts +29 -2
- package/dist/util/hash/xxhash64.js +7 -3
- package/dist/util/identifier.js +9 -15
- package/dist/util/index.js +1 -1
- package/dist/util/memoize.js +7 -9
- package/package.json +9 -8
- package/compiled/enhanced-resolve/index.js +0 -5566
- package/dist/builtin-plugin/css-extract/hmr/normalize-url.d.ts +0 -2
- package/dist/lib/ignoreWarningsPlugin.d.ts +0 -7
|
@@ -14,7 +14,7 @@ export declare function create<T extends any[], R>(name: binding.BuiltinPluginNa
|
|
|
14
14
|
new (...args: T): {
|
|
15
15
|
name: binding.BuiltinPluginName;
|
|
16
16
|
_args: T;
|
|
17
|
-
affectedHooks: "done" | "
|
|
17
|
+
affectedHooks: "done" | "make" | "compile" | "emit" | "afterEmit" | "invalid" | "thisCompilation" | "afterDone" | "compilation" | "normalModuleFactory" | "contextModuleFactory" | "initialize" | "shouldEmit" | "infrastructureLog" | "beforeRun" | "run" | "assetEmitted" | "failed" | "shutdown" | "watchRun" | "watchClose" | "environment" | "afterEnvironment" | "afterPlugins" | "afterResolvers" | "beforeCompile" | "afterCompile" | "finishMake" | "entryOption" | undefined;
|
|
18
18
|
raw(compiler: Compiler): binding.BuiltinPlugin;
|
|
19
19
|
apply(compiler: Compiler): void;
|
|
20
20
|
};
|
|
@@ -15,9 +15,7 @@ function canInherentFromParent(affectedHooks) {
|
|
|
15
15
|
// this arm should be removed
|
|
16
16
|
return false;
|
|
17
17
|
}
|
|
18
|
-
|
|
19
|
-
return !exports.HOOKS_CAN_NOT_INHERENT_FROM_PARENT.includes(affectedHooks);
|
|
20
|
-
}
|
|
18
|
+
return !exports.HOOKS_CAN_NOT_INHERENT_FROM_PARENT.includes(affectedHooks);
|
|
21
19
|
}
|
|
22
20
|
exports.canInherentFromParent = canInherentFromParent;
|
|
23
21
|
class RspackBuiltinPlugin {
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
declare function
|
|
2
|
-
|
|
3
|
-
export
|
|
1
|
+
declare function noop(): void;
|
|
2
|
+
declare function cssReload(moduleId: string, options: Record<string, any>): typeof noop;
|
|
3
|
+
export { cssReload };
|
|
@@ -1,45 +1,29 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
no-console,
|
|
6
|
-
func-names
|
|
7
|
-
*/
|
|
8
|
-
/** @typedef {any} TODO */
|
|
9
|
-
const normalizeUrl = require("./normalize-url");
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.cssReload = void 0;
|
|
4
|
+
const normalizeUrl_1 = require("./normalizeUrl");
|
|
10
5
|
const srcByModuleId = Object.create(null);
|
|
11
6
|
const noDocument = typeof document === "undefined";
|
|
12
7
|
const { forEach } = Array.prototype;
|
|
13
|
-
/**
|
|
14
|
-
* @param {function} fn
|
|
15
|
-
* @param {number} time
|
|
16
|
-
* @returns {(function(): void)|*}
|
|
17
|
-
*/
|
|
18
8
|
function debounce(fn, time) {
|
|
19
9
|
let timeout = 0;
|
|
20
10
|
return function () {
|
|
21
11
|
// @ts-ignore
|
|
22
12
|
const self = this;
|
|
23
|
-
// eslint-disable-next-line prefer-rest-params
|
|
24
13
|
const args = arguments;
|
|
25
14
|
const functionCall = function functionCall() {
|
|
26
15
|
return fn.apply(self, args);
|
|
27
16
|
};
|
|
28
17
|
clearTimeout(timeout);
|
|
29
|
-
// @ts-ignore
|
|
30
18
|
timeout = setTimeout(functionCall, time);
|
|
31
19
|
};
|
|
32
20
|
}
|
|
33
21
|
function noop() { }
|
|
34
|
-
/**
|
|
35
|
-
* @param {TODO} moduleId
|
|
36
|
-
* @returns {TODO}
|
|
37
|
-
*/
|
|
38
22
|
function getCurrentScriptUrl(moduleId) {
|
|
39
23
|
let src = srcByModuleId[moduleId];
|
|
40
24
|
if (!src) {
|
|
41
25
|
if (document.currentScript) {
|
|
42
|
-
({ src } =
|
|
26
|
+
({ src } = document.currentScript);
|
|
43
27
|
}
|
|
44
28
|
else {
|
|
45
29
|
const scripts = document.getElementsByTagName("script");
|
|
@@ -50,10 +34,6 @@ function getCurrentScriptUrl(moduleId) {
|
|
|
50
34
|
}
|
|
51
35
|
srcByModuleId[moduleId] = src;
|
|
52
36
|
}
|
|
53
|
-
/**
|
|
54
|
-
* @param {string} fileMap
|
|
55
|
-
* @returns {null | string[]}
|
|
56
|
-
*/
|
|
57
37
|
return function (fileMap) {
|
|
58
38
|
if (!src) {
|
|
59
39
|
return null;
|
|
@@ -68,23 +48,18 @@ function getCurrentScriptUrl(moduleId) {
|
|
|
68
48
|
}
|
|
69
49
|
return fileMap.split(",").map(mapRule => {
|
|
70
50
|
const reg = new RegExp(`${filename}\\.js$`, "g");
|
|
71
|
-
return normalizeUrl(src.replace(reg, `${mapRule.replace(/{fileName}/g, filename)}.css`));
|
|
51
|
+
return (0, normalizeUrl_1.normalizeUrl)(src.replace(reg, `${mapRule.replace(/{fileName}/g, filename)}.css`));
|
|
72
52
|
});
|
|
73
53
|
};
|
|
74
54
|
}
|
|
75
|
-
/**
|
|
76
|
-
* @param {TODO} el
|
|
77
|
-
* @param {string} [url]
|
|
78
|
-
*/
|
|
79
55
|
function updateCss(el, url) {
|
|
80
56
|
if (!url) {
|
|
81
57
|
if (!el.href) {
|
|
82
58
|
return;
|
|
83
59
|
}
|
|
84
|
-
// eslint-disable-next-line
|
|
85
60
|
url = el.href.split("?")[0];
|
|
86
61
|
}
|
|
87
|
-
if (!isUrlRequest(
|
|
62
|
+
if (!isUrlRequest(url)) {
|
|
88
63
|
return;
|
|
89
64
|
}
|
|
90
65
|
if (el.isLoaded === false) {
|
|
@@ -95,7 +70,6 @@ function updateCss(el, url) {
|
|
|
95
70
|
if (!url || !(url.indexOf(".css") > -1)) {
|
|
96
71
|
return;
|
|
97
72
|
}
|
|
98
|
-
// eslint-disable-next-line no-param-reassign
|
|
99
73
|
el.visited = true;
|
|
100
74
|
const newEl = el.cloneNode();
|
|
101
75
|
newEl.isLoaded = false;
|
|
@@ -104,48 +78,33 @@ function updateCss(el, url) {
|
|
|
104
78
|
return;
|
|
105
79
|
}
|
|
106
80
|
newEl.isLoaded = true;
|
|
107
|
-
el.parentNode
|
|
81
|
+
el.parentNode?.removeChild(el);
|
|
108
82
|
});
|
|
109
83
|
newEl.addEventListener("error", () => {
|
|
110
84
|
if (newEl.isLoaded) {
|
|
111
85
|
return;
|
|
112
86
|
}
|
|
113
87
|
newEl.isLoaded = true;
|
|
114
|
-
el.parentNode
|
|
88
|
+
el.parentNode?.removeChild(el);
|
|
115
89
|
});
|
|
116
90
|
newEl.href = `${url}?${Date.now()}`;
|
|
117
91
|
if (el.nextSibling) {
|
|
118
|
-
el.parentNode
|
|
92
|
+
el.parentNode?.insertBefore(newEl, el.nextSibling);
|
|
119
93
|
}
|
|
120
94
|
else {
|
|
121
|
-
el.parentNode
|
|
95
|
+
el.parentNode?.appendChild(newEl);
|
|
122
96
|
}
|
|
123
97
|
}
|
|
124
|
-
/**
|
|
125
|
-
* @param {string} href
|
|
126
|
-
* @param {TODO} src
|
|
127
|
-
* @returns {TODO}
|
|
128
|
-
*/
|
|
129
98
|
function getReloadUrl(href, src) {
|
|
130
|
-
let ret;
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
src.some(
|
|
134
|
-
/**
|
|
135
|
-
* @param {string} url
|
|
136
|
-
*/
|
|
137
|
-
// eslint-disable-next-line array-callback-return
|
|
138
|
-
url => {
|
|
99
|
+
let ret = "";
|
|
100
|
+
href = (0, normalizeUrl_1.normalizeUrl)(href);
|
|
101
|
+
src.some(url => {
|
|
139
102
|
if (href.indexOf(src) > -1) {
|
|
140
103
|
ret = url;
|
|
141
104
|
}
|
|
142
105
|
});
|
|
143
106
|
return ret;
|
|
144
107
|
}
|
|
145
|
-
/**
|
|
146
|
-
* @param {string} [src]
|
|
147
|
-
* @returns {boolean}
|
|
148
|
-
*/
|
|
149
108
|
function reloadStyle(src) {
|
|
150
109
|
if (!src) {
|
|
151
110
|
return false;
|
|
@@ -179,10 +138,6 @@ function reloadAll() {
|
|
|
179
138
|
updateCss(el);
|
|
180
139
|
});
|
|
181
140
|
}
|
|
182
|
-
/**
|
|
183
|
-
* @param {string} url
|
|
184
|
-
* @returns {boolean}
|
|
185
|
-
*/
|
|
186
141
|
function isUrlRequest(url) {
|
|
187
142
|
// An URL is not an request if
|
|
188
143
|
// It is not http or https
|
|
@@ -191,12 +146,7 @@ function isUrlRequest(url) {
|
|
|
191
146
|
}
|
|
192
147
|
return true;
|
|
193
148
|
}
|
|
194
|
-
|
|
195
|
-
* @param {TODO} moduleId
|
|
196
|
-
* @param {TODO} options
|
|
197
|
-
* @returns {TODO}
|
|
198
|
-
*/
|
|
199
|
-
module.exports = function (moduleId, options) {
|
|
149
|
+
function cssReload(moduleId, options) {
|
|
200
150
|
if (noDocument) {
|
|
201
151
|
console.log("no window.document found, will not HMR CSS");
|
|
202
152
|
return noop;
|
|
@@ -211,7 +161,7 @@ module.exports = function (moduleId, options) {
|
|
|
211
161
|
return;
|
|
212
162
|
}
|
|
213
163
|
if (reloaded) {
|
|
214
|
-
console.log("[HMR] css reload %s", src
|
|
164
|
+
console.log("[HMR] css reload %s", src?.join(" "));
|
|
215
165
|
}
|
|
216
166
|
else {
|
|
217
167
|
console.log("[HMR] Reload all css");
|
|
@@ -219,4 +169,5 @@ module.exports = function (moduleId, options) {
|
|
|
219
169
|
}
|
|
220
170
|
}
|
|
221
171
|
return debounce(update, 50);
|
|
222
|
-
}
|
|
172
|
+
}
|
|
173
|
+
exports.cssReload = cssReload;
|
|
@@ -1,11 +1,16 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.normalizeUrl = void 0;
|
|
4
|
+
function normalizeUrl(urlString) {
|
|
5
|
+
urlString = urlString.trim();
|
|
6
|
+
if (/^data:/i.test(urlString)) {
|
|
7
|
+
return urlString;
|
|
8
|
+
}
|
|
9
|
+
var protocol = urlString.indexOf("//") !== -1 ? urlString.split("//")[0] + "//" : "";
|
|
10
|
+
var components = urlString.replace(new RegExp(protocol, "i"), "").split("/");
|
|
11
|
+
var host = components[0].toLowerCase().replace(/\.$/, "");
|
|
12
|
+
components[0] = "";
|
|
13
|
+
var path = components
|
|
9
14
|
.reduce(function (accumulator, item) {
|
|
10
15
|
switch (item) {
|
|
11
16
|
case "..":
|
|
@@ -17,22 +22,8 @@ function normalizeUrl(pathComponents) {
|
|
|
17
22
|
accumulator.push(item);
|
|
18
23
|
}
|
|
19
24
|
return accumulator;
|
|
20
|
-
},
|
|
25
|
+
}, [])
|
|
21
26
|
.join("/");
|
|
22
|
-
}
|
|
23
|
-
/**
|
|
24
|
-
* @param {string} urlString
|
|
25
|
-
* @returns {string}
|
|
26
|
-
*/
|
|
27
|
-
module.exports = function (urlString) {
|
|
28
|
-
urlString = urlString.trim();
|
|
29
|
-
if (/^data:/i.test(urlString)) {
|
|
30
|
-
return urlString;
|
|
31
|
-
}
|
|
32
|
-
var protocol = urlString.indexOf("//") !== -1 ? urlString.split("//")[0] + "//" : "";
|
|
33
|
-
var components = urlString.replace(new RegExp(protocol, "i"), "").split("/");
|
|
34
|
-
var host = components[0].toLowerCase().replace(/\.$/, "");
|
|
35
|
-
components[0] = "";
|
|
36
|
-
var path = normalizeUrl(components);
|
|
37
27
|
return protocol + host + path;
|
|
38
|
-
}
|
|
28
|
+
}
|
|
29
|
+
exports.normalizeUrl = normalizeUrl;
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import type { LoaderDefinition } from "../..";
|
|
1
|
+
import type { LoaderContext, LoaderDefinition } from "../..";
|
|
2
|
+
export declare const BASE_URI = "webpack://";
|
|
2
3
|
export declare const MODULE_TYPE = "css/mini-extract";
|
|
3
4
|
export declare const AUTO_PUBLIC_PATH = "__mini_css_extract_plugin_public_path_auto__";
|
|
4
|
-
export declare const ABSOLUTE_PUBLIC_PATH
|
|
5
|
-
export declare const BASE_URI = "webpack://";
|
|
5
|
+
export declare const ABSOLUTE_PUBLIC_PATH: string;
|
|
6
6
|
export declare const SINGLE_DOT_PATH_SEGMENT = "__mini_css_extract_plugin_single_dot_path_segment__";
|
|
7
7
|
export interface CssExtractRspackLoaderOptions {
|
|
8
8
|
publicPath?: string | ((resourcePath: string, context: string) => string);
|
|
@@ -11,6 +11,11 @@ export interface CssExtractRspackLoaderOptions {
|
|
|
11
11
|
layer?: boolean;
|
|
12
12
|
defaultExport?: boolean;
|
|
13
13
|
}
|
|
14
|
+
export declare function hotLoader(content: string, context: {
|
|
15
|
+
loaderContext: LoaderContext;
|
|
16
|
+
options?: CssExtractRspackLoaderOptions;
|
|
17
|
+
locals?: Record<string, string>;
|
|
18
|
+
}): string;
|
|
14
19
|
declare const loader: LoaderDefinition;
|
|
15
20
|
export declare const pitch: LoaderDefinition["pitch"];
|
|
16
21
|
export default loader;
|
|
@@ -3,33 +3,44 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.pitch = exports.
|
|
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
9
|
const loader_options_json_1 = __importDefault(require("./loader-options.json"));
|
|
10
10
|
const utils_1 = require("./utils");
|
|
11
|
+
exports.BASE_URI = "webpack://";
|
|
11
12
|
exports.MODULE_TYPE = "css/mini-extract";
|
|
12
13
|
exports.AUTO_PUBLIC_PATH = "__mini_css_extract_plugin_public_path_auto__";
|
|
13
|
-
exports.ABSOLUTE_PUBLIC_PATH = "
|
|
14
|
-
exports.BASE_URI = "webpack://";
|
|
14
|
+
exports.ABSOLUTE_PUBLIC_PATH = exports.BASE_URI + "/mini-css-extract-plugin/";
|
|
15
15
|
exports.SINGLE_DOT_PATH_SEGMENT = "__mini_css_extract_plugin_single_dot_path_segment__";
|
|
16
16
|
const SERIALIZE_SEP = "__RSPACK_CSS_EXTRACT_SEP__";
|
|
17
17
|
function hotLoader(content, context) {
|
|
18
|
-
const
|
|
19
|
-
? ""
|
|
20
|
-
: "module.hot.accept(undefined, cssReload);";
|
|
18
|
+
const localsJsonString = JSON.stringify(JSON.stringify(context.locals));
|
|
21
19
|
return `${content}
|
|
22
20
|
if(module.hot) {
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
21
|
+
(function() {
|
|
22
|
+
var localsJsonString = ${localsJsonString};
|
|
23
|
+
// ${Date.now()}
|
|
24
|
+
var cssReload = require(${(0, utils_1.stringifyRequest)(context.loaderContext, node_path_1.default.join(__dirname, "hmr/hotModuleReplacement.js"))}).cssReload(module.id, ${JSON.stringify(context.options ?? {})});
|
|
25
|
+
// only invalidate when locals change
|
|
26
|
+
if (
|
|
27
|
+
module.hot.data &&
|
|
28
|
+
module.hot.data.value &&
|
|
29
|
+
module.hot.data.value !== localsJsonString
|
|
30
|
+
) {
|
|
31
|
+
module.hot.invalidate();
|
|
32
|
+
} else {
|
|
33
|
+
module.hot.accept();
|
|
34
|
+
}
|
|
35
|
+
module.hot.dispose(function(data) {
|
|
36
|
+
data.value = localsJsonString;
|
|
37
|
+
cssReload();
|
|
38
|
+
});
|
|
39
|
+
})();
|
|
30
40
|
}
|
|
31
41
|
`;
|
|
32
42
|
}
|
|
43
|
+
exports.hotLoader = hotLoader;
|
|
33
44
|
const loader = function loader(content) {
|
|
34
45
|
if (this._compiler &&
|
|
35
46
|
this._compiler.options &&
|
|
@@ -101,14 +112,14 @@ const pitch = function (request, _, data) {
|
|
|
101
112
|
originalExports.__esModule &&
|
|
102
113
|
(!originalExports.default || !("locals" in originalExports.default));
|
|
103
114
|
if (namedExport) {
|
|
104
|
-
Object.keys(originalExports)
|
|
115
|
+
for (const key of Object.keys(originalExports)) {
|
|
105
116
|
if (key !== "default") {
|
|
106
117
|
if (!locals) {
|
|
107
118
|
locals = {};
|
|
108
119
|
}
|
|
109
120
|
/** @type {Locals} */ locals[key] = originalExports[key];
|
|
110
121
|
}
|
|
111
|
-
}
|
|
122
|
+
}
|
|
112
123
|
}
|
|
113
124
|
else {
|
|
114
125
|
locals = exports && exports.locals;
|
|
@@ -171,7 +182,7 @@ const pitch = function (request, _, data) {
|
|
|
171
182
|
}
|
|
172
183
|
return `\n${esModule ? "export default" : "module.exports = "} ${JSON.stringify(locals)};`;
|
|
173
184
|
}
|
|
174
|
-
|
|
185
|
+
if (esModule) {
|
|
175
186
|
return "\nexport {};";
|
|
176
187
|
}
|
|
177
188
|
return "";
|
|
@@ -202,7 +213,7 @@ const pitch = function (request, _, data) {
|
|
|
202
213
|
callback(null, resultSource, undefined, additionalData);
|
|
203
214
|
};
|
|
204
215
|
this.importModule(`${this.resourcePath}.webpack[javascript/auto]!=!!!${request}`, {
|
|
205
|
-
publicPath: /** @type {
|
|
216
|
+
publicPath: /** @type {Filename} */ publicPathForExtract,
|
|
206
217
|
baseUri: `${exports.BASE_URI}/`
|
|
207
218
|
}, (error, exports) => {
|
|
208
219
|
if (error) {
|
|
@@ -17,7 +17,7 @@ export declare const BuiltinLazyCompilationPlugin: {
|
|
|
17
17
|
data: string;
|
|
18
18
|
client: string;
|
|
19
19
|
}, cacheable: boolean, entries: boolean, imports: boolean, test?: RawRegex | ((m: JsModule) => boolean) | undefined];
|
|
20
|
-
affectedHooks: "done" | "
|
|
20
|
+
affectedHooks: "done" | "make" | "compile" | "emit" | "afterEmit" | "invalid" | "thisCompilation" | "afterDone" | "compilation" | "normalModuleFactory" | "contextModuleFactory" | "initialize" | "shouldEmit" | "infrastructureLog" | "beforeRun" | "run" | "assetEmitted" | "failed" | "shutdown" | "watchRun" | "watchClose" | "environment" | "afterEnvironment" | "afterPlugins" | "afterResolvers" | "beforeCompile" | "afterCompile" | "finishMake" | "entryOption" | undefined;
|
|
21
21
|
raw(compiler: import("../../Compiler").Compiler): import("@rspack/binding").BuiltinPlugin;
|
|
22
22
|
apply(compiler: import("../../Compiler").Compiler): void;
|
|
23
23
|
};
|
package/dist/config/adapter.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type
|
|
1
|
+
import { type RawLibraryOptions, 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";
|
package/dist/config/adapter.js
CHANGED
|
@@ -5,6 +5,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
exports.getRawChunkLoading = exports.getRawLibrary = exports.getRawResolve = exports.getRawOptions = void 0;
|
|
7
7
|
const node_assert_1 = __importDefault(require("node:assert"));
|
|
8
|
+
const binding_1 = require("@rspack/binding");
|
|
8
9
|
const Stats_1 = require("../Stats");
|
|
9
10
|
const util_1 = require("../util");
|
|
10
11
|
const identifier_1 = require("../util/identifier");
|
|
@@ -68,9 +69,7 @@ function getRawExtensionAlias(alias = {}) {
|
|
|
68
69
|
if (Array.isArray(value)) {
|
|
69
70
|
return [key, value];
|
|
70
71
|
}
|
|
71
|
-
|
|
72
|
-
return [key, [value]];
|
|
73
|
-
}
|
|
72
|
+
return [key, [value]];
|
|
74
73
|
});
|
|
75
74
|
return Object.fromEntries(entries);
|
|
76
75
|
}
|
|
@@ -92,8 +91,8 @@ function getRawTsConfig(tsConfig) {
|
|
|
92
91
|
const { configFile, references } = tsConfig;
|
|
93
92
|
return {
|
|
94
93
|
configFile,
|
|
95
|
-
referencesType: references
|
|
96
|
-
references: references
|
|
94
|
+
referencesType: references === "auto" ? "auto" : references ? "manual" : "disabled",
|
|
95
|
+
references: references === "auto" ? undefined : references
|
|
97
96
|
};
|
|
98
97
|
}
|
|
99
98
|
function getRawResolve(resolve) {
|
|
@@ -140,6 +139,7 @@ function getRawOutput(output) {
|
|
|
140
139
|
strictModuleErrorHandling: output.strictModuleErrorHandling,
|
|
141
140
|
globalObject: output.globalObject,
|
|
142
141
|
importFunctionName: output.importFunctionName,
|
|
142
|
+
importMetaName: output.importMetaName,
|
|
143
143
|
iife: output.iife,
|
|
144
144
|
module: output.module,
|
|
145
145
|
wasmLoading: wasmLoading === false ? "false" : wasmLoading,
|
|
@@ -157,6 +157,8 @@ function getRawOutput(output) {
|
|
|
157
157
|
workerWasmLoading: workerWasmLoading === false ? "false" : workerWasmLoading,
|
|
158
158
|
workerPublicPath: output.workerPublicPath,
|
|
159
159
|
scriptType: output.scriptType === false ? "false" : output.scriptType,
|
|
160
|
+
charset: output.charset,
|
|
161
|
+
chunkLoadTimeout: output.chunkLoadTimeout,
|
|
160
162
|
environment: output.environment
|
|
161
163
|
};
|
|
162
164
|
}
|
|
@@ -277,6 +279,9 @@ const getRawModuleRule = (rule, path, options, upperType) => {
|
|
|
277
279
|
include: rule.include ? getRawRuleSetCondition(rule.include) : undefined,
|
|
278
280
|
exclude: rule.exclude ? getRawRuleSetCondition(rule.exclude) : undefined,
|
|
279
281
|
issuer: rule.issuer ? getRawRuleSetCondition(rule.issuer) : undefined,
|
|
282
|
+
issuerLayer: rule.issuerLayer
|
|
283
|
+
? getRawRuleSetCondition(rule.issuerLayer)
|
|
284
|
+
: undefined,
|
|
280
285
|
dependency: rule.dependency
|
|
281
286
|
? getRawRuleSetCondition(rule.dependency)
|
|
282
287
|
: undefined,
|
|
@@ -286,6 +291,12 @@ const getRawModuleRule = (rule, path, options, upperType) => {
|
|
|
286
291
|
getRawRuleSetCondition(v)
|
|
287
292
|
]))
|
|
288
293
|
: undefined,
|
|
294
|
+
with: rule.with
|
|
295
|
+
? Object.fromEntries(Object.entries(rule.with).map(([k, v]) => [
|
|
296
|
+
k,
|
|
297
|
+
getRawRuleSetCondition(v)
|
|
298
|
+
]))
|
|
299
|
+
: undefined,
|
|
289
300
|
resource: rule.resource ? getRawRuleSetCondition(rule.resource) : undefined,
|
|
290
301
|
resourceQuery: rule.resourceQuery
|
|
291
302
|
? getRawRuleSetCondition(rule.resourceQuery)
|
|
@@ -300,6 +311,7 @@ const getRawModuleRule = (rule, path, options, upperType) => {
|
|
|
300
311
|
? funcUse
|
|
301
312
|
: (0, adapterRuleUse_1.createRawModuleRuleUses)(rule.use ?? [], `${path}.use`, options),
|
|
302
313
|
type: rule.type,
|
|
314
|
+
layer: rule.layer,
|
|
303
315
|
parser: rule.parser
|
|
304
316
|
? getRawParserOptions(rule.parser, rule.type ?? upperType)
|
|
305
317
|
: undefined,
|
|
@@ -331,7 +343,7 @@ const getRawModuleRule = (rule, path, options, upperType) => {
|
|
|
331
343
|
if (rule.test && !tryMatch(path, rule.test)) {
|
|
332
344
|
return false;
|
|
333
345
|
}
|
|
334
|
-
|
|
346
|
+
if (rule.resource && !tryMatch(path, rule.resource)) {
|
|
335
347
|
return false;
|
|
336
348
|
}
|
|
337
349
|
if (rule.resourceQuery && !tryMatch(query, rule.resourceQuery)) {
|
|
@@ -349,14 +361,14 @@ const getRawModuleRule = (rule, path, options, upperType) => {
|
|
|
349
361
|
function getRawRuleSetCondition(condition) {
|
|
350
362
|
if (typeof condition === "string") {
|
|
351
363
|
return {
|
|
352
|
-
type:
|
|
353
|
-
|
|
364
|
+
type: binding_1.RawRuleSetConditionType.string,
|
|
365
|
+
string: condition
|
|
354
366
|
};
|
|
355
367
|
}
|
|
356
368
|
if (condition instanceof RegExp) {
|
|
357
369
|
return {
|
|
358
|
-
type:
|
|
359
|
-
|
|
370
|
+
type: binding_1.RawRuleSetConditionType.regexp,
|
|
371
|
+
regexp: {
|
|
360
372
|
source: condition.source,
|
|
361
373
|
flags: condition.flags
|
|
362
374
|
}
|
|
@@ -364,20 +376,20 @@ function getRawRuleSetCondition(condition) {
|
|
|
364
376
|
}
|
|
365
377
|
if (typeof condition === "function") {
|
|
366
378
|
return {
|
|
367
|
-
type:
|
|
368
|
-
|
|
379
|
+
type: binding_1.RawRuleSetConditionType.func,
|
|
380
|
+
func: condition
|
|
369
381
|
};
|
|
370
382
|
}
|
|
371
383
|
if (Array.isArray(condition)) {
|
|
372
384
|
return {
|
|
373
|
-
type:
|
|
374
|
-
|
|
385
|
+
type: binding_1.RawRuleSetConditionType.array,
|
|
386
|
+
array: condition.map(i => getRawRuleSetCondition(i))
|
|
375
387
|
};
|
|
376
388
|
}
|
|
377
389
|
if (typeof condition === "object" && condition !== null) {
|
|
378
390
|
return {
|
|
379
|
-
type:
|
|
380
|
-
|
|
391
|
+
type: binding_1.RawRuleSetConditionType.logical,
|
|
392
|
+
logical: [getRawRuleSetLogicalConditions(condition)]
|
|
381
393
|
};
|
|
382
394
|
}
|
|
383
395
|
throw new Error("unreachable: condition should be one of string, RegExp, Array, Object");
|
|
@@ -408,41 +420,41 @@ function getRawParserOptions(parser, type) {
|
|
|
408
420
|
asset: getRawAssetParserOptions(parser)
|
|
409
421
|
};
|
|
410
422
|
}
|
|
411
|
-
|
|
423
|
+
if (type === "javascript") {
|
|
412
424
|
// Filter this out, since `parser["javascript"]` already merge into `parser["javascript/*"]` in default.ts
|
|
413
425
|
return;
|
|
414
426
|
}
|
|
415
|
-
|
|
427
|
+
if (type === "javascript/auto") {
|
|
416
428
|
return {
|
|
417
429
|
type: "javascript/auto",
|
|
418
430
|
javascript: getRawJavascriptParserOptions(parser)
|
|
419
431
|
};
|
|
420
432
|
}
|
|
421
|
-
|
|
433
|
+
if (type === "javascript/dynamic") {
|
|
422
434
|
return {
|
|
423
435
|
type: "javascript/dynamic",
|
|
424
436
|
javascript: getRawJavascriptParserOptions(parser)
|
|
425
437
|
};
|
|
426
438
|
}
|
|
427
|
-
|
|
439
|
+
if (type === "javascript/esm") {
|
|
428
440
|
return {
|
|
429
441
|
type: "javascript/esm",
|
|
430
442
|
javascript: getRawJavascriptParserOptions(parser)
|
|
431
443
|
};
|
|
432
444
|
}
|
|
433
|
-
|
|
445
|
+
if (type === "css") {
|
|
434
446
|
return {
|
|
435
447
|
type: "css",
|
|
436
448
|
css: getRawCssParserOptions(parser)
|
|
437
449
|
};
|
|
438
450
|
}
|
|
439
|
-
|
|
451
|
+
if (type === "css/auto") {
|
|
440
452
|
return {
|
|
441
453
|
type: "css/auto",
|
|
442
454
|
cssAuto: getRawCssParserOptions(parser)
|
|
443
455
|
};
|
|
444
456
|
}
|
|
445
|
-
|
|
457
|
+
if (type === "css/module") {
|
|
446
458
|
return {
|
|
447
459
|
type: "css/module",
|
|
448
460
|
cssModule: getRawCssParserOptions(parser)
|
|
@@ -457,6 +469,7 @@ function getRawJavascriptParserOptions(parser) {
|
|
|
457
469
|
dynamicImportPreload: parser.dynamicImportPreload?.toString() ?? "false",
|
|
458
470
|
dynamicImportPrefetch: parser.dynamicImportPrefetch?.toString() ?? "false",
|
|
459
471
|
dynamicImportFetchPriority: parser.dynamicImportFetchPriority?.toString(),
|
|
472
|
+
importMeta: parser.importMeta ?? true,
|
|
460
473
|
url: parser.url === false
|
|
461
474
|
? "false"
|
|
462
475
|
: parser.url === "relative"
|
|
@@ -628,9 +641,10 @@ function getRawSnapshotOptions(_snapshot) {
|
|
|
628
641
|
return {};
|
|
629
642
|
}
|
|
630
643
|
function getRawExperiments(experiments) {
|
|
631
|
-
const { topLevelAwait, rspackFuture } = experiments;
|
|
632
|
-
(0, node_assert_1.default)(!(0, util_1.isNil)(topLevelAwait) && !(0, util_1.isNil)(rspackFuture));
|
|
644
|
+
const { topLevelAwait, layers, rspackFuture } = experiments;
|
|
645
|
+
(0, node_assert_1.default)(!(0, util_1.isNil)(topLevelAwait) && !(0, util_1.isNil)(rspackFuture) && !(0, util_1.isNil)(layers));
|
|
633
646
|
return {
|
|
647
|
+
layers,
|
|
634
648
|
topLevelAwait,
|
|
635
649
|
rspackFuture: getRawRspackFutureOptions(rspackFuture)
|
|
636
650
|
};
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
/// <reference types="node" />
|
|
2
2
|
import type { JsAssetInfo, RawModuleRuleUse, RawOptions } from "@rspack/binding";
|
|
3
3
|
import type { ResolveRequest } from "../../compiled/enhanced-resolve";
|
|
4
|
-
import type { Compiler } from "../Compiler";
|
|
5
|
-
import type { Logger } from "../logging/Logger";
|
|
6
|
-
import Hash = require("../util/hash");
|
|
7
4
|
import type { Compilation } from "../Compilation";
|
|
5
|
+
import type { Compiler } from "../Compiler";
|
|
8
6
|
import type { Module } from "../Module";
|
|
9
7
|
import { type LoaderObject } from "../loader-runner";
|
|
10
|
-
import type {
|
|
8
|
+
import type { Logger } from "../logging/Logger";
|
|
9
|
+
import type Hash from "../util/hash";
|
|
10
|
+
import type { Mode, PublicPath, Resolve, RuleSetUseItem, Target } from "./zod";
|
|
11
11
|
export declare const BUILTIN_LOADER_PREFIX = "builtin:";
|
|
12
12
|
export interface ComposeJsUseOptions {
|
|
13
13
|
devtool: RawOptions["devtool"];
|
|
@@ -87,7 +87,7 @@ export interface LoaderContext<OptionsType = {}> {
|
|
|
87
87
|
getMissingDependencies(): string[];
|
|
88
88
|
addBuildDependency(file: string): void;
|
|
89
89
|
importModule(request: string, options: {
|
|
90
|
-
publicPath?:
|
|
90
|
+
publicPath?: PublicPath;
|
|
91
91
|
baseUri?: string;
|
|
92
92
|
}, callback: (err?: Error, res?: any) => void): void;
|
|
93
93
|
fs: any;
|