@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.
Files changed (181) hide show
  1. package/compiled/zod/index.d.ts +138 -52
  2. package/compiled/zod/index.js +300 -103
  3. package/compiled/zod/package.json +1 -1
  4. package/compiled/zod-validation-error/index.js +6 -6
  5. package/dist/Compilation.d.ts +22 -4
  6. package/dist/Compilation.js +64 -49
  7. package/dist/Compiler.d.ts +11 -10
  8. package/dist/Compiler.js +42 -42
  9. package/dist/ErrorHelpers.js +2 -4
  10. package/dist/Module.d.ts +1 -0
  11. package/dist/Module.js +3 -6
  12. package/dist/ModuleTypeConstants.d.ts +45 -69
  13. package/dist/ModuleTypeConstants.js +24 -77
  14. package/dist/NormalModule.d.ts +1 -0
  15. package/dist/NormalModule.js +1 -0
  16. package/dist/Stats.js +4 -6
  17. package/dist/Template.d.ts +31 -147
  18. package/dist/Template.js +40 -236
  19. package/dist/builtin-loader/lightningcss/index.d.ts +89 -0
  20. package/dist/builtin-loader/lightningcss/index.js +175 -0
  21. package/dist/builtin-plugin/APIPlugin.d.ts +1 -1
  22. package/dist/builtin-plugin/ArrayPushCallbackChunkFormatPlugin.d.ts +1 -1
  23. package/dist/builtin-plugin/AssetModulesPlugin.d.ts +1 -1
  24. package/dist/builtin-plugin/AsyncWebAssemblyModulesPlugin.d.ts +1 -1
  25. package/dist/builtin-plugin/BannerPlugin.d.ts +25 -49
  26. package/dist/builtin-plugin/BundlerInfoRspackPlugin.d.ts +1 -1
  27. package/dist/builtin-plugin/ChunkPrefetchPreloadPlugin.d.ts +1 -1
  28. package/dist/builtin-plugin/CommonJsChunkFormatPlugin.d.ts +1 -1
  29. package/dist/builtin-plugin/CopyRspackPlugin.d.ts +1 -1
  30. package/dist/builtin-plugin/CssModulesPlugin.d.ts +1 -1
  31. package/dist/builtin-plugin/DataUriPlugin.d.ts +1 -1
  32. package/dist/builtin-plugin/DefinePlugin.d.ts +1 -1
  33. package/dist/builtin-plugin/DefinePlugin.js +9 -13
  34. package/dist/builtin-plugin/DeterministicChunkIdsPlugin.d.ts +1 -1
  35. package/dist/builtin-plugin/DeterministicModuleIdsPlugin.d.ts +1 -1
  36. package/dist/builtin-plugin/DynamicEntryPlugin.d.ts +1 -1
  37. package/dist/builtin-plugin/ElectronTargetPlugin.d.ts +1 -1
  38. package/dist/builtin-plugin/EnableChunkLoadingPlugin.d.ts +1 -1
  39. package/dist/builtin-plugin/EnableWasmLoadingPlugin.d.ts +1 -1
  40. package/dist/builtin-plugin/EnsureChunkConditionsPlugin.d.ts +1 -1
  41. package/dist/builtin-plugin/EntryPlugin.d.ts +4 -3
  42. package/dist/builtin-plugin/EntryPlugin.js +1 -0
  43. package/dist/builtin-plugin/EvalDevToolModulePlugin.d.ts +1 -1
  44. package/dist/builtin-plugin/EvalSourceMapDevToolPlugin.d.ts +1 -1
  45. package/dist/builtin-plugin/ExternalsPlugin.d.ts +29 -5
  46. package/dist/builtin-plugin/FetchCompileAsyncWasmPlugin.d.ts +1 -1
  47. package/dist/builtin-plugin/FileUriPlugin.d.ts +1 -1
  48. package/dist/builtin-plugin/FlagDependencyExportsPlugin.d.ts +1 -1
  49. package/dist/builtin-plugin/FlagDependencyUsagePlugin.d.ts +1 -1
  50. package/dist/builtin-plugin/HtmlRspackPlugin.d.ts +9 -9
  51. package/dist/builtin-plugin/HttpExternalsRspackPlugin.d.ts +1 -1
  52. package/dist/builtin-plugin/IgnorePlugin.d.ts +1 -1
  53. package/dist/builtin-plugin/InferAsyncModulesPlugin.d.ts +1 -1
  54. package/dist/builtin-plugin/JavascriptModulesPlugin.d.ts +2 -2
  55. package/dist/builtin-plugin/JsLoaderRspackPlugin.d.ts +1 -1
  56. package/dist/builtin-plugin/JsonModulesPlugin.d.ts +1 -1
  57. package/dist/builtin-plugin/LightningCssMiminizerRspackPlugin.d.ts +1 -1
  58. package/dist/builtin-plugin/LightningCssMiminizerRspackPlugin.js +4 -1
  59. package/dist/builtin-plugin/LimitChunkCountPlugin.d.ts +1 -1
  60. package/dist/builtin-plugin/MangleExportsPlugin.d.ts +1 -1
  61. package/dist/builtin-plugin/MergeDuplicateChunksPlugin.d.ts +1 -1
  62. package/dist/builtin-plugin/ModuleChunkFormatPlugin.d.ts +1 -1
  63. package/dist/builtin-plugin/ModuleConcatenationPlugin.d.ts +1 -1
  64. package/dist/builtin-plugin/NamedChunkIdsPlugin.d.ts +1 -1
  65. package/dist/builtin-plugin/NamedModuleIdsPlugin.d.ts +1 -1
  66. package/dist/builtin-plugin/NaturalChunkIdsPlugin.d.ts +1 -1
  67. package/dist/builtin-plugin/NaturalModuleIdsPlugin.d.ts +1 -1
  68. package/dist/builtin-plugin/NodeTargetPlugin.d.ts +1 -1
  69. package/dist/builtin-plugin/ProgressPlugin.d.ts +1 -1
  70. package/dist/builtin-plugin/ProvidePlugin.d.ts +1 -1
  71. package/dist/builtin-plugin/RealContentHashPlugin.d.ts +1 -1
  72. package/dist/builtin-plugin/RemoveEmptyChunksPlugin.d.ts +1 -1
  73. package/dist/builtin-plugin/RuntimeChunkPlugin.d.ts +1 -1
  74. package/dist/builtin-plugin/RuntimePlugin.d.ts +1 -1
  75. package/dist/builtin-plugin/SideEffectsFlagPlugin.d.ts +1 -1
  76. package/dist/builtin-plugin/SizeLimitsPlugin.d.ts +1 -1
  77. package/dist/builtin-plugin/SourceMapDevToolPlugin.d.ts +1 -1
  78. package/dist/builtin-plugin/SplitChunksPlugin.js +5 -15
  79. package/dist/builtin-plugin/SwcCssMinimizerPlugin.d.ts +1 -1
  80. package/dist/builtin-plugin/SwcJsMinimizerPlugin.d.ts +1 -1
  81. package/dist/builtin-plugin/SwcJsMinimizerPlugin.js +15 -23
  82. package/dist/builtin-plugin/WarnCaseSensitiveModulesPlugin.d.ts +1 -1
  83. package/dist/builtin-plugin/WebWorkerTemplatePlugin.d.ts +1 -1
  84. package/dist/builtin-plugin/base.d.ts +1 -1
  85. package/dist/builtin-plugin/base.js +1 -3
  86. package/dist/builtin-plugin/css-extract/hmr/hotModuleReplacement.d.ts +3 -3
  87. package/dist/builtin-plugin/css-extract/hmr/hotModuleReplacement.js +17 -66
  88. package/dist/builtin-plugin/css-extract/hmr/normalizeUrl.d.ts +2 -0
  89. package/dist/builtin-plugin/css-extract/hmr/{normalize-url.js → normalizeUrl.js} +15 -24
  90. package/dist/builtin-plugin/css-extract/loader.d.ts +8 -3
  91. package/dist/builtin-plugin/css-extract/loader.js +28 -17
  92. package/dist/builtin-plugin/lazy-compilation/lazyCompilation.d.ts +1 -1
  93. package/dist/config/adapter.d.ts +1 -1
  94. package/dist/config/adapter.js +39 -25
  95. package/dist/config/adapterRuleUse.d.ts +5 -5
  96. package/dist/config/adapterRuleUse.js +23 -1
  97. package/dist/config/browserslistTargetHandler.d.ts +17 -15
  98. package/dist/config/browserslistTargetHandler.js +27 -33
  99. package/dist/config/defaults.js +27 -31
  100. package/dist/config/normalization.d.ts +8 -3
  101. package/dist/config/normalization.js +7 -5
  102. package/dist/config/target.d.ts +48 -109
  103. package/dist/config/target.js +50 -86
  104. package/dist/config/zod.d.ts +2660 -2305
  105. package/dist/config/zod.js +38 -19
  106. package/dist/container/ContainerPlugin.d.ts +7 -7
  107. package/dist/container/ContainerReferencePlugin.d.ts +1 -1
  108. package/dist/container/ModuleFederationRuntimePlugin.d.ts +1 -1
  109. package/dist/container/options.js +1 -1
  110. package/dist/exports.d.ts +4 -4
  111. package/dist/exports.js +2 -2
  112. package/dist/lib/AbstractMethodError.d.ts +12 -3
  113. package/dist/lib/AbstractMethodError.js +29 -21
  114. package/dist/lib/Cache.d.ts +40 -46
  115. package/dist/lib/Cache.js +43 -78
  116. package/dist/lib/CacheFacade.d.ts +119 -143
  117. package/dist/lib/CacheFacade.js +123 -123
  118. package/dist/lib/EntryOptionPlugin.d.ts +19 -2
  119. package/dist/lib/EntryOptionPlugin.js +22 -6
  120. package/dist/lib/EnvironmentPlugin.d.ts +17 -10
  121. package/dist/lib/EnvironmentPlugin.js +16 -15
  122. package/dist/lib/HookWebpackError.d.ts +27 -33
  123. package/dist/lib/HookWebpackError.js +33 -34
  124. package/dist/lib/IgnoreWarningsPlugin.d.ts +25 -0
  125. package/dist/lib/{ignoreWarningsPlugin.js → IgnoreWarningsPlugin.js} +17 -0
  126. package/dist/lib/LoaderOptionsPlugin.d.ts +18 -9
  127. package/dist/lib/LoaderOptionsPlugin.js +38 -14
  128. package/dist/lib/LoaderTargetPlugin.d.ts +17 -8
  129. package/dist/lib/LoaderTargetPlugin.js +17 -15
  130. package/dist/lib/ModuleFilenameHelpers.d.ts +10 -1
  131. package/dist/lib/ModuleFilenameHelpers.js +10 -3
  132. package/dist/lib/NormalModuleReplacementPlugin.d.ts +15 -5
  133. package/dist/lib/NormalModuleReplacementPlugin.js +15 -5
  134. package/dist/lib/WebpackError.d.ts +29 -22
  135. package/dist/lib/WebpackError.js +17 -29
  136. package/dist/lib/cache/getLazyHashedEtag.d.ts +24 -24
  137. package/dist/lib/cache/getLazyHashedEtag.js +20 -23
  138. package/dist/lib/cache/mergeEtags.d.ts +15 -9
  139. package/dist/lib/cache/mergeEtags.js +23 -22
  140. package/dist/lib/formatLocation.d.ts +13 -8
  141. package/dist/lib/formatLocation.js +20 -20
  142. package/dist/loader-runner/LoaderLoadingError.d.ts +11 -1
  143. package/dist/loader-runner/LoaderLoadingError.js +3 -5
  144. package/dist/loader-runner/index.js +7 -9
  145. package/dist/loader-runner/loadLoader.d.ts +11 -2
  146. package/dist/loader-runner/loadLoader.js +17 -19
  147. package/dist/logging/createConsoleLogger.js +2 -6
  148. package/dist/logging/truncateArgs.js +5 -9
  149. package/dist/node/nodeConsole.js +1 -3
  150. package/dist/rspackOptionsApply.js +2 -2
  151. package/dist/stats/DefaultStatsFactoryPlugin.js +18 -8
  152. package/dist/stats/DefaultStatsPresetPlugin.js +4 -4
  153. package/dist/stats/DefaultStatsPrinterPlugin.js +11 -16
  154. package/dist/stats/StatsFactory.js +13 -17
  155. package/dist/stats/StatsPrinter.js +7 -9
  156. package/dist/util/AssetInfo.js +11 -7
  157. package/dist/util/SplitChunkSize.js +1 -1
  158. package/dist/util/cleverMerge.d.ts +33 -57
  159. package/dist/util/cleverMerge.js +89 -145
  160. package/dist/util/comparators.d.ts +1 -1
  161. package/dist/util/comparators.js +3 -5
  162. package/dist/util/createHash.d.ts +4 -3
  163. package/dist/util/createHash.js +31 -45
  164. package/dist/util/fs.js +9 -13
  165. package/dist/util/hash/BatchedHash.d.ts +24 -9
  166. package/dist/util/hash/BatchedHash.js +16 -13
  167. package/dist/util/hash/index.d.ts +9 -9
  168. package/dist/util/hash/index.js +14 -11
  169. package/dist/util/hash/md4.d.ts +29 -2
  170. package/dist/util/hash/md4.js +7 -3
  171. package/dist/util/hash/wasm-hash.d.ts +52 -5
  172. package/dist/util/hash/wasm-hash.js +19 -22
  173. package/dist/util/hash/xxhash64.d.ts +29 -2
  174. package/dist/util/hash/xxhash64.js +7 -3
  175. package/dist/util/identifier.js +9 -15
  176. package/dist/util/index.js +1 -1
  177. package/dist/util/memoize.js +7 -9
  178. package/package.json +9 -8
  179. package/compiled/enhanced-resolve/index.js +0 -5566
  180. package/dist/builtin-plugin/css-extract/hmr/normalize-url.d.ts +0 -2
  181. package/dist/lib/ignoreWarningsPlugin.d.ts +0 -7
@@ -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
- * @template T
18
- * @callback CallbackCache
19
- * @param {(WebpackError | null)=} err
20
- * @param {T=} result
21
- * @returns {void}
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 {ItemCacheFacade[]} items item caches
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 /** @type {any} */ (items[0]);
54
+ return items[0];
38
55
  }
39
56
  /**
40
- * @template T
41
- * @param {CallbackCache<T>} callback signals when the value is retrieved
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
- * @template T
50
- * @returns {Promise<T>} promise with the data
64
+ * @returns promise with the data
51
65
  */
52
66
  getPromise() {
53
- // @ts-expect-error
54
- const next = i => {
55
- return this._items[i].getPromise().then(result => {
56
- if (result !== undefined)
57
- return result;
58
- if (++i < this._items.length)
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
- * @template T
66
- * @param {T} data the value to store
67
- * @param {CallbackCache<void>} callback signals when the value is stored
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
- asyncLib.each(this._items, (item, callback) => item.store(data, callback), callback);
82
+ neo_async_1.default.each(this._items, (item, callback) => item.store(data, callback), callback);
72
83
  }
73
84
  /**
74
- * @template T
75
- * @param {T} data the value to store
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
- return Promise.all(this._items.map(item => item.storePromise(data))).then(() => { });
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 {Cache} cache the root cache
85
- * @param {string} name the child cache item name
86
- * @param {Etag | null} etag the etag
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
- * @template T
95
- * @param {CallbackCache<T>} callback signals when the value is retrieved
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
- * @template T
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
- * @template T
119
- * @param {T} data the value to store
120
- * @param {CallbackCache<void>} callback signals when the value is stored
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
- * @template T
128
- * @param {T} data the value to store
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
- * @template T
145
- * @param {function(CallbackNormalErrorCache<T>): void} computer function to compute the value if not cached
146
- * @param {CallbackNormalErrorCache<T>} callback signals when the value is retrieved
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
- * @template T
168
- * @param {function(): Promise<T> | T} computer function to compute the value if not cached
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 {Cache} cache the root cache
183
- * @param {string} name the child cache name
184
- * @param {string | HashConstructor} hashFunction the hash function to use
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 {string} name the child cache name#
193
- * @returns {CacheFacade} child cache
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 {string} identifier the cache identifier
200
- * @param {Etag | null} etag the etag
201
- * @returns {ItemCacheFacade} item cache
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 {HashableObject} obj an hashable object
208
- * @returns {Etag} an etag that is lazy hashed
214
+ * @param obj an hashable object
215
+ * @returns an etag that is lazy hashed
209
216
  */
210
217
  getLazyHashedEtag(obj) {
211
- return getLazyHashedEtag(obj, this._hashFunction);
218
+ return (0, getLazyHashedEtag_js_1.getter)(obj, this._hashFunction);
212
219
  }
213
220
  /**
214
- * @param {Etag} a an etag
215
- * @param {Etag} b another etag
216
- * @returns {Etag} an etag that represents both
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
- * @template T
223
- * @param {string} identifier the cache identifier
224
- * @param {Etag | null} etag the etag
225
- * @param {CallbackCache<T>} callback signals when the value is retrieved
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
- * @template T
233
- * @param {string} identifier the cache identifier
234
- * @param {Etag | null} etag the etag
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
- * @template T
251
- * @param {string} identifier the cache identifier
252
- * @param {Etag | null} etag the etag
253
- * @param {T} data the value to store
254
- * @param {CallbackCache<void>} callback signals when the value is stored
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
- * @template T
262
- * @param {string} identifier the cache identifier
263
- * @param {Etag | null} etag the etag
264
- * @param {T} data the value to store
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
- * @template T
281
- * @param {string} identifier the cache identifier
282
- * @param {Etag | null} etag the etag
283
- * @param {function(CallbackNormalErrorCache<T>): void} computer function to compute the value if not cached
284
- * @param {CallbackNormalErrorCache<T>} callback signals when the value is retrieved
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
- * @template T
306
- * @param {string} identifier the cache identifier
307
- * @param {Etag | null} etag the etag
308
- * @param {function(): Promise<T> | T} computer function to compute the value if not cached
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
- module.exports = CacheFacade;
321
- module.exports.ItemCacheFacade = ItemCacheFacade;
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 { type EntryOptions } from "../builtin-plugin";
12
- export default class EntryOptionPlugin {
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
- // layer: desc.layer,
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
- // if (desc.layer !== undefined && !compiler.options.experiments.layers) {
54
- // throw new Error(
55
- // "'entryOptions.layer' is only allowed when 'experiments.layers' is enabled"
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
- export type Compiler = any;
2
- export type CodeValue = any;
3
- /** @typedef {any} Compiler */
4
- /** @typedef {any} CodeValue */
5
- export class EnvironmentPlugin {
6
- constructor(...keys: any[]);
7
- keys: any[];
8
- defaultValues: any;
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 {Compiler} compiler the compiler instance
12
- * @returns {void}
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 WebpackError = require("./WebpackError");
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 {Compiler} compiler the compiler instance
33
- * @returns {void}
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 WebpackError(`EnvironmentPlugin - ${key} environment variable is undefined.\n\n` +
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
- * @template T
5
- * @callback Callback
6
- * @param {Error=} err
7
- * @param {T=} stats
8
- * @returns {void}
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
- declare class HookWebpackError extends WebpackError {
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 {Error} error inner error
14
- * @param {string} hook name of hook
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
- import WebpackError = require("./WebpackError.js");
22
+ export default HookWebpackError;
25
23
  /**
26
- * @param {Error} error an error
27
- * @param {string} hook name of the hook
28
- * @returns {WebpackError} a webpack error
24
+ * @param error an error
25
+ * @param hook name of the hook
26
+ * @returns a webpack error
29
27
  */
30
- declare function makeWebpackError(error: Error, hook: string): WebpackError;
28
+ export declare const makeWebpackError: (error: Error, hook: string) => WebpackError;
31
29
  /**
32
- * @template T
33
- * @param {function((WebpackError | null)=, T=): void} callback webpack error callback
34
- * @param {string} hook name of hook
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 function makeWebpackErrorCallback<T>(callback: (arg0?: (WebpackError | null) | undefined, arg1?: T | undefined) => void, hook: string): Callback<T>;
34
+ export declare const makeWebpackErrorCallback: <T>(callback: (error?: WebpackError | null, result?: T | undefined) => void, hook: string) => Callback<Error, T>;
38
35
  /**
39
- * @template T
40
- * @param {function(): T} fn function which will be wrapping in try catch
41
- * @param {string} hook name of hook
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 function tryRunOrWebpackError<T>(fn: () => T, hook: string): T;
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;