@rspack/core 1.0.0-beta.0 → 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/dist/Compilation.d.ts +1 -1
- package/dist/Compiler.d.ts +11 -10
- package/dist/Compiler.js +14 -14
- package/dist/Module.d.ts +1 -0
- package/dist/Module.js +1 -0
- package/dist/NormalModule.d.ts +1 -0
- package/dist/NormalModule.js +1 -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 +31 -31
- 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/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 +3 -2
- 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 +5 -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/JsLoaderRspackPlugin.d.ts +1 -1
- package/dist/builtin-plugin/JsonModulesPlugin.d.ts +1 -1
- package/dist/builtin-plugin/LightningCssMiminizerRspackPlugin.d.ts +4 -11
- 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/SwcCssMinimizerPlugin.d.ts +1 -1
- package/dist/builtin-plugin/SwcJsMinimizerPlugin.d.ts +1 -1
- 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/css-extract/loader.d.ts +8 -3
- package/dist/builtin-plugin/css-extract/loader.js +24 -13
- package/dist/builtin-plugin/lazy-compilation/lazyCompilation.d.ts +1 -1
- package/dist/config/adapter.js +15 -2
- package/dist/config/adapterRuleUse.js +3 -3
- package/dist/config/defaults.js +7 -10
- package/dist/config/normalization.d.ts +6 -3
- package/dist/config/normalization.js +2 -0
- package/dist/config/zod.d.ts +1224 -1055
- package/dist/config/zod.js +10 -1
- package/dist/container/ContainerReferencePlugin.d.ts +1 -1
- package/dist/container/ModuleFederationRuntimePlugin.d.ts +1 -1
- package/dist/exports.d.ts +1 -1
- 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 -124
- 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 +9 -0
- 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 +18 -11
- package/dist/lib/formatLocation.d.ts +13 -8
- package/dist/lib/formatLocation.js +17 -15
- package/dist/rspackOptionsApply.js +2 -2
- package/dist/stats/DefaultStatsFactoryPlugin.js +1 -1
- package/dist/util/comparators.d.ts +1 -1
- package/package.json +3 -3
- package/compiled/enhanced-resolve/index.js +0 -5566
- package/dist/lib/ignoreWarningsPlugin.d.ts +0 -7
package/dist/lib/CacheFacade.js
CHANGED
|
@@ -1,90 +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
|
-
if (++i < this._items.length)
|
|
60
|
-
return next(i);
|
|
61
|
-
});
|
|
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);
|
|
62
73
|
};
|
|
63
74
|
return next(0);
|
|
64
75
|
}
|
|
65
76
|
/**
|
|
66
|
-
* @
|
|
67
|
-
* @param
|
|
68
|
-
* @
|
|
69
|
-
* @returns {void}
|
|
77
|
+
* @param data the value to store
|
|
78
|
+
* @param callback signals when the value is stored
|
|
79
|
+
* @returns
|
|
70
80
|
*/
|
|
71
81
|
store(data, callback) {
|
|
72
|
-
|
|
82
|
+
neo_async_1.default.each(this._items, (item, callback) => item.store(data, callback), callback);
|
|
73
83
|
}
|
|
74
84
|
/**
|
|
75
|
-
* @
|
|
76
|
-
* @
|
|
77
|
-
* @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
|
|
78
87
|
*/
|
|
79
|
-
storePromise(data) {
|
|
80
|
-
|
|
88
|
+
async storePromise(data) {
|
|
89
|
+
await Promise.all(this._items.map(item => item.storePromise(data)));
|
|
81
90
|
}
|
|
82
91
|
}
|
|
92
|
+
exports.MultiItemCache = MultiItemCache;
|
|
83
93
|
class ItemCacheFacade {
|
|
84
94
|
/**
|
|
85
|
-
* @param
|
|
86
|
-
* @param
|
|
87
|
-
* @param
|
|
95
|
+
* @param cache the root cache
|
|
96
|
+
* @param name the child cache item name
|
|
97
|
+
* @param etag the etag
|
|
98
|
+
* @returns
|
|
88
99
|
*/
|
|
89
100
|
constructor(cache, name, etag) {
|
|
90
101
|
this._cache = cache;
|
|
@@ -92,16 +103,14 @@ class ItemCacheFacade {
|
|
|
92
103
|
this._etag = etag;
|
|
93
104
|
}
|
|
94
105
|
/**
|
|
95
|
-
* @
|
|
96
|
-
* @
|
|
97
|
-
* @returns {void}
|
|
106
|
+
* @param callback signals when the value is retrieved
|
|
107
|
+
* @returns
|
|
98
108
|
*/
|
|
99
109
|
get(callback) {
|
|
100
110
|
this._cache.get(this._name, this._etag, callback);
|
|
101
111
|
}
|
|
102
112
|
/**
|
|
103
|
-
* @
|
|
104
|
-
* @returns {Promise<T>} promise with the data
|
|
113
|
+
* @returns promise with the data
|
|
105
114
|
*/
|
|
106
115
|
getPromise() {
|
|
107
116
|
return new Promise((resolve, reject) => {
|
|
@@ -116,18 +125,16 @@ class ItemCacheFacade {
|
|
|
116
125
|
});
|
|
117
126
|
}
|
|
118
127
|
/**
|
|
119
|
-
* @
|
|
120
|
-
* @param
|
|
121
|
-
* @
|
|
122
|
-
* @returns {void}
|
|
128
|
+
* @param data the value to store
|
|
129
|
+
* @param callback signals when the value is stored
|
|
130
|
+
* @returns
|
|
123
131
|
*/
|
|
124
132
|
store(data, callback) {
|
|
125
133
|
this._cache.store(this._name, this._etag, data, callback);
|
|
126
134
|
}
|
|
127
135
|
/**
|
|
128
|
-
* @
|
|
129
|
-
* @
|
|
130
|
-
* @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
|
|
131
138
|
*/
|
|
132
139
|
storePromise(data) {
|
|
133
140
|
return new Promise((resolve, reject) => {
|
|
@@ -142,10 +149,9 @@ class ItemCacheFacade {
|
|
|
142
149
|
});
|
|
143
150
|
}
|
|
144
151
|
/**
|
|
145
|
-
* @
|
|
146
|
-
* @param
|
|
147
|
-
* @
|
|
148
|
-
* @returns {void}
|
|
152
|
+
* @param computer function to compute the value if not cached
|
|
153
|
+
* @param callback signals when the value is retrieved
|
|
154
|
+
* @returns
|
|
149
155
|
*/
|
|
150
156
|
provide(computer, callback) {
|
|
151
157
|
this.get((err, cacheEntry) => {
|
|
@@ -165,9 +171,8 @@ class ItemCacheFacade {
|
|
|
165
171
|
});
|
|
166
172
|
}
|
|
167
173
|
/**
|
|
168
|
-
* @
|
|
169
|
-
* @
|
|
170
|
-
* @returns {Promise<T>} promise with the data
|
|
174
|
+
* @param computer function to compute the value if not cached
|
|
175
|
+
* @returns promise with the data
|
|
171
176
|
*/
|
|
172
177
|
async providePromise(computer) {
|
|
173
178
|
const cacheEntry = await this.getPromise();
|
|
@@ -178,11 +183,12 @@ class ItemCacheFacade {
|
|
|
178
183
|
return result;
|
|
179
184
|
}
|
|
180
185
|
}
|
|
186
|
+
exports.ItemCacheFacade = ItemCacheFacade;
|
|
181
187
|
class CacheFacade {
|
|
182
188
|
/**
|
|
183
|
-
* @param
|
|
184
|
-
* @param
|
|
185
|
-
* @param
|
|
189
|
+
* @param cache the root cache
|
|
190
|
+
* @param name the child cache name
|
|
191
|
+
* @param hashFunction the hash function to use
|
|
186
192
|
*/
|
|
187
193
|
constructor(cache, name, hashFunction) {
|
|
188
194
|
this._cache = cache;
|
|
@@ -190,50 +196,48 @@ class CacheFacade {
|
|
|
190
196
|
this._hashFunction = hashFunction;
|
|
191
197
|
}
|
|
192
198
|
/**
|
|
193
|
-
* @param
|
|
194
|
-
* @returns
|
|
199
|
+
* @param name the child cache name#
|
|
200
|
+
* @returns child cache
|
|
195
201
|
*/
|
|
196
202
|
getChildCache(name) {
|
|
197
203
|
return new CacheFacade(this._cache, `${this._name}|${name}`, this._hashFunction);
|
|
198
204
|
}
|
|
199
205
|
/**
|
|
200
|
-
* @param
|
|
201
|
-
* @param
|
|
202
|
-
* @returns
|
|
206
|
+
* @param identifier the cache identifier
|
|
207
|
+
* @param etag the etag
|
|
208
|
+
* @returns item cache
|
|
203
209
|
*/
|
|
204
210
|
getItemCache(identifier, etag) {
|
|
205
211
|
return new ItemCacheFacade(this._cache, `${this._name}|${identifier}`, etag);
|
|
206
212
|
}
|
|
207
213
|
/**
|
|
208
|
-
* @param
|
|
209
|
-
* @returns
|
|
214
|
+
* @param obj an hashable object
|
|
215
|
+
* @returns an etag that is lazy hashed
|
|
210
216
|
*/
|
|
211
217
|
getLazyHashedEtag(obj) {
|
|
212
|
-
return
|
|
218
|
+
return (0, getLazyHashedEtag_js_1.getter)(obj, this._hashFunction);
|
|
213
219
|
}
|
|
214
220
|
/**
|
|
215
|
-
* @param
|
|
216
|
-
* @param
|
|
217
|
-
* @returns
|
|
221
|
+
* @param a an etag
|
|
222
|
+
* @param b another etag
|
|
223
|
+
* @returns an etag that represents both
|
|
218
224
|
*/
|
|
219
225
|
mergeEtags(a, b) {
|
|
220
|
-
return mergeEtags(a, b);
|
|
226
|
+
return (0, mergeEtags_js_1.mergeEtags)(a, b);
|
|
221
227
|
}
|
|
222
228
|
/**
|
|
223
|
-
* @
|
|
224
|
-
* @param
|
|
225
|
-
* @param
|
|
226
|
-
* @
|
|
227
|
-
* @returns {void}
|
|
229
|
+
* @param identifier the cache identifier
|
|
230
|
+
* @param etag the etag
|
|
231
|
+
* @param callback signals when the value is retrieved
|
|
232
|
+
* @returns
|
|
228
233
|
*/
|
|
229
234
|
get(identifier, etag, callback) {
|
|
230
235
|
this._cache.get(`${this._name}|${identifier}`, etag, callback);
|
|
231
236
|
}
|
|
232
237
|
/**
|
|
233
|
-
* @
|
|
234
|
-
* @param
|
|
235
|
-
* @
|
|
236
|
-
* @returns {Promise<T>} promise with the data
|
|
238
|
+
* @param identifier the cache identifier
|
|
239
|
+
* @param etag the etag
|
|
240
|
+
* @returns promise with the data
|
|
237
241
|
*/
|
|
238
242
|
getPromise(identifier, etag) {
|
|
239
243
|
return new Promise((resolve, reject) => {
|
|
@@ -248,22 +252,20 @@ class CacheFacade {
|
|
|
248
252
|
});
|
|
249
253
|
}
|
|
250
254
|
/**
|
|
251
|
-
* @
|
|
252
|
-
* @param
|
|
253
|
-
* @param
|
|
254
|
-
* @param
|
|
255
|
-
* @
|
|
256
|
-
* @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
|
|
257
260
|
*/
|
|
258
261
|
store(identifier, etag, data, callback) {
|
|
259
262
|
this._cache.store(`${this._name}|${identifier}`, etag, data, callback);
|
|
260
263
|
}
|
|
261
264
|
/**
|
|
262
|
-
* @
|
|
263
|
-
* @param
|
|
264
|
-
* @param
|
|
265
|
-
* @
|
|
266
|
-
* @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
|
|
267
269
|
*/
|
|
268
270
|
storePromise(identifier, etag, data) {
|
|
269
271
|
return new Promise((resolve, reject) => {
|
|
@@ -278,12 +280,11 @@ class CacheFacade {
|
|
|
278
280
|
});
|
|
279
281
|
}
|
|
280
282
|
/**
|
|
281
|
-
* @
|
|
282
|
-
* @param
|
|
283
|
-
* @param
|
|
284
|
-
* @param
|
|
285
|
-
* @
|
|
286
|
-
* @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
|
|
287
288
|
*/
|
|
288
289
|
provide(identifier, etag, computer, callback) {
|
|
289
290
|
this.get(identifier, etag, (err, cacheEntry) => {
|
|
@@ -303,11 +304,10 @@ class CacheFacade {
|
|
|
303
304
|
});
|
|
304
305
|
}
|
|
305
306
|
/**
|
|
306
|
-
* @
|
|
307
|
-
* @param
|
|
308
|
-
* @param
|
|
309
|
-
* @
|
|
310
|
-
* @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
|
|
311
311
|
*/
|
|
312
312
|
async providePromise(identifier, etag, computer) {
|
|
313
313
|
const cacheEntry = await this.getPromise(identifier, etag);
|
|
@@ -318,6 +318,5 @@ class CacheFacade {
|
|
|
318
318
|
return result;
|
|
319
319
|
}
|
|
320
320
|
}
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
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;
|