@rspack/core 0.1.8 → 0.1.10

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 (120) hide show
  1. package/dist/ContextModuleFactory.d.ts +13 -0
  2. package/dist/ContextModuleFactory.d.ts.map +1 -0
  3. package/dist/ContextModuleFactory.js +40 -0
  4. package/dist/ContextModuleFactory.js.map +1 -0
  5. package/dist/RuleSetCompiler.d.ts +6 -0
  6. package/dist/RuleSetCompiler.d.ts.map +1 -0
  7. package/dist/RuleSetCompiler.js +10 -0
  8. package/dist/RuleSetCompiler.js.map +1 -0
  9. package/dist/compilation.d.ts +30 -11
  10. package/dist/compilation.d.ts.map +1 -1
  11. package/dist/compilation.js +48 -12
  12. package/dist/compilation.js.map +1 -1
  13. package/dist/compiler.d.ts +24 -4
  14. package/dist/compiler.d.ts.map +1 -1
  15. package/dist/compiler.js +233 -14
  16. package/dist/compiler.js.map +1 -1
  17. package/dist/config/adapter-rule-use.d.ts +64 -6
  18. package/dist/config/adapter-rule-use.d.ts.map +1 -1
  19. package/dist/config/adapter-rule-use.js +45 -392
  20. package/dist/config/adapter-rule-use.js.map +1 -1
  21. package/dist/config/adapter.d.ts +6 -3
  22. package/dist/config/adapter.d.ts.map +1 -1
  23. package/dist/config/adapter.js +85 -16
  24. package/dist/config/adapter.js.map +1 -1
  25. package/dist/config/builtins.d.ts +24 -2
  26. package/dist/config/builtins.d.ts.map +1 -1
  27. package/dist/config/builtins.js +44 -4
  28. package/dist/config/builtins.js.map +1 -1
  29. package/dist/config/defaults.d.ts.map +1 -1
  30. package/dist/config/defaults.js +128 -40
  31. package/dist/config/defaults.js.map +1 -1
  32. package/dist/config/normalization.d.ts.map +1 -1
  33. package/dist/config/normalization.js +26 -1
  34. package/dist/config/normalization.js.map +1 -1
  35. package/dist/config/schema.check.d.ts.map +1 -1
  36. package/dist/config/schema.check.js +2449 -1684
  37. package/dist/config/schema.check.js.map +1 -1
  38. package/dist/config/schema.d.ts +1131 -950
  39. package/dist/config/schema.js +149 -0
  40. package/dist/config/schema.js.map +1 -1
  41. package/dist/config/types.d.ts +63 -4
  42. package/dist/config/types.d.ts.map +1 -1
  43. package/dist/lib/Cache.d.ts +72 -0
  44. package/dist/lib/Cache.d.ts.map +1 -0
  45. package/dist/lib/Cache.js +131 -0
  46. package/dist/lib/Cache.js.map +1 -0
  47. package/dist/lib/CacheFacade.d.ts +192 -0
  48. package/dist/lib/CacheFacade.d.ts.map +1 -0
  49. package/dist/lib/CacheFacade.js +320 -0
  50. package/dist/lib/CacheFacade.js.map +1 -0
  51. package/dist/lib/HookWebpackError.d.ts +47 -0
  52. package/dist/lib/HookWebpackError.d.ts.map +1 -0
  53. package/dist/lib/HookWebpackError.js +83 -0
  54. package/dist/lib/HookWebpackError.js.map +1 -0
  55. package/dist/lib/WebpackError.d.ts +24 -0
  56. package/dist/lib/WebpackError.d.ts.map +1 -0
  57. package/dist/lib/WebpackError.js +35 -0
  58. package/dist/lib/WebpackError.js.map +1 -0
  59. package/dist/lib/cache/getLazyHashedEtag.d.ts +36 -0
  60. package/dist/lib/cache/getLazyHashedEtag.d.ts.map +1 -0
  61. package/dist/lib/cache/getLazyHashedEtag.js +74 -0
  62. package/dist/lib/cache/getLazyHashedEtag.js.map +1 -0
  63. package/dist/lib/cache/mergeEtags.d.ts +12 -0
  64. package/dist/lib/cache/mergeEtags.d.ts.map +1 -0
  65. package/dist/lib/cache/mergeEtags.js +72 -0
  66. package/dist/lib/cache/mergeEtags.js.map +1 -0
  67. package/dist/lib/ignoreWarningsPlugin.d.ts +8 -0
  68. package/dist/lib/ignoreWarningsPlugin.d.ts.map +1 -0
  69. package/dist/lib/ignoreWarningsPlugin.js +19 -0
  70. package/dist/lib/ignoreWarningsPlugin.js.map +1 -0
  71. package/dist/loader-runner/LoaderLoadingError.d.ts +5 -0
  72. package/dist/loader-runner/LoaderLoadingError.d.ts.map +1 -0
  73. package/dist/loader-runner/LoaderLoadingError.js +19 -0
  74. package/dist/loader-runner/LoaderLoadingError.js.map +1 -0
  75. package/dist/loader-runner/index.d.ts +18 -0
  76. package/dist/loader-runner/index.d.ts.map +1 -0
  77. package/dist/loader-runner/index.js +678 -0
  78. package/dist/loader-runner/index.js.map +1 -0
  79. package/dist/loader-runner/loadLoader.d.ts +3 -0
  80. package/dist/loader-runner/loadLoader.d.ts.map +1 -0
  81. package/dist/loader-runner/loadLoader.js +69 -0
  82. package/dist/loader-runner/loadLoader.js.map +1 -0
  83. package/dist/multiStats.d.ts.map +1 -1
  84. package/dist/multiStats.js +4 -1
  85. package/dist/multiStats.js.map +1 -1
  86. package/dist/normalModule.d.ts +6 -0
  87. package/dist/normalModule.d.ts.map +1 -0
  88. package/dist/normalModule.js +84 -0
  89. package/dist/normalModule.js.map +1 -0
  90. package/dist/normalModuleFactory.d.ts +5 -0
  91. package/dist/normalModuleFactory.d.ts.map +1 -1
  92. package/dist/normalModuleFactory.js +2 -8
  93. package/dist/normalModuleFactory.js.map +1 -1
  94. package/dist/rspack.d.ts.map +1 -1
  95. package/dist/rspack.js +4 -0
  96. package/dist/rspack.js.map +1 -1
  97. package/dist/stats.d.ts +2 -0
  98. package/dist/stats.d.ts.map +1 -1
  99. package/dist/stats.js +2 -2
  100. package/dist/stats.js.map +1 -1
  101. package/dist/util/fake.d.ts +2 -0
  102. package/dist/util/fake.d.ts.map +1 -1
  103. package/dist/util/fake.js +2 -0
  104. package/dist/util/fake.js.map +1 -1
  105. package/dist/util/index.d.ts +6 -1
  106. package/dist/util/index.d.ts.map +1 -1
  107. package/dist/util/index.js +42 -2
  108. package/dist/util/index.js.map +1 -1
  109. package/dist/util/scheme.d.ts +7 -0
  110. package/dist/util/scheme.d.ts.map +1 -0
  111. package/dist/util/scheme.js +58 -0
  112. package/dist/util/scheme.js.map +1 -0
  113. package/dist/util/webpack.d.ts +5 -0
  114. package/dist/util/webpack.d.ts.map +1 -0
  115. package/dist/util/webpack.js +27 -0
  116. package/dist/util/webpack.js.map +1 -0
  117. package/dist/watching.d.ts.map +1 -1
  118. package/dist/watching.js +1 -1
  119. package/dist/watching.js.map +1 -1
  120. package/package.json +10 -10
@@ -0,0 +1,320 @@
1
+ /*
2
+ MIT License http://www.opensource.org/licenses/mit-license.php
3
+ Author Tobias Koppers @sokra
4
+ */
5
+ "use strict";
6
+ const { forEachBail } = require("enhanced-resolve");
7
+ const asyncLib = require("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
+ /**
16
+ * @template T
17
+ * @callback CallbackCache
18
+ * @param {(WebpackError | null)=} err
19
+ * @param {T=} result
20
+ * @returns {void}
21
+ */
22
+ /**
23
+ * @template T
24
+ * @callback CallbackNormalErrorCache
25
+ * @param {(Error | null)=} err
26
+ * @param {T=} result
27
+ * @returns {void}
28
+ */
29
+ class MultiItemCache {
30
+ /**
31
+ * @param {ItemCacheFacade[]} items item caches
32
+ */
33
+ constructor(items) {
34
+ this._items = items;
35
+ if (items.length === 1)
36
+ return /** @type {any} */ (items[0]);
37
+ }
38
+ /**
39
+ * @template T
40
+ * @param {CallbackCache<T>} callback signals when the value is retrieved
41
+ * @returns {void}
42
+ */
43
+ get(callback) {
44
+ forEachBail(this._items, (item, callback) => item.get(callback), callback);
45
+ }
46
+ /**
47
+ * @template T
48
+ * @returns {Promise<T>} promise with the data
49
+ */
50
+ getPromise() {
51
+ const next = i => {
52
+ return this._items[i].getPromise().then(result => {
53
+ if (result !== undefined)
54
+ return result;
55
+ if (++i < this._items.length)
56
+ return next(i);
57
+ });
58
+ };
59
+ return next(0);
60
+ }
61
+ /**
62
+ * @template T
63
+ * @param {T} data the value to store
64
+ * @param {CallbackCache<void>} callback signals when the value is stored
65
+ * @returns {void}
66
+ */
67
+ store(data, callback) {
68
+ asyncLib.each(this._items, (item, callback) => item.store(data, callback), callback);
69
+ }
70
+ /**
71
+ * @template T
72
+ * @param {T} data the value to store
73
+ * @returns {Promise<void>} promise signals when the value is stored
74
+ */
75
+ storePromise(data) {
76
+ return Promise.all(this._items.map(item => item.storePromise(data))).then(() => { });
77
+ }
78
+ }
79
+ class ItemCacheFacade {
80
+ /**
81
+ * @param {Cache} cache the root cache
82
+ * @param {string} name the child cache item name
83
+ * @param {Etag | null} etag the etag
84
+ */
85
+ constructor(cache, name, etag) {
86
+ this._cache = cache;
87
+ this._name = name;
88
+ this._etag = etag;
89
+ }
90
+ /**
91
+ * @template T
92
+ * @param {CallbackCache<T>} callback signals when the value is retrieved
93
+ * @returns {void}
94
+ */
95
+ get(callback) {
96
+ this._cache.get(this._name, this._etag, callback);
97
+ }
98
+ /**
99
+ * @template T
100
+ * @returns {Promise<T>} promise with the data
101
+ */
102
+ getPromise() {
103
+ return new Promise((resolve, reject) => {
104
+ this._cache.get(this._name, this._etag, (err, data) => {
105
+ if (err) {
106
+ reject(err);
107
+ }
108
+ else {
109
+ resolve(data);
110
+ }
111
+ });
112
+ });
113
+ }
114
+ /**
115
+ * @template T
116
+ * @param {T} data the value to store
117
+ * @param {CallbackCache<void>} callback signals when the value is stored
118
+ * @returns {void}
119
+ */
120
+ store(data, callback) {
121
+ this._cache.store(this._name, this._etag, data, callback);
122
+ }
123
+ /**
124
+ * @template T
125
+ * @param {T} data the value to store
126
+ * @returns {Promise<void>} promise signals when the value is stored
127
+ */
128
+ storePromise(data) {
129
+ return new Promise((resolve, reject) => {
130
+ this._cache.store(this._name, this._etag, data, err => {
131
+ if (err) {
132
+ reject(err);
133
+ }
134
+ else {
135
+ resolve();
136
+ }
137
+ });
138
+ });
139
+ }
140
+ /**
141
+ * @template T
142
+ * @param {function(CallbackNormalErrorCache<T>): void} computer function to compute the value if not cached
143
+ * @param {CallbackNormalErrorCache<T>} callback signals when the value is retrieved
144
+ * @returns {void}
145
+ */
146
+ provide(computer, callback) {
147
+ this.get((err, cacheEntry) => {
148
+ if (err)
149
+ return callback(err);
150
+ if (cacheEntry !== undefined)
151
+ return cacheEntry;
152
+ computer((err, result) => {
153
+ if (err)
154
+ return callback(err);
155
+ this.store(result, err => {
156
+ if (err)
157
+ return callback(err);
158
+ callback(null, result);
159
+ });
160
+ });
161
+ });
162
+ }
163
+ /**
164
+ * @template T
165
+ * @param {function(): Promise<T> | T} computer function to compute the value if not cached
166
+ * @returns {Promise<T>} promise with the data
167
+ */
168
+ async providePromise(computer) {
169
+ const cacheEntry = await this.getPromise();
170
+ if (cacheEntry !== undefined)
171
+ return cacheEntry;
172
+ const result = await computer();
173
+ await this.storePromise(result);
174
+ return result;
175
+ }
176
+ }
177
+ class CacheFacade {
178
+ /**
179
+ * @param {Cache} cache the root cache
180
+ * @param {string} name the child cache name
181
+ * @param {string | HashConstructor} hashFunction the hash function to use
182
+ */
183
+ constructor(cache, name, hashFunction) {
184
+ this._cache = cache;
185
+ this._name = name;
186
+ this._hashFunction = hashFunction;
187
+ }
188
+ /**
189
+ * @param {string} name the child cache name#
190
+ * @returns {CacheFacade} child cache
191
+ */
192
+ getChildCache(name) {
193
+ return new CacheFacade(this._cache, `${this._name}|${name}`, this._hashFunction);
194
+ }
195
+ /**
196
+ * @param {string} identifier the cache identifier
197
+ * @param {Etag | null} etag the etag
198
+ * @returns {ItemCacheFacade} item cache
199
+ */
200
+ getItemCache(identifier, etag) {
201
+ return new ItemCacheFacade(this._cache, `${this._name}|${identifier}`, etag);
202
+ }
203
+ /**
204
+ * @param {HashableObject} obj an hashable object
205
+ * @returns {Etag} an etag that is lazy hashed
206
+ */
207
+ getLazyHashedEtag(obj) {
208
+ return getLazyHashedEtag(obj, this._hashFunction);
209
+ }
210
+ /**
211
+ * @param {Etag} a an etag
212
+ * @param {Etag} b another etag
213
+ * @returns {Etag} an etag that represents both
214
+ */
215
+ mergeEtags(a, b) {
216
+ return mergeEtags(a, b);
217
+ }
218
+ /**
219
+ * @template T
220
+ * @param {string} identifier the cache identifier
221
+ * @param {Etag | null} etag the etag
222
+ * @param {CallbackCache<T>} callback signals when the value is retrieved
223
+ * @returns {void}
224
+ */
225
+ get(identifier, etag, callback) {
226
+ this._cache.get(`${this._name}|${identifier}`, etag, callback);
227
+ }
228
+ /**
229
+ * @template T
230
+ * @param {string} identifier the cache identifier
231
+ * @param {Etag | null} etag the etag
232
+ * @returns {Promise<T>} promise with the data
233
+ */
234
+ getPromise(identifier, etag) {
235
+ return new Promise((resolve, reject) => {
236
+ this._cache.get(`${this._name}|${identifier}`, etag, (err, data) => {
237
+ if (err) {
238
+ reject(err);
239
+ }
240
+ else {
241
+ resolve(data);
242
+ }
243
+ });
244
+ });
245
+ }
246
+ /**
247
+ * @template T
248
+ * @param {string} identifier the cache identifier
249
+ * @param {Etag | null} etag the etag
250
+ * @param {T} data the value to store
251
+ * @param {CallbackCache<void>} callback signals when the value is stored
252
+ * @returns {void}
253
+ */
254
+ store(identifier, etag, data, callback) {
255
+ this._cache.store(`${this._name}|${identifier}`, etag, data, callback);
256
+ }
257
+ /**
258
+ * @template T
259
+ * @param {string} identifier the cache identifier
260
+ * @param {Etag | null} etag the etag
261
+ * @param {T} data the value to store
262
+ * @returns {Promise<void>} promise signals when the value is stored
263
+ */
264
+ storePromise(identifier, etag, data) {
265
+ return new Promise((resolve, reject) => {
266
+ this._cache.store(`${this._name}|${identifier}`, etag, data, err => {
267
+ if (err) {
268
+ reject(err);
269
+ }
270
+ else {
271
+ resolve();
272
+ }
273
+ });
274
+ });
275
+ }
276
+ /**
277
+ * @template T
278
+ * @param {string} identifier the cache identifier
279
+ * @param {Etag | null} etag the etag
280
+ * @param {function(CallbackNormalErrorCache<T>): void} computer function to compute the value if not cached
281
+ * @param {CallbackNormalErrorCache<T>} callback signals when the value is retrieved
282
+ * @returns {void}
283
+ */
284
+ provide(identifier, etag, computer, callback) {
285
+ this.get(identifier, etag, (err, cacheEntry) => {
286
+ if (err)
287
+ return callback(err);
288
+ if (cacheEntry !== undefined)
289
+ return cacheEntry;
290
+ computer((err, result) => {
291
+ if (err)
292
+ return callback(err);
293
+ this.store(identifier, etag, result, err => {
294
+ if (err)
295
+ return callback(err);
296
+ callback(null, result);
297
+ });
298
+ });
299
+ });
300
+ }
301
+ /**
302
+ * @template T
303
+ * @param {string} identifier the cache identifier
304
+ * @param {Etag | null} etag the etag
305
+ * @param {function(): Promise<T> | T} computer function to compute the value if not cached
306
+ * @returns {Promise<T>} promise with the data
307
+ */
308
+ async providePromise(identifier, etag, computer) {
309
+ const cacheEntry = await this.getPromise(identifier, etag);
310
+ if (cacheEntry !== undefined)
311
+ return cacheEntry;
312
+ const result = await computer();
313
+ await this.storePromise(identifier, etag, result);
314
+ return result;
315
+ }
316
+ }
317
+ module.exports = CacheFacade;
318
+ module.exports.ItemCacheFacade = ItemCacheFacade;
319
+ module.exports.MultiItemCache = MultiItemCache;
320
+ //# sourceMappingURL=CacheFacade.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"CacheFacade.js","sourceRoot":"","sources":["../../src/lib/CacheFacade.js"],"names":[],"mappings":"AAAA;;;EAGE;AAEF,YAAY,CAAC;AAEb,MAAM,EAAE,WAAW,EAAE,GAAG,OAAO,CAAC,kBAAkB,CAAC,CAAC;AACpD,MAAM,QAAQ,GAAG,OAAO,CAAC,WAAW,CAAC,CAAC;AACtC,MAAM,iBAAiB,GAAG,OAAO,CAAC,8BAA8B,CAAC,CAAC;AAClE,MAAM,UAAU,GAAG,OAAO,CAAC,uBAAuB,CAAC,CAAC;AAEpD,yCAAyC;AACzC,6CAA6C;AAC7C,uDAAuD;AACvD,mFAAmF;AACnF,8DAA8D;AAE9D;;;;;;GAMG;AAEH;;;;;;GAMG;AAEH,MAAM,cAAc;IACnB;;OAEG;IACH,YAAY,KAAK;QAChB,IAAI,CAAC,MAAM,GAAG,KAAK,CAAC;QACpB,IAAI,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AC,IAAI,EAAE,MAAM,CAAC,CAAC;gBACxB,CAAC,CAAC,CAAC;YACJ,CAAC,CAAC,CAAC;QACJ,CAAC,CAAC,CAAC;IACJ,CAAC;IAED;;;;;;OAMG;IACH,KAAK,CAAC,cAAc,CAAC,UAAU,EAAE,IAAI,EAAE,QAAQ;QAC9C,MAAM,UAAU,GAAG,MAAM,IAAI,CAAC,UAAU,CAAC,UAAU,EAAE,IAAI,CAAC,CAAC;QAC3D,IAAI,UAAU,KAAK,SAAS;YAAE,OAAO,UAAU,CAAC;QAChD,MAAM,MAAM,GAAG,MAAM,QAAQ,EAAE,CAAC;QAChC,MAAM,IAAI,CAAC,YAAY,CAAC,UAAU,EAAE,IAAI,EAAE,MAAM,CAAC,CAAC;QAClD,OAAO,MAAM,CAAC;IACf,CAAC;CACD;AAED,MAAM,CAAC,OAAO,GAAG,WAAW,CAAC;AAC7B,MAAM,CAAC,OAAO,CAAC,eAAe,GAAG,eAAe,CAAC;AACjD,MAAM,CAAC,OAAO,CAAC,cAAc,GAAG,cAAc,CAAC"}
@@ -0,0 +1,47 @@
1
+ export = HookWebpackError;
2
+ /** @typedef {import("./Module")} Module */
3
+ /**
4
+ * @template T
5
+ * @callback Callback
6
+ * @param {Error=} err
7
+ * @param {T=} stats
8
+ * @returns {void}
9
+ */
10
+ declare class HookWebpackError extends WebpackError {
11
+ /**
12
+ * Creates an instance of HookWebpackError.
13
+ * @param {Error} error inner error
14
+ * @param {string} hook name of hook
15
+ */
16
+ 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
+ }
24
+ import WebpackError = require("./WebpackError.js");
25
+ /**
26
+ * @param {Error} error an error
27
+ * @param {string} hook name of the hook
28
+ * @returns {WebpackError} a webpack error
29
+ */
30
+ declare function makeWebpackError(error: Error, hook: string): WebpackError;
31
+ /**
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
36
+ */
37
+ declare function makeWebpackErrorCallback<T>(callback: (arg0?: (WebpackError | null) | undefined, arg1?: T | undefined) => void, hook: string): Callback<T>;
38
+ /**
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
43
+ */
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;
47
+ //# sourceMappingURL=HookWebpackError.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"HookWebpackError.d.ts","sourceRoot":"","sources":["../../src/lib/HookWebpackError.js"],"names":[],"mappings":";AASA,2CAA2C;AAE3C;;;;;;GAMG;AAEH;IACC;;;;OAIG;IACH,mBAHW,KAAK,QACL,MAAM,EAYhB;IANA,aAAgB;IAChB,aAAkB;IAElB,gBAA6D;CAI9D;;;;;AAID;;;;GAIG;AACH,yCAJW,KAAK,QACL,MAAM,GACJ,YAAY,CAKxB;AAGD;;;;;GAKG;AACH,+DAJoB,CAAC,YAAY,GAAG,IAAI,CAAC,uCAAQ,IAAI,QAC1C,MAAM,eAehB;AAID;;;;;GAKG;AACH,4DAHW,MAAM,KAchB;;0BA5EU,KAAK,sBACL,CAAC,iBACC,IAAI"}
@@ -0,0 +1,83 @@
1
+ /*
2
+ MIT License http://www.opensource.org/licenses/mit-license.php
3
+ Author Sean Larkin @thelarkinn
4
+ */
5
+ "use strict";
6
+ const WebpackError = require("./WebpackError.js");
7
+ /** @typedef {import("./Module")} Module */
8
+ /**
9
+ * @template T
10
+ * @callback Callback
11
+ * @param {Error=} err
12
+ * @param {T=} stats
13
+ * @returns {void}
14
+ */
15
+ class HookWebpackError extends WebpackError {
16
+ /**
17
+ * Creates an instance of HookWebpackError.
18
+ * @param {Error} error inner error
19
+ * @param {string} hook name of hook
20
+ */
21
+ constructor(error, hook) {
22
+ super(error.message);
23
+ this.name = "HookWebpackError";
24
+ this.hook = hook;
25
+ this.error = error;
26
+ this.hideStack = true;
27
+ this.details = `caused by plugins in ${hook}\n${error.stack}`;
28
+ this.stack += `\n-- inner error --\n${error.stack}`;
29
+ }
30
+ }
31
+ module.exports = HookWebpackError;
32
+ /**
33
+ * @param {Error} error an error
34
+ * @param {string} hook name of the hook
35
+ * @returns {WebpackError} a webpack error
36
+ */
37
+ const makeWebpackError = (error, hook) => {
38
+ if (error instanceof WebpackError)
39
+ return error;
40
+ return new HookWebpackError(error, hook);
41
+ };
42
+ module.exports.makeWebpackError = makeWebpackError;
43
+ /**
44
+ * @template T
45
+ * @param {function((WebpackError | null)=, T=): void} callback webpack error callback
46
+ * @param {string} hook name of hook
47
+ * @returns {Callback<T>} generic callback
48
+ */
49
+ const makeWebpackErrorCallback = (callback, hook) => {
50
+ return (err, result) => {
51
+ if (err) {
52
+ if (err instanceof WebpackError) {
53
+ callback(err);
54
+ return;
55
+ }
56
+ callback(new HookWebpackError(err, hook));
57
+ return;
58
+ }
59
+ callback(null, result);
60
+ };
61
+ };
62
+ module.exports.makeWebpackErrorCallback = makeWebpackErrorCallback;
63
+ /**
64
+ * @template T
65
+ * @param {function(): T} fn function which will be wrapping in try catch
66
+ * @param {string} hook name of hook
67
+ * @returns {T} the result
68
+ */
69
+ const tryRunOrWebpackError = (fn, hook) => {
70
+ let r;
71
+ try {
72
+ r = fn();
73
+ }
74
+ catch (err) {
75
+ if (err instanceof WebpackError) {
76
+ throw err;
77
+ }
78
+ throw new HookWebpackError(err, hook);
79
+ }
80
+ return r;
81
+ };
82
+ module.exports.tryRunOrWebpackError = tryRunOrWebpackError;
83
+ //# sourceMappingURL=HookWebpackError.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"HookWebpackError.js","sourceRoot":"","sources":["../../src/lib/HookWebpackError.js"],"names":[],"mappings":"AAAA;;;EAGE;AAEF,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AAC,IAAI,EAAE,MAAM,CAAC,CAAC;IACxB,CAAC,CAAC;AACH,CAAC,CAAC;AAEF,MAAM,CAAC,OAAO,CAAC,wBAAwB,GAAG,wBAAwB,CAAC;AAEnE;;;;;GAKG;AACH,MAAM,oBAAoB,GAAG,CAAC,EAAE,EAAE,IAAI,EAAE,EAAE;IACzC,IAAI,CAAC,CAAC;IACN,IAAI;QACH,CAAC,GAAG,EAAE,EAAE,CAAC;KACT;IAAC,OAAO,GAAG,EAAE;QACb,IAAI,GAAG,YAAY,YAAY,EAAE;YAChC,MAAM,GAAG,CAAC;SACV;QACD,MAAM,IAAI,gBAAgB,CAAC,GAAG,EAAE,IAAI,CAAC,CAAC;KACtC;IACD,OAAO,CAAC,CAAC;AACV,CAAC,CAAC;AAEF,MAAM,CAAC,OAAO,CAAC,oBAAoB,GAAG,oBAAoB,CAAC"}
@@ -0,0 +1,24 @@
1
+ export = WebpackError;
2
+ /** @typedef {import("./Chunk")} Chunk */
3
+ /** @typedef {import("./Dependency").DependencyLocation} DependencyLocation */
4
+ /** @typedef {import("./Module")} Module */
5
+ declare class WebpackError extends Error {
6
+ details: any;
7
+ /** @type {Module} */
8
+ module: any;
9
+ /** @type {DependencyLocation} */
10
+ loc: any;
11
+ /** @type {boolean} */
12
+ hideStack: boolean;
13
+ /** @type {Chunk} */
14
+ chunk: any;
15
+ /** @type {string} */
16
+ file: string;
17
+ }
18
+ declare namespace WebpackError {
19
+ export { Chunk, DependencyLocation, Module };
20
+ }
21
+ type Chunk = any;
22
+ type DependencyLocation = any;
23
+ type Module = any;
24
+ //# sourceMappingURL=WebpackError.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"WebpackError.d.ts","sourceRoot":"","sources":["../../src/lib/WebpackError.js"],"names":[],"mappings":";AASA,yCAAyC;AACzC,8EAA8E;AAC9E,2CAA2C;AAE3C;IAQE,aAAwB;IACxB,qBAAqB;IACrB,YAAuB;IACvB,iCAAiC;IACjC,SAAoB;IACpB,sBAAsB;IACtB,WADW,OAAO,CACQ;IAC1B,oBAAoB;IACpB,WAAsB;IACtB,qBAAqB;IACrB,MADW,MAAM,CACI;CAwBtB"}
@@ -0,0 +1,35 @@
1
+ /*
2
+ MIT License http://www.opensource.org/licenses/mit-license.php
3
+ Author Jarid Margolin @jaridmargolin
4
+ */
5
+ "use strict";
6
+ const inspect = require("util").inspect.custom;
7
+ /** @typedef {import("./Chunk")} Chunk */
8
+ /** @typedef {import("./Dependency").DependencyLocation} DependencyLocation */
9
+ /** @typedef {import("./Module")} Module */
10
+ class WebpackError extends Error {
11
+ /**
12
+ * Creates an instance of WebpackError.
13
+ * @param {string=} message error message
14
+ */
15
+ constructor(message) {
16
+ super(message);
17
+ this.details = undefined;
18
+ /** @type {Module} */
19
+ this.module = undefined;
20
+ /** @type {DependencyLocation} */
21
+ this.loc = undefined;
22
+ /** @type {boolean} */
23
+ this.hideStack = undefined;
24
+ /** @type {Chunk} */
25
+ this.chunk = undefined;
26
+ /** @type {string} */
27
+ this.file = undefined;
28
+ }
29
+ [inspect]() {
30
+ return this.stack + (this.details ? `\n${this.details}` : "");
31
+ }
32
+ }
33
+ // makeSerializable(WebpackError, "webpack/lib/WebpackError");
34
+ module.exports = WebpackError;
35
+ //# sourceMappingURL=WebpackError.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"WebpackError.js","sourceRoot":"","sources":["../../src/lib/WebpackError.js"],"names":[],"mappings":"AAAA;;;EAGE;AAEF,YAAY,CAAC;AAEb,MAAM,OAAO,GAAG,OAAO,CAAC,MAAM,CAAC,CAAC,OAAO,CAAC,MAAM,CAAC;AAE/C,yCAAyC;AACzC,8EAA8E;AAC9E,2CAA2C;AAE3C,MAAM,YAAa,SAAQ,KAAK;IAC/B;;;OAGG;IACH,YAAY,OAAO;QAClB,KAAK,CAAC,OAAO,CAAC,CAAC;QAEf,IAAI,CAAC,OAAO,GAAG,SAAS,CAAC;QACzB,qBAAqB;QACrB,IAAI,CAAC,MAAM,GAAG,SAAS,CAAC;QACxB,iCAAiC;QACjC,IAAI,CAAC,GAAG,GAAG,SAAS,CAAC;QACrB,sBAAsB;QACtB,IAAI,CAAC,SAAS,GAAG,SAAS,CAAC;QAC3B,oBAAoB;QACpB,IAAI,CAAC,KAAK,GAAG,SAAS,CAAC;QACvB,qBAAqB;QACrB,IAAI,CAAC,IAAI,GAAG,SAAS,CAAC;IACvB,CAAC;IAED,CAAC,OAAO,CAAC;QACR,OAAO,IAAI,CAAC,KAAK,GAAG,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC,CAAC,KAAK,IAAI,CAAC,OAAO,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC;IAC/D,CAAC;CAmBD;AAED,8DAA8D;AAE9D,MAAM,CAAC,OAAO,GAAG,YAAY,CAAC"}
@@ -0,0 +1,36 @@
1
+ export = getter;
2
+ /**
3
+ * @param {HashableObject} obj object with updateHash method
4
+ * @param {string | HashConstructor} hashFunction the hash function to use
5
+ * @returns {LazyHashedEtag} etag
6
+ */
7
+ declare function getter(obj: HashableObject, hashFunction?: string | HashConstructor): LazyHashedEtag;
8
+ declare namespace getter {
9
+ export { Hash, HashConstructor, HashableObject };
10
+ }
11
+ type HashableObject = {
12
+ updateHash: (arg0: Hash) => void;
13
+ };
14
+ type HashConstructor = typeof import("../util/Hash");
15
+ /** @typedef {import("../util/Hash")} Hash */
16
+ /** @typedef {typeof import("../util/Hash")} HashConstructor */
17
+ /**
18
+ * @typedef {Object} HashableObject
19
+ * @property {function(Hash): void} updateHash
20
+ */
21
+ declare class LazyHashedEtag {
22
+ /**
23
+ * @param {HashableObject} obj object with updateHash method
24
+ * @param {string | HashConstructor} hashFunction the hash function to use
25
+ */
26
+ constructor(obj: HashableObject, hashFunction?: string | HashConstructor);
27
+ _obj: HashableObject;
28
+ _hash: string | undefined;
29
+ _hashFunction: any;
30
+ /**
31
+ * @returns {string} hash of object
32
+ */
33
+ toString(): string;
34
+ }
35
+ type Hash = any;
36
+ //# sourceMappingURL=getLazyHashedEtag.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"getLazyHashedEtag.d.ts","sourceRoot":"","sources":["../../../src/lib/cache/getLazyHashedEtag.js"],"names":[],"mappings":";AA+CA;;;;GAIG;AACH,6BAJW,cAAc,iBACd,MAAM,GAAG,eAAe,GACtB,cAAc,CA4B1B;;;;;uBAhEsB,IAAI,KAAG,IAAI;;uBAJpB,cAAc,cAAc,CAAC;AAD3C,6CAA6C;AAC7C,+DAA+D;AAE/D;;;GAGG;AAEH;IACC;;;OAGG;IACH,iBAHW,cAAc,iBACd,MAAM,GAAG,eAAe,EAMlC;IAHA,qBAAe;IACf,0BAAsB;IACtB,mBAAiC;IAGlC;;OAEG;IACH,YAFa,MAAM,CASlB;CACD"}
@@ -0,0 +1,74 @@
1
+ /*
2
+ MIT License http://www.opensource.org/licenses/mit-license.php
3
+ Author Tobias Koppers @sokra
4
+ */
5
+ "use strict";
6
+ const createHash = require("../../util/createHash");
7
+ /** @typedef {import("../util/Hash")} Hash */
8
+ /** @typedef {typeof import("../util/Hash")} HashConstructor */
9
+ /**
10
+ * @typedef {Object} HashableObject
11
+ * @property {function(Hash): void} updateHash
12
+ */
13
+ class LazyHashedEtag {
14
+ /**
15
+ * @param {HashableObject} obj object with updateHash method
16
+ * @param {string | HashConstructor} hashFunction the hash function to use
17
+ */
18
+ constructor(obj, hashFunction = "md4") {
19
+ this._obj = obj;
20
+ this._hash = undefined;
21
+ this._hashFunction = hashFunction;
22
+ }
23
+ /**
24
+ * @returns {string} hash of object
25
+ */
26
+ toString() {
27
+ if (this._hash === undefined) {
28
+ const hash = createHash(this._hashFunction);
29
+ this._obj.updateHash(hash);
30
+ this._hash = /** @type {string} */ (hash.digest("base64"));
31
+ }
32
+ return this._hash;
33
+ }
34
+ }
35
+ /** @type {Map<string | HashConstructor, WeakMap<HashableObject, LazyHashedEtag>>} */
36
+ const mapStrings = new Map();
37
+ /** @type {WeakMap<HashConstructor, WeakMap<HashableObject, LazyHashedEtag>>} */
38
+ const mapObjects = new WeakMap();
39
+ /**
40
+ * @param {HashableObject} obj object with updateHash method
41
+ * @param {string | HashConstructor} hashFunction the hash function to use
42
+ * @returns {LazyHashedEtag} etag
43
+ */
44
+ const getter = (obj, hashFunction = "md4") => {
45
+ let innerMap;
46
+ if (typeof hashFunction === "string") {
47
+ innerMap = mapStrings.get(hashFunction);
48
+ if (innerMap === undefined) {
49
+ const newHash = new LazyHashedEtag(obj, hashFunction);
50
+ innerMap = new WeakMap();
51
+ innerMap.set(obj, newHash);
52
+ mapStrings.set(hashFunction, innerMap);
53
+ return newHash;
54
+ }
55
+ }
56
+ else {
57
+ innerMap = mapObjects.get(hashFunction);
58
+ if (innerMap === undefined) {
59
+ const newHash = new LazyHashedEtag(obj, hashFunction);
60
+ innerMap = new WeakMap();
61
+ innerMap.set(obj, newHash);
62
+ mapObjects.set(hashFunction, innerMap);
63
+ return newHash;
64
+ }
65
+ }
66
+ const hash = innerMap.get(obj);
67
+ if (hash !== undefined)
68
+ return hash;
69
+ const newHash = new LazyHashedEtag(obj, hashFunction);
70
+ innerMap.set(obj, newHash);
71
+ return newHash;
72
+ };
73
+ module.exports = getter;
74
+ //# sourceMappingURL=getLazyHashedEtag.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"getLazyHashedEtag.js","sourceRoot":"","sources":["../../../src/lib/cache/getLazyHashedEtag.js"],"names":[],"mappings":"AAAA;;;EAGE;AAEF,YAAY,CAAC;AAEb,MAAM,UAAU,GAAG,OAAO,CAAC,uBAAuB,CAAC,CAAC;AAEpD,6CAA6C;AAC7C,+DAA+D;AAE/D;;;GAGG;AAEH,MAAM,cAAc;IACnB;;;OAGG;IACH,YAAY,GAAG,EAAE,YAAY,GAAG,KAAK;QACpC,IAAI,CAAC,IAAI,GAAG,GAAG,CAAC;QAChB,IAAI,CAAC,KAAK,GAAG,SAAS,CAAC;QACvB,IAAI,CAAC,aAAa,GAAG,YAAY,CAAC;IACnC,CAAC;IAED;;OAE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AAQ,CAAC,GAAG,CAAC,GAAG,EAAE,OAAO,CAAC,CAAC;YAC3B,UAAU,CAAC,GAAG,CAAC,YAAY,EAAE,QAAQ,CAAC,CAAC;YACvC,OAAO,OAAO,CAAC;SACf;KACD;IACD,MAAM,IAAI,GAAG,QAAQ,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;IAC/B,IAAI,IAAI,KAAK,SAAS;QAAE,OAAO,IAAI,CAAC;IACpC,MAAM,OAAO,GAAG,IAAI,cAAc,CAAC,GAAG,EAAE,YAAY,CAAC,CAAC;IACtD,QAAQ,CAAC,GAAG,CAAC,GAAG,EAAE,OAAO,CAAC,CAAC;IAC3B,OAAO,OAAO,CAAC;AAChB,CAAC,CAAC;AAEF,MAAM,CAAC,OAAO,GAAG,MAAM,CAAC"}
@@ -0,0 +1,12 @@
1
+ export = mergeEtags;
2
+ /**
3
+ * @param {Etag} a first
4
+ * @param {Etag} b second
5
+ * @returns {Etag} result
6
+ */
7
+ declare function mergeEtags(a: Etag, b: Etag): Etag;
8
+ declare namespace mergeEtags {
9
+ export { Etag };
10
+ }
11
+ type Etag = import("../Cache").Etag;
12
+ //# sourceMappingURL=mergeEtags.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"mergeEtags.d.ts","sourceRoot":"","sources":["../../../src/lib/cache/mergeEtags.js"],"names":[],"mappings":";AA2BA;;;;GAIG;AACH,+BAJW,IAAI,KACJ,IAAI,GACF,IAAI,CAyChB;;;;YAhEa,OAAO,UAAU,EAAE,IAAI"}