@rspack/core 1.0.10 → 1.0.11

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 (217) hide show
  1. package/dist/builtin-plugin/css-extract/utils.d.ts +1 -0
  2. package/dist/config/types.d.ts +309 -0
  3. package/dist/config/zod.d.ts +22 -534
  4. package/dist/cssExtractHmr.js +224 -0
  5. package/dist/cssExtractLoader.js +277 -0
  6. package/dist/index.js +23347 -31
  7. package/dist/{builtin-plugin/css-extract/hmr/hotModuleReplacement.d.ts → runtime/cssExtractHmr.d.ts} +1 -0
  8. package/dist/runtime/moduleFederationDefaultRuntime.d.ts +2 -0
  9. package/dist/stats/statsFactoryUtils.d.ts +1 -0
  10. package/package.json +8 -5
  11. package/compiled/json-parse-even-better-errors/index.d.ts +0 -1
  12. package/compiled/json-parse-even-better-errors/index.js +0 -193
  13. package/compiled/json-parse-even-better-errors/package.json +0 -1
  14. package/compiled/neo-async/index.d.ts +0 -685
  15. package/compiled/neo-async/index.js +0 -9207
  16. package/compiled/neo-async/license +0 -22
  17. package/compiled/neo-async/package.json +0 -1
  18. package/compiled/zod-validation-error/index.d.ts +0 -41
  19. package/compiled/zod-validation-error/index.js +0 -335
  20. package/compiled/zod-validation-error/license +0 -9
  21. package/compiled/zod-validation-error/package.json +0 -1
  22. package/dist/Chunk.js +0 -118
  23. package/dist/ChunkGraph.js +0 -27
  24. package/dist/ChunkGroup.js +0 -76
  25. package/dist/Compilation.js +0 -854
  26. package/dist/Compiler.js +0 -925
  27. package/dist/ContextModuleFactory.js +0 -36
  28. package/dist/DependenciesBlock.js +0 -30
  29. package/dist/Dependency.js +0 -43
  30. package/dist/Entrypoint.js +0 -21
  31. package/dist/ErrorHelpers.js +0 -62
  32. package/dist/ExecuteModulePlugin.js +0 -46
  33. package/dist/FileSystem.js +0 -34
  34. package/dist/FileSystemInfo.js +0 -2
  35. package/dist/Module.js +0 -226
  36. package/dist/ModuleTypeConstants.js +0 -92
  37. package/dist/MultiCompiler.js +0 -440
  38. package/dist/MultiStats.js +0 -161
  39. package/dist/MultiWatching.js +0 -62
  40. package/dist/NormalModule.js +0 -97
  41. package/dist/NormalModuleFactory.js +0 -43
  42. package/dist/Resolver.js +0 -39
  43. package/dist/ResolverFactory.js +0 -61
  44. package/dist/RspackError.js +0 -21
  45. package/dist/RuleSetCompiler.js +0 -10
  46. package/dist/RuntimeGlobals.js +0 -357
  47. package/dist/RuntimeModule.js +0 -58
  48. package/dist/Stats.js +0 -161
  49. package/dist/Template.js +0 -206
  50. package/dist/Watching.js +0 -290
  51. package/dist/builtin-loader/index.js +0 -17
  52. package/dist/builtin-loader/lightningcss/index.js +0 -175
  53. package/dist/builtin-loader/swc/index.js +0 -5
  54. package/dist/builtin-loader/swc/pluginImport.js +0 -35
  55. package/dist/builtin-loader/swc/react.js +0 -7
  56. package/dist/builtin-loader/swc/types.js +0 -2
  57. package/dist/builtin-plugin/APIPlugin.js +0 -6
  58. package/dist/builtin-plugin/ArrayPushCallbackChunkFormatPlugin.js +0 -6
  59. package/dist/builtin-plugin/AssetModulesPlugin.js +0 -6
  60. package/dist/builtin-plugin/AsyncWebAssemblyModulesPlugin.js +0 -6
  61. package/dist/builtin-plugin/BannerPlugin.js +0 -22
  62. package/dist/builtin-plugin/BundlerInfoRspackPlugin.js +0 -12
  63. package/dist/builtin-plugin/ChunkPrefetchPreloadPlugin.js +0 -6
  64. package/dist/builtin-plugin/CommonJsChunkFormatPlugin.js +0 -6
  65. package/dist/builtin-plugin/ContextReplacementPlugin.js +0 -43
  66. package/dist/builtin-plugin/CopyRspackPlugin.js +0 -21
  67. package/dist/builtin-plugin/CssModulesPlugin.js +0 -6
  68. package/dist/builtin-plugin/DataUriPlugin.js +0 -6
  69. package/dist/builtin-plugin/DefinePlugin.js +0 -44
  70. package/dist/builtin-plugin/DeterministicChunkIdsPlugin.js +0 -6
  71. package/dist/builtin-plugin/DeterministicModuleIdsPlugin.js +0 -6
  72. package/dist/builtin-plugin/DynamicEntryPlugin.js +0 -36
  73. package/dist/builtin-plugin/ElectronTargetPlugin.js +0 -6
  74. package/dist/builtin-plugin/EnableChunkLoadingPlugin.js +0 -6
  75. package/dist/builtin-plugin/EnableLibraryPlugin.js +0 -39
  76. package/dist/builtin-plugin/EnableWasmLoadingPlugin.js +0 -6
  77. package/dist/builtin-plugin/EnsureChunkConditionsPlugin.js +0 -6
  78. package/dist/builtin-plugin/EntryPlugin.js +0 -34
  79. package/dist/builtin-plugin/EvalDevToolModulePlugin.js +0 -6
  80. package/dist/builtin-plugin/EvalSourceMapDevToolPlugin.js +0 -16
  81. package/dist/builtin-plugin/ExternalsPlugin.js +0 -51
  82. package/dist/builtin-plugin/FetchCompileAsyncWasmPlugin.js +0 -6
  83. package/dist/builtin-plugin/FileUriPlugin.js +0 -6
  84. package/dist/builtin-plugin/FlagDependencyExportsPlugin.js +0 -6
  85. package/dist/builtin-plugin/FlagDependencyUsagePlugin.js +0 -6
  86. package/dist/builtin-plugin/HotModuleReplacementPlugin.js +0 -18
  87. package/dist/builtin-plugin/HtmlRspackPlugin.js +0 -285
  88. package/dist/builtin-plugin/HttpExternalsRspackPlugin.js +0 -11
  89. package/dist/builtin-plugin/IgnorePlugin.js +0 -20
  90. package/dist/builtin-plugin/InferAsyncModulesPlugin.js +0 -6
  91. package/dist/builtin-plugin/JavascriptModulesPlugin.js +0 -55
  92. package/dist/builtin-plugin/JsLoaderRspackPlugin.js +0 -9
  93. package/dist/builtin-plugin/JsonModulesPlugin.js +0 -6
  94. package/dist/builtin-plugin/LightningCssMiminizerRspackPlugin.js +0 -30
  95. package/dist/builtin-plugin/LimitChunkCountPlugin.js +0 -8
  96. package/dist/builtin-plugin/MangleExportsPlugin.js +0 -6
  97. package/dist/builtin-plugin/MergeDuplicateChunksPlugin.js +0 -6
  98. package/dist/builtin-plugin/ModuleChunkFormatPlugin.js +0 -6
  99. package/dist/builtin-plugin/ModuleConcatenationPlugin.js +0 -6
  100. package/dist/builtin-plugin/NamedChunkIdsPlugin.js +0 -6
  101. package/dist/builtin-plugin/NamedModuleIdsPlugin.js +0 -6
  102. package/dist/builtin-plugin/NaturalChunkIdsPlugin.js +0 -6
  103. package/dist/builtin-plugin/NaturalModuleIdsPlugin.js +0 -6
  104. package/dist/builtin-plugin/NoEmitOnErrorsPlugin.js +0 -6
  105. package/dist/builtin-plugin/NodeTargetPlugin.js +0 -6
  106. package/dist/builtin-plugin/ProgressPlugin.js +0 -15
  107. package/dist/builtin-plugin/ProvidePlugin.js +0 -14
  108. package/dist/builtin-plugin/RealContentHashPlugin.js +0 -6
  109. package/dist/builtin-plugin/RemoveEmptyChunksPlugin.js +0 -6
  110. package/dist/builtin-plugin/RuntimeChunkPlugin.js +0 -6
  111. package/dist/builtin-plugin/RuntimePlugin.js +0 -6
  112. package/dist/builtin-plugin/SideEffectsFlagPlugin.js +0 -6
  113. package/dist/builtin-plugin/SizeLimitsPlugin.js +0 -9
  114. package/dist/builtin-plugin/SourceMapDevToolPlugin.js +0 -14
  115. package/dist/builtin-plugin/SplitChunksPlugin.js +0 -92
  116. package/dist/builtin-plugin/SwcJsMinimizerPlugin.js +0 -80
  117. package/dist/builtin-plugin/WarnCaseSensitiveModulesPlugin.js +0 -6
  118. package/dist/builtin-plugin/WebWorkerTemplatePlugin.js +0 -6
  119. package/dist/builtin-plugin/WorkerPlugin.js +0 -31
  120. package/dist/builtin-plugin/base.js +0 -58
  121. package/dist/builtin-plugin/css-extract/hmr/hotModuleReplacement.js +0 -182
  122. package/dist/builtin-plugin/css-extract/hmr/normalizeUrl.d.ts +0 -2
  123. package/dist/builtin-plugin/css-extract/hmr/normalizeUrl.js +0 -31
  124. package/dist/builtin-plugin/css-extract/index.js +0 -105
  125. package/dist/builtin-plugin/css-extract/loader.js +0 -204
  126. package/dist/builtin-plugin/css-extract/utils.js +0 -51
  127. package/dist/builtin-plugin/index.js +0 -84
  128. package/dist/builtin-plugin/lazy-compilation/backend.js +0 -139
  129. package/dist/builtin-plugin/lazy-compilation/lazyCompilation.js +0 -6
  130. package/dist/builtin-plugin/lazy-compilation/plugin.js +0 -60
  131. package/dist/config/adapter.js +0 -691
  132. package/dist/config/adapterRuleUse.js +0 -107
  133. package/dist/config/browserslistTargetHandler.js +0 -345
  134. package/dist/config/defaults.js +0 -876
  135. package/dist/config/index.js +0 -20
  136. package/dist/config/normalization.js +0 -299
  137. package/dist/config/target.js +0 -318
  138. package/dist/config/types.js +0 -3
  139. package/dist/config/zod.js +0 -1030
  140. package/dist/container/ContainerPlugin.js +0 -50
  141. package/dist/container/ContainerReferencePlugin.js +0 -49
  142. package/dist/container/ModuleFederationPlugin.js +0 -137
  143. package/dist/container/ModuleFederationPluginV1.js +0 -63
  144. package/dist/container/ModuleFederationRuntimePlugin.js +0 -6
  145. package/dist/container/options.js +0 -48
  146. package/dist/error/ConcurrentCompilationError.js +0 -20
  147. package/dist/exports.js +0 -183
  148. package/dist/lib/AbstractMethodError.js +0 -51
  149. package/dist/lib/Cache.js +0 -111
  150. package/dist/lib/CacheFacade.js +0 -321
  151. package/dist/lib/Dependency.js +0 -11
  152. package/dist/lib/EntryOptionPlugin.js +0 -89
  153. package/dist/lib/EnvironmentPlugin.js +0 -57
  154. package/dist/lib/HookWebpackError.js +0 -83
  155. package/dist/lib/IgnoreWarningsPlugin.js +0 -35
  156. package/dist/lib/LoaderOptionsPlugin.js +0 -74
  157. package/dist/lib/LoaderTargetPlugin.js +0 -37
  158. package/dist/lib/ModuleFilenameHelpers.js +0 -83
  159. package/dist/lib/NormalModuleReplacementPlugin.js +0 -85
  160. package/dist/lib/WebpackError.js +0 -20
  161. package/dist/lib/cache/MemoryCachePlugin.js +0 -40
  162. package/dist/lib/cache/getLazyHashedEtag.js +0 -73
  163. package/dist/lib/cache/mergeEtags.js +0 -74
  164. package/dist/lib/formatLocation.js +0 -64
  165. package/dist/loader-runner/LoaderLoadingError.js +0 -19
  166. package/dist/loader-runner/index.js +0 -735
  167. package/dist/loader-runner/loadLoader.js +0 -64
  168. package/dist/logging/Logger.js +0 -143
  169. package/dist/logging/createConsoleLogger.js +0 -176
  170. package/dist/logging/runtime.js +0 -37
  171. package/dist/logging/truncateArgs.js +0 -81
  172. package/dist/node/NodeEnvironmentPlugin.js +0 -50
  173. package/dist/node/NodeTemplatePlugin.js +0 -26
  174. package/dist/node/NodeWatchFileSystem.js +0 -144
  175. package/dist/node/nodeConsole.js +0 -146
  176. package/dist/rspack.js +0 -123
  177. package/dist/rspackOptionsApply.js +0 -274
  178. package/dist/sharing/ConsumeSharedPlugin.js +0 -69
  179. package/dist/sharing/ProvideSharedPlugin.js +0 -50
  180. package/dist/sharing/SharePlugin.js +0 -66
  181. package/dist/sharing/ShareRuntimePlugin.js +0 -26
  182. package/dist/sharing/utils.js +0 -8
  183. package/dist/stats/DefaultStatsFactoryPlugin.js +0 -1173
  184. package/dist/stats/DefaultStatsPresetPlugin.js +0 -305
  185. package/dist/stats/DefaultStatsPrinterPlugin.js +0 -1069
  186. package/dist/stats/StatsFactory.js +0 -167
  187. package/dist/stats/StatsPrinter.js +0 -142
  188. package/dist/stats/statsFactoryUtils.js +0 -341
  189. package/dist/util/ArrayQueue.js +0 -108
  190. package/dist/util/AssetInfo.js +0 -39
  191. package/dist/util/IterableHelpers.js +0 -35
  192. package/dist/util/MergeCaller.js +0 -24
  193. package/dist/util/SizeFormatHelpers.js +0 -24
  194. package/dist/util/SplitChunkSize.js +0 -18
  195. package/dist/util/assertNotNil.js +0 -9
  196. package/dist/util/assetCondition.js +0 -2
  197. package/dist/util/bindingVersionCheck.js +0 -124
  198. package/dist/util/cleverMerge.js +0 -504
  199. package/dist/util/comparators.js +0 -108
  200. package/dist/util/createHash.js +0 -161
  201. package/dist/util/createReadonlyMap.js +0 -29
  202. package/dist/util/fake.js +0 -28
  203. package/dist/util/fs.js +0 -120
  204. package/dist/util/hash/BatchedHash.js +0 -69
  205. package/dist/util/hash/index.js +0 -39
  206. package/dist/util/hash/md4.js +0 -27
  207. package/dist/util/hash/wasm-hash.js +0 -167
  208. package/dist/util/hash/xxhash64.js +0 -27
  209. package/dist/util/identifier.js +0 -330
  210. package/dist/util/index.js +0 -123
  211. package/dist/util/memoize.js +0 -61
  212. package/dist/util/scheme.js +0 -57
  213. package/dist/util/smartGrouping.js +0 -148
  214. package/dist/util/source.js +0 -42
  215. package/dist/util/validate.js +0 -77
  216. package/dist/util/webpack.js +0 -27
  217. /package/dist/{container/default.runtime.js → moduleFederationDefaultRuntime.js} +0 -0
package/dist/lib/Cache.js DELETED
@@ -1,111 +0,0 @@
1
- "use strict";
2
- /**
3
- * The following code is modified based on
4
- * https://github.com/webpack/webpack/blob/4b4ca3b/lib/Cache.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
- Object.defineProperty(exports, "__esModule", { value: true });
12
- exports.Cache = void 0;
13
- const lite_tapable_1 = require("@rspack/lite-tapable");
14
- const HookWebpackError_1 = require("./HookWebpackError");
15
- const needCalls = (times, callback) => {
16
- let leftTimes = times;
17
- return err => {
18
- if (--leftTimes === 0) {
19
- return callback();
20
- }
21
- if (err && leftTimes > 0) {
22
- leftTimes = 0;
23
- return callback();
24
- }
25
- };
26
- };
27
- class Cache {
28
- constructor() {
29
- this.hooks = {
30
- get: new lite_tapable_1.AsyncSeriesBailHook(["identifier", "etag", "gotHandlers"]),
31
- store: new lite_tapable_1.AsyncParallelHook(["identifier", "etag", "data"]),
32
- storeBuildDependencies: new lite_tapable_1.AsyncParallelHook(["dependencies"]),
33
- beginIdle: new lite_tapable_1.SyncHook([]),
34
- endIdle: new lite_tapable_1.AsyncParallelHook([]),
35
- shutdown: new lite_tapable_1.AsyncParallelHook([])
36
- };
37
- }
38
- /**
39
- * @param identifier the cache identifier
40
- * @param etag the etag
41
- * @param callback signals when the value is retrieved
42
- * @returns
43
- */
44
- get(identifier, etag, callback) {
45
- const gotHandlers = [];
46
- this.hooks.get.callAsync(identifier, etag, gotHandlers, (err, res) => {
47
- if (err) {
48
- callback((0, HookWebpackError_1.makeWebpackError)(err, "Cache.hooks.get"));
49
- return;
50
- }
51
- let result = res;
52
- if (result === null) {
53
- result = undefined;
54
- }
55
- if (gotHandlers.length > 1) {
56
- const innerCallback = needCalls(gotHandlers.length, () => callback(null, result));
57
- for (const gotHandler of gotHandlers) {
58
- gotHandler(result, innerCallback);
59
- }
60
- }
61
- else if (gotHandlers.length === 1) {
62
- gotHandlers[0](result, () => callback(null, result));
63
- }
64
- else {
65
- callback(null, result);
66
- }
67
- });
68
- }
69
- /**
70
- * @param identifier the cache identifier
71
- * @param etag the etag
72
- * @param data the value to store
73
- * @param callback signals when the value is stored
74
- * @returns
75
- */
76
- store(identifier, etag, data, callback) {
77
- this.hooks.store.callAsync(identifier, etag, data, (0, HookWebpackError_1.makeWebpackErrorCallback)(callback, "Cache.hooks.store"));
78
- }
79
- /**
80
- * After this method has succeeded the cache can only be restored when build dependencies are
81
- * @param dependencies list of all build dependencies
82
- * @param callback signals when the dependencies are stored
83
- * @returns
84
- */
85
- storeBuildDependencies(dependencies, callback) {
86
- this.hooks.storeBuildDependencies.callAsync(dependencies, (0, HookWebpackError_1.makeWebpackErrorCallback)(callback, "Cache.hooks.storeBuildDependencies"));
87
- }
88
- beginIdle() {
89
- this.hooks.beginIdle.call();
90
- }
91
- /**
92
- * @param callback signals when the call finishes
93
- * @returns
94
- */
95
- endIdle(callback) {
96
- this.hooks.endIdle.callAsync((0, HookWebpackError_1.makeWebpackErrorCallback)(callback, "Cache.hooks.endIdle"));
97
- }
98
- /**
99
- * @param callback signals when the call finishes
100
- * @returns
101
- */
102
- shutdown(callback) {
103
- this.hooks.shutdown.callAsync((0, HookWebpackError_1.makeWebpackErrorCallback)(callback, "Cache.hooks.shutdown"));
104
- }
105
- }
106
- Cache.STAGE_DISK = 10;
107
- Cache.STAGE_MEMORY = -10;
108
- Cache.STAGE_DEFAULT = 0;
109
- Cache.STAGE_NETWORK = 20;
110
- exports.Cache = Cache;
111
- exports.default = Cache;
@@ -1,321 +0,0 @@
1
- "use strict";
2
- /**
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
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
- }
46
- class MultiItemCache {
47
- /**
48
- * @param items item caches
49
- * @returns
50
- */
51
- constructor(items) {
52
- this._items = items;
53
- if (items.length === 1)
54
- return items[0];
55
- }
56
- /**
57
- * @param callback signals when the value is retrieved
58
- * @returns
59
- */
60
- get(callback) {
61
- forEachBail(this._items, (item, callback) => item.get(callback), callback);
62
- }
63
- /**
64
- * @returns promise with the data
65
- */
66
- async getPromise() {
67
- for (let i = 0; i < this._items.length; i++) {
68
- const result = await this._items[i].getPromise();
69
- if (result !== undefined) {
70
- return result;
71
- }
72
- }
73
- return undefined;
74
- }
75
- /**
76
- * @param data the value to store
77
- * @param callback signals when the value is stored
78
- * @returns
79
- */
80
- store(data, callback) {
81
- neo_async_1.default.each(this._items, (item, callback) => item.store(data, callback), callback);
82
- }
83
- /**
84
- * @param data the value to store
85
- * @returns promise signals when the value is stored
86
- */
87
- async storePromise(data) {
88
- await Promise.all(this._items.map(item => item.storePromise(data)));
89
- }
90
- }
91
- exports.MultiItemCache = MultiItemCache;
92
- class ItemCacheFacade {
93
- /**
94
- * @param cache the root cache
95
- * @param name the child cache item name
96
- * @param etag the etag
97
- * @returns
98
- */
99
- constructor(cache, name, etag) {
100
- this._cache = cache;
101
- this._name = name;
102
- this._etag = etag;
103
- }
104
- /**
105
- * @param callback signals when the value is retrieved
106
- * @returns
107
- */
108
- get(callback) {
109
- this._cache.get(this._name, this._etag, callback);
110
- }
111
- /**
112
- * @returns promise with the data
113
- */
114
- getPromise() {
115
- return new Promise((resolve, reject) => {
116
- this._cache.get(this._name, this._etag, (err, data) => {
117
- if (err) {
118
- reject(err);
119
- }
120
- else {
121
- resolve(data);
122
- }
123
- });
124
- });
125
- }
126
- /**
127
- * @param data the value to store
128
- * @param callback signals when the value is stored
129
- * @returns
130
- */
131
- store(data, callback) {
132
- this._cache.store(this._name, this._etag, data, callback);
133
- }
134
- /**
135
- * @param data the value to store
136
- * @returns promise signals when the value is stored
137
- */
138
- storePromise(data) {
139
- return new Promise((resolve, reject) => {
140
- this._cache.store(this._name, this._etag, data, err => {
141
- if (err) {
142
- reject(err);
143
- }
144
- else {
145
- resolve();
146
- }
147
- });
148
- });
149
- }
150
- /**
151
- * @param computer function to compute the value if not cached
152
- * @param callback signals when the value is retrieved
153
- * @returns
154
- */
155
- provide(computer, callback) {
156
- this.get((err, cacheEntry) => {
157
- if (err)
158
- return callback(err);
159
- if (cacheEntry !== undefined)
160
- return cacheEntry;
161
- computer((err, result) => {
162
- if (err)
163
- return callback(err);
164
- this.store(result, err => {
165
- if (err)
166
- return callback(err);
167
- callback(null, result);
168
- });
169
- });
170
- });
171
- }
172
- /**
173
- * @param computer function to compute the value if not cached
174
- * @returns promise with the data
175
- */
176
- async providePromise(computer) {
177
- const cacheEntry = await this.getPromise();
178
- if (cacheEntry !== undefined)
179
- return cacheEntry;
180
- const result = await computer();
181
- await this.storePromise(result);
182
- return result;
183
- }
184
- }
185
- exports.ItemCacheFacade = ItemCacheFacade;
186
- class CacheFacade {
187
- /**
188
- * @param cache the root cache
189
- * @param name the child cache name
190
- * @param hashFunction the hash function to use
191
- */
192
- constructor(cache, name, hashFunction) {
193
- this._cache = cache;
194
- this._name = name;
195
- this._hashFunction = hashFunction;
196
- }
197
- /**
198
- * @param name the child cache name#
199
- * @returns child cache
200
- */
201
- getChildCache(name) {
202
- return new CacheFacade(this._cache, `${this._name}|${name}`, this._hashFunction);
203
- }
204
- /**
205
- * @param identifier the cache identifier
206
- * @param etag the etag
207
- * @returns item cache
208
- */
209
- getItemCache(identifier, etag) {
210
- return new ItemCacheFacade(this._cache, `${this._name}|${identifier}`, etag);
211
- }
212
- /**
213
- * @param obj an hashable object
214
- * @returns an etag that is lazy hashed
215
- */
216
- getLazyHashedEtag(obj) {
217
- return (0, getLazyHashedEtag_js_1.getter)(obj, this._hashFunction);
218
- }
219
- /**
220
- * @param a an etag
221
- * @param b another etag
222
- * @returns an etag that represents both
223
- */
224
- mergeEtags(a, b) {
225
- return (0, mergeEtags_js_1.mergeEtags)(a, b);
226
- }
227
- /**
228
- * @param identifier the cache identifier
229
- * @param etag the etag
230
- * @param callback signals when the value is retrieved
231
- * @returns
232
- */
233
- get(identifier, etag, callback) {
234
- this._cache.get(`${this._name}|${identifier}`, etag, callback);
235
- }
236
- /**
237
- * @param identifier the cache identifier
238
- * @param etag the etag
239
- * @returns promise with the data
240
- */
241
- getPromise(identifier, etag) {
242
- return new Promise((resolve, reject) => {
243
- this._cache.get(`${this._name}|${identifier}`, etag, (err, data) => {
244
- if (err) {
245
- reject(err);
246
- }
247
- else {
248
- resolve(data);
249
- }
250
- });
251
- });
252
- }
253
- /**
254
- * @param identifier the cache identifier
255
- * @param etag the etag
256
- * @param data the value to store
257
- * @param callback signals when the value is stored
258
- * @returns
259
- */
260
- store(identifier, etag, data, callback) {
261
- this._cache.store(`${this._name}|${identifier}`, etag, data, callback);
262
- }
263
- /**
264
- * @param identifier the cache identifier
265
- * @param etag the etag
266
- * @param data the value to store
267
- * @returns promise signals when the value is stored
268
- */
269
- storePromise(identifier, etag, data) {
270
- return new Promise((resolve, reject) => {
271
- this._cache.store(`${this._name}|${identifier}`, etag, data, err => {
272
- if (err) {
273
- reject(err);
274
- }
275
- else {
276
- resolve();
277
- }
278
- });
279
- });
280
- }
281
- /**
282
- * @param identifier the cache identifier
283
- * @param etag the etag
284
- * @param computer function to compute the value if not cached
285
- * @param callback signals when the value is retrieved
286
- * @returns
287
- */
288
- provide(identifier, etag, computer, callback) {
289
- this.get(identifier, etag, (err, cacheEntry) => {
290
- if (err)
291
- return callback(err);
292
- if (cacheEntry !== undefined)
293
- return cacheEntry;
294
- computer((err, result) => {
295
- if (err)
296
- return callback(err);
297
- this.store(identifier, etag, result, err => {
298
- if (err)
299
- return callback(err);
300
- callback(null, result);
301
- });
302
- });
303
- });
304
- }
305
- /**
306
- * @param identifier the cache identifier
307
- * @param etag the etag
308
- * @param computer function to compute the value if not cached
309
- * @returns promise with the data
310
- */
311
- async providePromise(identifier, etag, computer) {
312
- const cacheEntry = await this.getPromise(identifier, etag);
313
- if (cacheEntry !== undefined)
314
- return cacheEntry;
315
- const result = await computer();
316
- await this.storePromise(identifier, etag, result);
317
- return result;
318
- }
319
- }
320
- exports.CacheFacade = CacheFacade;
321
- exports.default = CacheFacade;
@@ -1,11 +0,0 @@
1
- "use strict";
2
- /**
3
- * The following code is modified based on
4
- * https://github.com/webpack/webpack/blob/4b4ca3b/lib/Dependency.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
- Object.defineProperty(exports, "__esModule", { value: true });
@@ -1,89 +0,0 @@
1
- "use strict";
2
- /**
3
- * The following code is modified based on
4
- * https://github.com/webpack/webpack/blob/4b4ca3b/lib/EntryOptionPlugin.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
- };
14
- Object.defineProperty(exports, "__esModule", { value: true });
15
- exports.EntryOptionPlugin = void 0;
16
- const node_assert_1 = __importDefault(require("node:assert"));
17
- const builtin_plugin_1 = require("../builtin-plugin");
18
- class EntryOptionPlugin {
19
- /**
20
- * @param compiler the compiler instance one is tapping into
21
- * @returns
22
- */
23
- apply(compiler) {
24
- compiler.hooks.entryOption.tap("EntryOptionPlugin", (context, entry) => {
25
- EntryOptionPlugin.applyEntryOption(compiler, context, entry);
26
- return true;
27
- });
28
- }
29
- /**
30
- * @param compiler the compiler
31
- * @param context context directory
32
- * @param entry request
33
- * @returns
34
- */
35
- static applyEntryOption(compiler, context, entry) {
36
- if (typeof entry === "function") {
37
- new builtin_plugin_1.DynamicEntryPlugin(context, entry).apply(compiler);
38
- }
39
- else {
40
- for (const name of Object.keys(entry)) {
41
- const desc = entry[name];
42
- const options = EntryOptionPlugin.entryDescriptionToOptions(compiler, name, desc);
43
- (0, node_assert_1.default)(desc.import !== undefined, "desc.import should not be `undefined` once `EntryOptionPlugin.applyEntryOption` is called");
44
- for (const entry of desc.import) {
45
- new builtin_plugin_1.EntryPlugin(context, entry, options).apply(compiler);
46
- }
47
- }
48
- }
49
- }
50
- /**
51
- * @param compiler the compiler
52
- * @param name entry name
53
- * @param desc entry description
54
- * @returns options for the entry
55
- */
56
- static entryDescriptionToOptions(compiler, name, desc) {
57
- const options = {
58
- name,
59
- filename: desc.filename,
60
- runtime: desc.runtime,
61
- layer: desc.layer,
62
- dependOn: desc.dependOn,
63
- baseUri: desc.baseUri,
64
- publicPath: desc.publicPath,
65
- chunkLoading: desc.chunkLoading,
66
- asyncChunks: desc.asyncChunks,
67
- // wasmLoading: desc.wasmLoading,
68
- library: desc.library
69
- };
70
- if (desc.layer !== undefined && !compiler.options.experiments.layers) {
71
- throw new Error("'entryOptions.layer' is only allowed when 'experiments.layers' is enabled");
72
- }
73
- // if (desc.chunkLoading) {
74
- // const EnableChunkLoadingPlugin = require("./javascript/EnableChunkLoadingPlugin");
75
- // EnableChunkLoadingPlugin.checkEnabled(compiler, desc.chunkLoading);
76
- // }
77
- // if (desc.wasmLoading) {
78
- // const EnableWasmLoadingPlugin = require("./wasm/EnableWasmLoadingPlugin");
79
- // EnableWasmLoadingPlugin.checkEnabled(compiler, desc.wasmLoading);
80
- // }
81
- // if (desc.library) {
82
- // const EnableLibraryPlugin = require("./library/EnableLibraryPlugin");
83
- // EnableLibraryPlugin.checkEnabled(compiler, desc.library.type);
84
- // }
85
- return options;
86
- }
87
- }
88
- exports.EntryOptionPlugin = EntryOptionPlugin;
89
- exports.default = EntryOptionPlugin;
@@ -1,57 +0,0 @@
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
- };
14
- Object.defineProperty(exports, "__esModule", { value: true });
15
- exports.EnvironmentPlugin = void 0;
16
- const builtin_plugin_1 = require("../builtin-plugin");
17
- const WebpackError_1 = __importDefault(require("./WebpackError"));
18
- class EnvironmentPlugin {
19
- constructor(...keys) {
20
- if (keys.length === 1 && Array.isArray(keys[0])) {
21
- this.keys = keys[0];
22
- this.defaultValues = {};
23
- }
24
- else if (keys.length === 1 && keys[0] && typeof keys[0] === "object") {
25
- this.keys = Object.keys(keys[0]);
26
- this.defaultValues = keys[0];
27
- }
28
- else {
29
- this.keys = keys;
30
- this.defaultValues = {};
31
- }
32
- }
33
- /**
34
- * Apply the plugin
35
- * @param compiler the compiler instance
36
- * @returns
37
- */
38
- apply(compiler) {
39
- const definitions = {};
40
- for (const key of this.keys) {
41
- const value = process.env[key] !== undefined
42
- ? process.env[key]
43
- : this.defaultValues[key];
44
- if (value === undefined) {
45
- compiler.hooks.thisCompilation.tap("EnvironmentPlugin", compilation => {
46
- const error = new WebpackError_1.default(`EnvironmentPlugin - ${key} environment variable is undefined.\n\nYou can pass an object with default values to suppress this warning.\nSee https://rspack.dev/plugins/webpack/environment-plugin for example.`);
47
- error.name = "EnvVariableNotDefinedError";
48
- compilation.errors.push(error);
49
- });
50
- }
51
- definitions[`process.env.${key}`] =
52
- value === undefined ? "undefined" : JSON.stringify(value);
53
- }
54
- new builtin_plugin_1.DefinePlugin(definitions).apply(compiler);
55
- }
56
- }
57
- exports.EnvironmentPlugin = EnvironmentPlugin;
@@ -1,83 +0,0 @@
1
- "use strict";
2
- /**
3
- * The following code is modified based on
4
- * https://github.com/webpack/webpack/blob/4b4ca3b/lib/HookWebpackError.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
- };
14
- Object.defineProperty(exports, "__esModule", { value: true });
15
- exports.tryRunOrWebpackError = exports.makeWebpackErrorCallback = exports.makeWebpackError = exports.HookWebpackError = void 0;
16
- const WebpackError_1 = __importDefault(require("./WebpackError"));
17
- class HookWebpackError extends WebpackError_1.default {
18
- /**
19
- * Creates an instance of HookWebpackError.
20
- * @param error inner error
21
- * @param hook name of hook
22
- */
23
- constructor(error, hook) {
24
- super(error.message);
25
- this.name = "HookWebpackError";
26
- this.hook = hook;
27
- this.error = error;
28
- this.hideStack = true;
29
- this.details = `caused by plugins in ${hook}\n${error.stack}`;
30
- this.stack += `\n-- inner error --\n${error.stack}`;
31
- }
32
- }
33
- exports.HookWebpackError = HookWebpackError;
34
- exports.default = HookWebpackError;
35
- /**
36
- * @param error an error
37
- * @param hook name of the hook
38
- * @returns a webpack error
39
- */
40
- const makeWebpackError = (error, hook) => {
41
- if (error instanceof WebpackError_1.default)
42
- return error;
43
- return new HookWebpackError(error, hook);
44
- };
45
- exports.makeWebpackError = makeWebpackError;
46
- /**
47
- * @param callback webpack error callback
48
- * @param hook name of hook
49
- * @returns generic callback
50
- */
51
- const makeWebpackErrorCallback = (callback, hook) => {
52
- return (err, result) => {
53
- if (err) {
54
- if (err instanceof WebpackError_1.default) {
55
- callback(err);
56
- return;
57
- }
58
- callback(new HookWebpackError(err, hook));
59
- return;
60
- }
61
- callback(null, result);
62
- };
63
- };
64
- exports.makeWebpackErrorCallback = makeWebpackErrorCallback;
65
- /**
66
- * @param fn function which will be wrapping in try catch
67
- * @param hook name of hook
68
- * @returns the result
69
- */
70
- const tryRunOrWebpackError = (fn, hook) => {
71
- let r;
72
- try {
73
- r = fn();
74
- }
75
- catch (err) {
76
- if (err instanceof WebpackError_1.default) {
77
- throw err;
78
- }
79
- throw new HookWebpackError(err, hook);
80
- }
81
- return r;
82
- };
83
- exports.tryRunOrWebpackError = tryRunOrWebpackError;