@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
package/dist/lib/CacheFacade.js
CHANGED
|
@@ -1,89 +1,101 @@
|
|
|
1
|
-
/*
|
|
2
|
-
MIT License http://www.opensource.org/licenses/mit-license.php
|
|
3
|
-
Author Tobias Koppers @sokra
|
|
4
|
-
*/
|
|
5
1
|
"use strict";
|
|
6
|
-
const { forEachBail } = require("../../compiled/enhanced-resolve");
|
|
7
|
-
const asyncLib = require("../../compiled/neo-async");
|
|
8
|
-
const getLazyHashedEtag = require("./cache/getLazyHashedEtag.js");
|
|
9
|
-
const mergeEtags = require("./cache/mergeEtags.js");
|
|
10
|
-
/** @typedef {import("./Cache")} Cache */
|
|
11
|
-
/** @typedef {import("./Cache").Etag} Etag */
|
|
12
|
-
/** @typedef {import("./WebpackError")} WebpackError */
|
|
13
|
-
/** @typedef {import("./cache/getLazyHashedEtag").HashableObject} HashableObject */
|
|
14
|
-
// /** @typedef {typeof import("./util/Hash")} HashConstructor */
|
|
15
|
-
/** @typedef {any} HashConstructor */
|
|
16
2
|
/**
|
|
17
|
-
*
|
|
18
|
-
*
|
|
19
|
-
*
|
|
20
|
-
*
|
|
21
|
-
* @
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
* @template T
|
|
25
|
-
* @callback CallbackNormalErrorCache
|
|
26
|
-
* @param {(Error | null)=} err
|
|
27
|
-
* @param {T=} result
|
|
28
|
-
* @returns {void}
|
|
3
|
+
* The following code is modified based on
|
|
4
|
+
* https://github.com/webpack/webpack/blob/4b4ca3b/lib/CacheFacade.js
|
|
5
|
+
*
|
|
6
|
+
* MIT Licensed
|
|
7
|
+
* Author Tobias Koppers @sokra
|
|
8
|
+
* Copyright (c) JS Foundation and other contributors
|
|
9
|
+
* https://github.com/webpack/webpack/blob/main/LICENSE
|
|
29
10
|
*/
|
|
11
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
12
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
13
|
+
};
|
|
14
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
+
exports.CacheFacade = exports.ItemCacheFacade = exports.MultiItemCache = void 0;
|
|
16
|
+
const neo_async_1 = __importDefault(require("../../compiled/neo-async"));
|
|
17
|
+
const getLazyHashedEtag_js_1 = require("./cache/getLazyHashedEtag.js");
|
|
18
|
+
const mergeEtags_js_1 = require("./cache/mergeEtags.js");
|
|
19
|
+
function forEachBail(array, iterator, callback) {
|
|
20
|
+
if (array.length === 0) {
|
|
21
|
+
callback();
|
|
22
|
+
return;
|
|
23
|
+
}
|
|
24
|
+
let i = 0;
|
|
25
|
+
const next = () => {
|
|
26
|
+
/** @type {boolean|undefined} */
|
|
27
|
+
let loop = undefined;
|
|
28
|
+
iterator(array[i++], (err, result) => {
|
|
29
|
+
if (err || result !== undefined || i >= array.length) {
|
|
30
|
+
return callback(err, result, i);
|
|
31
|
+
}
|
|
32
|
+
if (loop === false)
|
|
33
|
+
while (next())
|
|
34
|
+
;
|
|
35
|
+
loop = true;
|
|
36
|
+
}, i);
|
|
37
|
+
if (!loop)
|
|
38
|
+
loop = false;
|
|
39
|
+
return loop;
|
|
40
|
+
};
|
|
41
|
+
while (next())
|
|
42
|
+
;
|
|
43
|
+
}
|
|
44
|
+
class BaseCache {
|
|
45
|
+
}
|
|
30
46
|
class MultiItemCache {
|
|
31
47
|
/**
|
|
32
|
-
* @param
|
|
48
|
+
* @param items item caches
|
|
49
|
+
* @returns
|
|
33
50
|
*/
|
|
34
51
|
constructor(items) {
|
|
35
52
|
this._items = items;
|
|
36
53
|
if (items.length === 1)
|
|
37
|
-
return
|
|
54
|
+
return items[0];
|
|
38
55
|
}
|
|
39
56
|
/**
|
|
40
|
-
* @
|
|
41
|
-
* @
|
|
42
|
-
* @returns {void}
|
|
57
|
+
* @param callback signals when the value is retrieved
|
|
58
|
+
* @returns
|
|
43
59
|
*/
|
|
44
60
|
get(callback) {
|
|
45
|
-
// @ts-expect-error
|
|
46
61
|
forEachBail(this._items, (item, callback) => item.get(callback), callback);
|
|
47
62
|
}
|
|
48
63
|
/**
|
|
49
|
-
* @
|
|
50
|
-
* @returns {Promise<T>} promise with the data
|
|
64
|
+
* @returns promise with the data
|
|
51
65
|
*/
|
|
52
66
|
getPromise() {
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
return next(i);
|
|
60
|
-
});
|
|
67
|
+
const next = async (i) => {
|
|
68
|
+
const result_1 = await this._items[i].getPromise();
|
|
69
|
+
if (result_1 !== undefined)
|
|
70
|
+
return result_1;
|
|
71
|
+
if (++i < this._items.length)
|
|
72
|
+
return next(i);
|
|
61
73
|
};
|
|
62
74
|
return next(0);
|
|
63
75
|
}
|
|
64
76
|
/**
|
|
65
|
-
* @
|
|
66
|
-
* @param
|
|
67
|
-
* @
|
|
68
|
-
* @returns {void}
|
|
77
|
+
* @param data the value to store
|
|
78
|
+
* @param callback signals when the value is stored
|
|
79
|
+
* @returns
|
|
69
80
|
*/
|
|
70
81
|
store(data, callback) {
|
|
71
|
-
|
|
82
|
+
neo_async_1.default.each(this._items, (item, callback) => item.store(data, callback), callback);
|
|
72
83
|
}
|
|
73
84
|
/**
|
|
74
|
-
* @
|
|
75
|
-
* @
|
|
76
|
-
* @returns {Promise<void>} promise signals when the value is stored
|
|
85
|
+
* @param data the value to store
|
|
86
|
+
* @returns promise signals when the value is stored
|
|
77
87
|
*/
|
|
78
|
-
storePromise(data) {
|
|
79
|
-
|
|
88
|
+
async storePromise(data) {
|
|
89
|
+
await Promise.all(this._items.map(item => item.storePromise(data)));
|
|
80
90
|
}
|
|
81
91
|
}
|
|
92
|
+
exports.MultiItemCache = MultiItemCache;
|
|
82
93
|
class ItemCacheFacade {
|
|
83
94
|
/**
|
|
84
|
-
* @param
|
|
85
|
-
* @param
|
|
86
|
-
* @param
|
|
95
|
+
* @param cache the root cache
|
|
96
|
+
* @param name the child cache item name
|
|
97
|
+
* @param etag the etag
|
|
98
|
+
* @returns
|
|
87
99
|
*/
|
|
88
100
|
constructor(cache, name, etag) {
|
|
89
101
|
this._cache = cache;
|
|
@@ -91,16 +103,14 @@ class ItemCacheFacade {
|
|
|
91
103
|
this._etag = etag;
|
|
92
104
|
}
|
|
93
105
|
/**
|
|
94
|
-
* @
|
|
95
|
-
* @
|
|
96
|
-
* @returns {void}
|
|
106
|
+
* @param callback signals when the value is retrieved
|
|
107
|
+
* @returns
|
|
97
108
|
*/
|
|
98
109
|
get(callback) {
|
|
99
110
|
this._cache.get(this._name, this._etag, callback);
|
|
100
111
|
}
|
|
101
112
|
/**
|
|
102
|
-
* @
|
|
103
|
-
* @returns {Promise<T>} promise with the data
|
|
113
|
+
* @returns promise with the data
|
|
104
114
|
*/
|
|
105
115
|
getPromise() {
|
|
106
116
|
return new Promise((resolve, reject) => {
|
|
@@ -115,18 +125,16 @@ class ItemCacheFacade {
|
|
|
115
125
|
});
|
|
116
126
|
}
|
|
117
127
|
/**
|
|
118
|
-
* @
|
|
119
|
-
* @param
|
|
120
|
-
* @
|
|
121
|
-
* @returns {void}
|
|
128
|
+
* @param data the value to store
|
|
129
|
+
* @param callback signals when the value is stored
|
|
130
|
+
* @returns
|
|
122
131
|
*/
|
|
123
132
|
store(data, callback) {
|
|
124
133
|
this._cache.store(this._name, this._etag, data, callback);
|
|
125
134
|
}
|
|
126
135
|
/**
|
|
127
|
-
* @
|
|
128
|
-
* @
|
|
129
|
-
* @returns {Promise<void>} promise signals when the value is stored
|
|
136
|
+
* @param data the value to store
|
|
137
|
+
* @returns promise signals when the value is stored
|
|
130
138
|
*/
|
|
131
139
|
storePromise(data) {
|
|
132
140
|
return new Promise((resolve, reject) => {
|
|
@@ -141,10 +149,9 @@ class ItemCacheFacade {
|
|
|
141
149
|
});
|
|
142
150
|
}
|
|
143
151
|
/**
|
|
144
|
-
* @
|
|
145
|
-
* @param
|
|
146
|
-
* @
|
|
147
|
-
* @returns {void}
|
|
152
|
+
* @param computer function to compute the value if not cached
|
|
153
|
+
* @param callback signals when the value is retrieved
|
|
154
|
+
* @returns
|
|
148
155
|
*/
|
|
149
156
|
provide(computer, callback) {
|
|
150
157
|
this.get((err, cacheEntry) => {
|
|
@@ -164,9 +171,8 @@ class ItemCacheFacade {
|
|
|
164
171
|
});
|
|
165
172
|
}
|
|
166
173
|
/**
|
|
167
|
-
* @
|
|
168
|
-
* @
|
|
169
|
-
* @returns {Promise<T>} promise with the data
|
|
174
|
+
* @param computer function to compute the value if not cached
|
|
175
|
+
* @returns promise with the data
|
|
170
176
|
*/
|
|
171
177
|
async providePromise(computer) {
|
|
172
178
|
const cacheEntry = await this.getPromise();
|
|
@@ -177,11 +183,12 @@ class ItemCacheFacade {
|
|
|
177
183
|
return result;
|
|
178
184
|
}
|
|
179
185
|
}
|
|
186
|
+
exports.ItemCacheFacade = ItemCacheFacade;
|
|
180
187
|
class CacheFacade {
|
|
181
188
|
/**
|
|
182
|
-
* @param
|
|
183
|
-
* @param
|
|
184
|
-
* @param
|
|
189
|
+
* @param cache the root cache
|
|
190
|
+
* @param name the child cache name
|
|
191
|
+
* @param hashFunction the hash function to use
|
|
185
192
|
*/
|
|
186
193
|
constructor(cache, name, hashFunction) {
|
|
187
194
|
this._cache = cache;
|
|
@@ -189,50 +196,48 @@ class CacheFacade {
|
|
|
189
196
|
this._hashFunction = hashFunction;
|
|
190
197
|
}
|
|
191
198
|
/**
|
|
192
|
-
* @param
|
|
193
|
-
* @returns
|
|
199
|
+
* @param name the child cache name#
|
|
200
|
+
* @returns child cache
|
|
194
201
|
*/
|
|
195
202
|
getChildCache(name) {
|
|
196
203
|
return new CacheFacade(this._cache, `${this._name}|${name}`, this._hashFunction);
|
|
197
204
|
}
|
|
198
205
|
/**
|
|
199
|
-
* @param
|
|
200
|
-
* @param
|
|
201
|
-
* @returns
|
|
206
|
+
* @param identifier the cache identifier
|
|
207
|
+
* @param etag the etag
|
|
208
|
+
* @returns item cache
|
|
202
209
|
*/
|
|
203
210
|
getItemCache(identifier, etag) {
|
|
204
211
|
return new ItemCacheFacade(this._cache, `${this._name}|${identifier}`, etag);
|
|
205
212
|
}
|
|
206
213
|
/**
|
|
207
|
-
* @param
|
|
208
|
-
* @returns
|
|
214
|
+
* @param obj an hashable object
|
|
215
|
+
* @returns an etag that is lazy hashed
|
|
209
216
|
*/
|
|
210
217
|
getLazyHashedEtag(obj) {
|
|
211
|
-
return
|
|
218
|
+
return (0, getLazyHashedEtag_js_1.getter)(obj, this._hashFunction);
|
|
212
219
|
}
|
|
213
220
|
/**
|
|
214
|
-
* @param
|
|
215
|
-
* @param
|
|
216
|
-
* @returns
|
|
221
|
+
* @param a an etag
|
|
222
|
+
* @param b another etag
|
|
223
|
+
* @returns an etag that represents both
|
|
217
224
|
*/
|
|
218
225
|
mergeEtags(a, b) {
|
|
219
|
-
return mergeEtags(a, b);
|
|
226
|
+
return (0, mergeEtags_js_1.mergeEtags)(a, b);
|
|
220
227
|
}
|
|
221
228
|
/**
|
|
222
|
-
* @
|
|
223
|
-
* @param
|
|
224
|
-
* @param
|
|
225
|
-
* @
|
|
226
|
-
* @returns {void}
|
|
229
|
+
* @param identifier the cache identifier
|
|
230
|
+
* @param etag the etag
|
|
231
|
+
* @param callback signals when the value is retrieved
|
|
232
|
+
* @returns
|
|
227
233
|
*/
|
|
228
234
|
get(identifier, etag, callback) {
|
|
229
235
|
this._cache.get(`${this._name}|${identifier}`, etag, callback);
|
|
230
236
|
}
|
|
231
237
|
/**
|
|
232
|
-
* @
|
|
233
|
-
* @param
|
|
234
|
-
* @
|
|
235
|
-
* @returns {Promise<T>} promise with the data
|
|
238
|
+
* @param identifier the cache identifier
|
|
239
|
+
* @param etag the etag
|
|
240
|
+
* @returns promise with the data
|
|
236
241
|
*/
|
|
237
242
|
getPromise(identifier, etag) {
|
|
238
243
|
return new Promise((resolve, reject) => {
|
|
@@ -247,22 +252,20 @@ class CacheFacade {
|
|
|
247
252
|
});
|
|
248
253
|
}
|
|
249
254
|
/**
|
|
250
|
-
* @
|
|
251
|
-
* @param
|
|
252
|
-
* @param
|
|
253
|
-
* @param
|
|
254
|
-
* @
|
|
255
|
-
* @returns {void}
|
|
255
|
+
* @param identifier the cache identifier
|
|
256
|
+
* @param etag the etag
|
|
257
|
+
* @param data the value to store
|
|
258
|
+
* @param callback signals when the value is stored
|
|
259
|
+
* @returns
|
|
256
260
|
*/
|
|
257
261
|
store(identifier, etag, data, callback) {
|
|
258
262
|
this._cache.store(`${this._name}|${identifier}`, etag, data, callback);
|
|
259
263
|
}
|
|
260
264
|
/**
|
|
261
|
-
* @
|
|
262
|
-
* @param
|
|
263
|
-
* @param
|
|
264
|
-
* @
|
|
265
|
-
* @returns {Promise<void>} promise signals when the value is stored
|
|
265
|
+
* @param identifier the cache identifier
|
|
266
|
+
* @param etag the etag
|
|
267
|
+
* @param data the value to store
|
|
268
|
+
* @returns promise signals when the value is stored
|
|
266
269
|
*/
|
|
267
270
|
storePromise(identifier, etag, data) {
|
|
268
271
|
return new Promise((resolve, reject) => {
|
|
@@ -277,12 +280,11 @@ class CacheFacade {
|
|
|
277
280
|
});
|
|
278
281
|
}
|
|
279
282
|
/**
|
|
280
|
-
* @
|
|
281
|
-
* @param
|
|
282
|
-
* @param
|
|
283
|
-
* @param
|
|
284
|
-
* @
|
|
285
|
-
* @returns {void}
|
|
283
|
+
* @param identifier the cache identifier
|
|
284
|
+
* @param etag the etag
|
|
285
|
+
* @param computer function to compute the value if not cached
|
|
286
|
+
* @param callback signals when the value is retrieved
|
|
287
|
+
* @returns
|
|
286
288
|
*/
|
|
287
289
|
provide(identifier, etag, computer, callback) {
|
|
288
290
|
this.get(identifier, etag, (err, cacheEntry) => {
|
|
@@ -302,11 +304,10 @@ class CacheFacade {
|
|
|
302
304
|
});
|
|
303
305
|
}
|
|
304
306
|
/**
|
|
305
|
-
* @
|
|
306
|
-
* @param
|
|
307
|
-
* @param
|
|
308
|
-
* @
|
|
309
|
-
* @returns {Promise<T>} promise with the data
|
|
307
|
+
* @param identifier the cache identifier
|
|
308
|
+
* @param etag the etag
|
|
309
|
+
* @param computer function to compute the value if not cached
|
|
310
|
+
* @returns promise with the data
|
|
310
311
|
*/
|
|
311
312
|
async providePromise(identifier, etag, computer) {
|
|
312
313
|
const cacheEntry = await this.getPromise(identifier, etag);
|
|
@@ -317,6 +318,5 @@ class CacheFacade {
|
|
|
317
318
|
return result;
|
|
318
319
|
}
|
|
319
320
|
}
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
module.exports.MultiItemCache = MultiItemCache;
|
|
321
|
+
exports.CacheFacade = CacheFacade;
|
|
322
|
+
exports.default = CacheFacade;
|
|
@@ -8,9 +8,26 @@
|
|
|
8
8
|
* https://github.com/webpack/webpack/blob/main/LICENSE
|
|
9
9
|
*/
|
|
10
10
|
import type { Compiler, EntryDescriptionNormalized, EntryNormalized } from "..";
|
|
11
|
-
import {
|
|
12
|
-
export
|
|
11
|
+
import type { EntryOptions } from "../builtin-plugin";
|
|
12
|
+
export declare class EntryOptionPlugin {
|
|
13
|
+
/**
|
|
14
|
+
* @param compiler the compiler instance one is tapping into
|
|
15
|
+
* @returns
|
|
16
|
+
*/
|
|
13
17
|
apply(compiler: Compiler): void;
|
|
18
|
+
/**
|
|
19
|
+
* @param compiler the compiler
|
|
20
|
+
* @param context context directory
|
|
21
|
+
* @param entry request
|
|
22
|
+
* @returns
|
|
23
|
+
*/
|
|
14
24
|
static applyEntryOption(compiler: Compiler, context: string, entry: EntryNormalized): void;
|
|
25
|
+
/**
|
|
26
|
+
* @param compiler the compiler
|
|
27
|
+
* @param name entry name
|
|
28
|
+
* @param desc entry description
|
|
29
|
+
* @returns options for the entry
|
|
30
|
+
*/
|
|
15
31
|
static entryDescriptionToOptions(compiler: Compiler, name: string, desc: EntryDescriptionNormalized): EntryOptions;
|
|
16
32
|
}
|
|
33
|
+
export default EntryOptionPlugin;
|
|
@@ -12,15 +12,26 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
12
12
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
13
13
|
};
|
|
14
14
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
+
exports.EntryOptionPlugin = void 0;
|
|
15
16
|
const node_assert_1 = __importDefault(require("node:assert"));
|
|
16
17
|
const builtin_plugin_1 = require("../builtin-plugin");
|
|
17
18
|
class EntryOptionPlugin {
|
|
19
|
+
/**
|
|
20
|
+
* @param compiler the compiler instance one is tapping into
|
|
21
|
+
* @returns
|
|
22
|
+
*/
|
|
18
23
|
apply(compiler) {
|
|
19
24
|
compiler.hooks.entryOption.tap("EntryOptionPlugin", (context, entry) => {
|
|
20
25
|
EntryOptionPlugin.applyEntryOption(compiler, context, entry);
|
|
21
26
|
return true;
|
|
22
27
|
});
|
|
23
28
|
}
|
|
29
|
+
/**
|
|
30
|
+
* @param compiler the compiler
|
|
31
|
+
* @param context context directory
|
|
32
|
+
* @param entry request
|
|
33
|
+
* @returns
|
|
34
|
+
*/
|
|
24
35
|
static applyEntryOption(compiler, context, entry) {
|
|
25
36
|
if (typeof entry === "function") {
|
|
26
37
|
new builtin_plugin_1.DynamicEntryPlugin(context, entry).apply(compiler);
|
|
@@ -36,12 +47,18 @@ class EntryOptionPlugin {
|
|
|
36
47
|
}
|
|
37
48
|
}
|
|
38
49
|
}
|
|
50
|
+
/**
|
|
51
|
+
* @param compiler the compiler
|
|
52
|
+
* @param name entry name
|
|
53
|
+
* @param desc entry description
|
|
54
|
+
* @returns options for the entry
|
|
55
|
+
*/
|
|
39
56
|
static entryDescriptionToOptions(compiler, name, desc) {
|
|
40
57
|
const options = {
|
|
41
58
|
name,
|
|
42
59
|
filename: desc.filename,
|
|
43
60
|
runtime: desc.runtime,
|
|
44
|
-
|
|
61
|
+
layer: desc.layer,
|
|
45
62
|
dependOn: desc.dependOn,
|
|
46
63
|
baseUri: desc.baseUri,
|
|
47
64
|
publicPath: desc.publicPath,
|
|
@@ -50,11 +67,9 @@ class EntryOptionPlugin {
|
|
|
50
67
|
// wasmLoading: desc.wasmLoading,
|
|
51
68
|
library: desc.library
|
|
52
69
|
};
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
// );
|
|
57
|
-
// }
|
|
70
|
+
if (desc.layer !== undefined && !compiler.options.experiments.layers) {
|
|
71
|
+
throw new Error("'entryOptions.layer' is only allowed when 'experiments.layers' is enabled");
|
|
72
|
+
}
|
|
58
73
|
// if (desc.chunkLoading) {
|
|
59
74
|
// const EnableChunkLoadingPlugin = require("./javascript/EnableChunkLoadingPlugin");
|
|
60
75
|
// EnableChunkLoadingPlugin.checkEnabled(compiler, desc.chunkLoading);
|
|
@@ -70,4 +85,5 @@ class EntryOptionPlugin {
|
|
|
70
85
|
return options;
|
|
71
86
|
}
|
|
72
87
|
}
|
|
88
|
+
exports.EntryOptionPlugin = EntryOptionPlugin;
|
|
73
89
|
exports.default = EntryOptionPlugin;
|
|
@@ -1,15 +1,22 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
1
|
+
/**
|
|
2
|
+
* The following code is modified based on
|
|
3
|
+
* https://github.com/webpack/webpack/blob/4b4ca3b/lib/EnvironmentPlugin.js
|
|
4
|
+
*
|
|
5
|
+
* MIT Licensed
|
|
6
|
+
* Author Tobias Koppers @sokra
|
|
7
|
+
* Copyright (c) JS Foundation and other contributors
|
|
8
|
+
* https://github.com/webpack/webpack/blob/main/LICENSE
|
|
9
|
+
*/
|
|
10
|
+
import type { Compiler } from "../Compiler";
|
|
11
|
+
declare class EnvironmentPlugin {
|
|
12
|
+
keys: string[];
|
|
13
|
+
defaultValues: Record<string, string>;
|
|
14
|
+
constructor(...keys: string[] | [Record<string, string> | string]);
|
|
9
15
|
/**
|
|
10
16
|
* Apply the plugin
|
|
11
|
-
* @param
|
|
12
|
-
* @returns
|
|
17
|
+
* @param compiler the compiler instance
|
|
18
|
+
* @returns
|
|
13
19
|
*/
|
|
14
20
|
apply(compiler: Compiler): void;
|
|
15
21
|
}
|
|
22
|
+
export { EnvironmentPlugin };
|
|
@@ -1,18 +1,21 @@
|
|
|
1
|
-
/*
|
|
2
|
-
MIT License http://www.opensource.org/licenses/mit-license.php
|
|
3
|
-
Authors Simen Brekken @simenbrekken, Einar Löve @einarlove
|
|
4
|
-
*/
|
|
5
1
|
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* The following code is modified based on
|
|
4
|
+
* https://github.com/webpack/webpack/blob/4b4ca3b/lib/EnvironmentPlugin.js
|
|
5
|
+
*
|
|
6
|
+
* MIT Licensed
|
|
7
|
+
* Author Tobias Koppers @sokra
|
|
8
|
+
* Copyright (c) JS Foundation and other contributors
|
|
9
|
+
* https://github.com/webpack/webpack/blob/main/LICENSE
|
|
10
|
+
*/
|
|
11
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
12
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
13
|
+
};
|
|
6
14
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
15
|
exports.EnvironmentPlugin = void 0;
|
|
8
16
|
const builtin_plugin_1 = require("../builtin-plugin");
|
|
9
|
-
const
|
|
10
|
-
// /** @typedef {import("./Compiler")} Compiler */
|
|
11
|
-
// /** @typedef {import("./DefinePlugin").CodeValue} CodeValue */
|
|
12
|
-
/** @typedef {any} Compiler */
|
|
13
|
-
/** @typedef {any} CodeValue */
|
|
17
|
+
const WebpackError_1 = __importDefault(require("./WebpackError"));
|
|
14
18
|
class EnvironmentPlugin {
|
|
15
|
-
// @ts-expect-error
|
|
16
19
|
constructor(...keys) {
|
|
17
20
|
if (keys.length === 1 && Array.isArray(keys[0])) {
|
|
18
21
|
this.keys = keys[0];
|
|
@@ -29,20 +32,18 @@ class EnvironmentPlugin {
|
|
|
29
32
|
}
|
|
30
33
|
/**
|
|
31
34
|
* Apply the plugin
|
|
32
|
-
* @param
|
|
33
|
-
* @returns
|
|
35
|
+
* @param compiler the compiler instance
|
|
36
|
+
* @returns
|
|
34
37
|
*/
|
|
35
38
|
apply(compiler) {
|
|
36
|
-
/** @type {Record<string, CodeValue>} */
|
|
37
39
|
const definitions = {};
|
|
38
40
|
for (const key of this.keys) {
|
|
39
41
|
const value = process.env[key] !== undefined
|
|
40
42
|
? process.env[key]
|
|
41
43
|
: this.defaultValues[key];
|
|
42
44
|
if (value === undefined) {
|
|
43
|
-
// @ts-expect-error
|
|
44
45
|
compiler.hooks.thisCompilation.tap("EnvironmentPlugin", compilation => {
|
|
45
|
-
const error = new
|
|
46
|
+
const error = new WebpackError_1.default(`EnvironmentPlugin - ${key} environment variable is undefined.\n\n` +
|
|
46
47
|
"You can pass an object with default values to suppress this warning.\n" +
|
|
47
48
|
"See https://webpack.js.org/plugins/environment-plugin for example.");
|
|
48
49
|
error.name = "EnvVariableNotDefinedError";
|
|
@@ -1,46 +1,40 @@
|
|
|
1
|
-
export = HookWebpackError;
|
|
2
|
-
/** @typedef {any} Module */
|
|
3
1
|
/**
|
|
4
|
-
*
|
|
5
|
-
*
|
|
6
|
-
*
|
|
7
|
-
*
|
|
8
|
-
* @
|
|
2
|
+
* The following code is modified based on
|
|
3
|
+
* https://github.com/webpack/webpack/blob/4b4ca3b/lib/HookWebpackError.js
|
|
4
|
+
*
|
|
5
|
+
* MIT Licensed
|
|
6
|
+
* Author Tobias Koppers @sokra
|
|
7
|
+
* Copyright (c) JS Foundation and other contributors
|
|
8
|
+
* https://github.com/webpack/webpack/blob/main/LICENSE
|
|
9
9
|
*/
|
|
10
|
-
|
|
10
|
+
import type { Callback } from "@rspack/lite-tapable";
|
|
11
|
+
import WebpackError from "./WebpackError";
|
|
12
|
+
export declare class HookWebpackError extends WebpackError {
|
|
13
|
+
hook: string;
|
|
14
|
+
error: Error;
|
|
11
15
|
/**
|
|
12
16
|
* Creates an instance of HookWebpackError.
|
|
13
|
-
* @param
|
|
14
|
-
* @param
|
|
17
|
+
* @param error inner error
|
|
18
|
+
* @param hook name of hook
|
|
15
19
|
*/
|
|
16
20
|
constructor(error: Error, hook: string);
|
|
17
|
-
hook: string;
|
|
18
|
-
error: Error;
|
|
19
|
-
details: string;
|
|
20
|
-
}
|
|
21
|
-
declare namespace HookWebpackError {
|
|
22
|
-
export { makeWebpackError, makeWebpackErrorCallback, tryRunOrWebpackError, Module, Callback };
|
|
23
21
|
}
|
|
24
|
-
|
|
22
|
+
export default HookWebpackError;
|
|
25
23
|
/**
|
|
26
|
-
* @param
|
|
27
|
-
* @param
|
|
28
|
-
* @returns
|
|
24
|
+
* @param error an error
|
|
25
|
+
* @param hook name of the hook
|
|
26
|
+
* @returns a webpack error
|
|
29
27
|
*/
|
|
30
|
-
declare
|
|
28
|
+
export declare const makeWebpackError: (error: Error, hook: string) => WebpackError;
|
|
31
29
|
/**
|
|
32
|
-
* @
|
|
33
|
-
* @param
|
|
34
|
-
* @
|
|
35
|
-
* @returns {Callback<T>} generic callback
|
|
30
|
+
* @param callback webpack error callback
|
|
31
|
+
* @param hook name of hook
|
|
32
|
+
* @returns generic callback
|
|
36
33
|
*/
|
|
37
|
-
declare
|
|
34
|
+
export declare const makeWebpackErrorCallback: <T>(callback: (error?: WebpackError | null, result?: T | undefined) => void, hook: string) => Callback<Error, T>;
|
|
38
35
|
/**
|
|
39
|
-
* @
|
|
40
|
-
* @param
|
|
41
|
-
* @
|
|
42
|
-
* @returns {T} the result
|
|
36
|
+
* @param fn function which will be wrapping in try catch
|
|
37
|
+
* @param hook name of hook
|
|
38
|
+
* @returns the result
|
|
43
39
|
*/
|
|
44
|
-
declare
|
|
45
|
-
type Module = any;
|
|
46
|
-
type Callback<T> = (err?: Error | undefined, stats?: T | undefined) => void;
|
|
40
|
+
export declare const tryRunOrWebpackError: <T>(fn: () => T, hook: string) => T;
|