@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
@@ -1,504 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.resolveByProperty = exports.removeOperations = exports.cleverMerge = exports.cachedSetProperty = exports.cachedCleverMerge = exports.DELETE = void 0;
4
- const DYNAMIC_INFO = Symbol("cleverMerge dynamic info");
5
- const mergeCache = new WeakMap();
6
- const setPropertyCache = new WeakMap();
7
- exports.DELETE = Symbol("DELETE");
8
- /**
9
- * Merges two given objects and caches the result to avoid computation if same objects passed as arguments again.
10
- * @example
11
- * // performs cleverMerge(first, second), stores the result in WeakMap and returns result
12
- * cachedCleverMerge({a: 1}, {a: 2})
13
- * {a: 2}
14
- * // when same arguments passed, gets the result from WeakMap and returns it.
15
- * cachedCleverMerge({a: 1}, {a: 2})
16
- * {a: 2}
17
- * @param first first object
18
- * @param second second object
19
- * @returns merged object of first and second object
20
- */
21
- const cachedCleverMerge = (first, second) => {
22
- if (second === undefined)
23
- return first;
24
- if (first === undefined)
25
- return second;
26
- if (typeof second !== "object" || second === null)
27
- return second;
28
- if (typeof first !== "object" || first === null)
29
- return first;
30
- let innerCache = mergeCache.get(first);
31
- if (innerCache === undefined) {
32
- innerCache = new WeakMap();
33
- mergeCache.set(first, innerCache);
34
- }
35
- const prevMerge = innerCache.get(second);
36
- if (prevMerge !== undefined)
37
- return prevMerge;
38
- const newMerge = _cleverMerge(first, second, true);
39
- innerCache.set(second, newMerge);
40
- return newMerge;
41
- };
42
- exports.cachedCleverMerge = cachedCleverMerge;
43
- /**
44
- * @param obj object
45
- * @param property property
46
- * @param value assignment value
47
- * @returns new object
48
- */
49
- const cachedSetProperty = (obj, property, value) => {
50
- let mapByProperty = setPropertyCache.get(obj);
51
- if (mapByProperty === undefined) {
52
- mapByProperty = new Map();
53
- setPropertyCache.set(obj, mapByProperty);
54
- }
55
- let mapByValue = mapByProperty.get(property);
56
- if (mapByValue === undefined) {
57
- mapByValue = new Map();
58
- mapByProperty.set(property, mapByValue);
59
- }
60
- let result = mapByValue.get(value);
61
- if (result)
62
- return result;
63
- result = {
64
- ...obj,
65
- [property]: value
66
- };
67
- mapByValue.set(value, result);
68
- return result;
69
- };
70
- exports.cachedSetProperty = cachedSetProperty;
71
- const parseCache = new WeakMap();
72
- /**
73
- * @param obj the object
74
- * @returns parsed object
75
- */
76
- const cachedParseObject = (obj) => {
77
- const entry = parseCache.get(obj);
78
- if (entry !== undefined)
79
- return entry;
80
- const result = parseObject(obj);
81
- parseCache.set(obj, result);
82
- return result;
83
- };
84
- /**
85
- * @param {object} obj the object
86
- * @returns {ParsedObject} parsed object
87
- */
88
- const parseObject = (obj) => {
89
- const info = new Map();
90
- let dynamicInfo;
91
- const getInfo = (p) => {
92
- const entry = info.get(p);
93
- if (entry !== undefined)
94
- return entry;
95
- const newEntry = {
96
- base: undefined,
97
- byProperty: undefined,
98
- byValues: new Map()
99
- };
100
- info.set(p, newEntry);
101
- return newEntry;
102
- };
103
- for (const key of Object.keys(obj)) {
104
- if (key.startsWith("by")) {
105
- const byProperty = key;
106
- const byObj = obj[byProperty];
107
- if (typeof byObj === "object") {
108
- for (const byValue of Object.keys(byObj)) {
109
- const obj = byObj[byValue];
110
- for (const key of Object.keys(obj)) {
111
- const entry = getInfo(key);
112
- if (entry.byProperty === undefined) {
113
- entry.byProperty = byProperty;
114
- }
115
- else if (entry.byProperty !== byProperty) {
116
- throw new Error(`${byProperty} and ${entry.byProperty} for a single property is not supported`);
117
- }
118
- entry.byValues.set(byValue, obj[key]);
119
- if (byValue === "default") {
120
- for (const otherByValue of Object.keys(byObj)) {
121
- if (!entry.byValues.has(otherByValue))
122
- entry.byValues.set(otherByValue, undefined);
123
- }
124
- }
125
- }
126
- }
127
- }
128
- else if (typeof byObj === "function") {
129
- if (dynamicInfo === undefined) {
130
- dynamicInfo = {
131
- byProperty: key,
132
- fn: byObj
133
- };
134
- }
135
- else {
136
- throw new Error(`${key} and ${dynamicInfo.byProperty} when both are functions is not supported`);
137
- }
138
- }
139
- else {
140
- const entry = getInfo(key);
141
- entry.base = obj[key];
142
- }
143
- }
144
- else {
145
- const entry = getInfo(key);
146
- entry.base = obj[key];
147
- }
148
- }
149
- return {
150
- static: info,
151
- dynamic: dynamicInfo
152
- };
153
- };
154
- /**
155
- * @param info static properties (key is property name)
156
- * @param dynamicInfo dynamic part
157
- * @returns the object
158
- */
159
- const serializeObject = (info, dynamicInfo) => {
160
- const obj = {};
161
- // Setup byProperty structure
162
- for (const entry of info.values()) {
163
- if (entry.byProperty !== undefined) {
164
- const byObj = (obj[entry.byProperty] = obj[entry.byProperty] || {});
165
- for (const byValue of entry.byValues.keys()) {
166
- byObj[byValue] = byObj[byValue] || {};
167
- }
168
- }
169
- }
170
- for (const [key, entry] of info) {
171
- if (entry.base !== undefined) {
172
- obj[key] = entry.base;
173
- }
174
- // Fill byProperty structure
175
- if (entry.byProperty !== undefined) {
176
- const byObj = (obj[entry.byProperty] = obj[entry.byProperty] || {});
177
- for (const byValue of Object.keys(byObj)) {
178
- const value = getFromByValues(entry.byValues, byValue);
179
- if (value !== undefined)
180
- byObj[byValue][key] = value;
181
- }
182
- }
183
- }
184
- if (dynamicInfo !== undefined) {
185
- obj[dynamicInfo.byProperty] = dynamicInfo.fn;
186
- }
187
- return obj;
188
- };
189
- const VALUE_TYPE_UNDEFINED = 0;
190
- const VALUE_TYPE_ATOM = 1;
191
- const VALUE_TYPE_ARRAY_EXTEND = 2;
192
- const VALUE_TYPE_OBJECT = 3;
193
- const VALUE_TYPE_DELETE = 4;
194
- /**
195
- * @param value a single value
196
- * @returns {VALUE_TYPE_UNDEFINED | VALUE_TYPE_ATOM | VALUE_TYPE_ARRAY_EXTEND | VALUE_TYPE_OBJECT | VALUE_TYPE_DELETE} value type
197
- */
198
- const getValueType = (value) => {
199
- if (value === undefined) {
200
- return VALUE_TYPE_UNDEFINED;
201
- }
202
- if (value === exports.DELETE) {
203
- return VALUE_TYPE_DELETE;
204
- }
205
- if (Array.isArray(value)) {
206
- if (value.lastIndexOf("...") !== -1)
207
- return VALUE_TYPE_ARRAY_EXTEND;
208
- return VALUE_TYPE_ATOM;
209
- }
210
- if (typeof value === "object" &&
211
- value !== null &&
212
- (!value.constructor || value.constructor === Object)) {
213
- return VALUE_TYPE_OBJECT;
214
- }
215
- return VALUE_TYPE_ATOM;
216
- };
217
- /**
218
- * Merges two objects. Objects are deeply clever merged.
219
- * Arrays might reference the old value with "...".
220
- * Non-object values take preference over object values.
221
- * @param first first object
222
- * @param second second object
223
- * @returns merged object of first and second object
224
- */
225
- const cleverMerge = (first, second) => {
226
- if (second === undefined)
227
- return first;
228
- if (first === undefined)
229
- return second;
230
- if (typeof second !== "object" || second === null)
231
- return second;
232
- if (typeof first !== "object" || first === null)
233
- return first;
234
- return _cleverMerge(first, second, false);
235
- };
236
- exports.cleverMerge = cleverMerge;
237
- /**
238
- * Merges two objects. Objects are deeply clever merged.
239
- * @param first first object
240
- * @param second second object
241
- * @param internalCaching should parsing of objects and nested merges be cached
242
- * @returns merged object of first and second object
243
- */
244
- const _cleverMerge = (first, second, internalCaching = false) => {
245
- const firstObject = internalCaching
246
- ? cachedParseObject(first)
247
- : parseObject(first);
248
- const { static: firstInfo, dynamic: firstDynamicInfo } = firstObject;
249
- // If the first argument has a dynamic part we modify the dynamic part to merge the second argument
250
- let secondObj = second;
251
- if (firstDynamicInfo !== undefined) {
252
- let { byProperty, fn } = firstDynamicInfo;
253
- const fnInfo = fn[DYNAMIC_INFO];
254
- if (fnInfo) {
255
- secondObj = internalCaching
256
- ? (0, exports.cachedCleverMerge)(fnInfo[1], second)
257
- : (0, exports.cleverMerge)(fnInfo[1], second);
258
- fn = fnInfo[0];
259
- }
260
- const newFn = (...args) => {
261
- const fnResult = fn(...args);
262
- return internalCaching
263
- ? (0, exports.cachedCleverMerge)(fnResult, secondObj)
264
- : (0, exports.cleverMerge)(fnResult, secondObj);
265
- };
266
- newFn[DYNAMIC_INFO] = [fn, secondObj];
267
- return serializeObject(firstObject.static, { byProperty, fn: newFn });
268
- }
269
- // If the first part is static only, we merge the static parts and keep the dynamic part of the second argument
270
- const secondObject = internalCaching
271
- ? cachedParseObject(second)
272
- : parseObject(second);
273
- const { static: secondInfo, dynamic: secondDynamicInfo } = secondObject;
274
- const resultInfo = new Map();
275
- for (const [key, firstEntry] of firstInfo) {
276
- const secondEntry = secondInfo.get(key);
277
- const entry = secondEntry !== undefined
278
- ? mergeEntries(firstEntry, secondEntry, internalCaching)
279
- : firstEntry;
280
- resultInfo.set(key, entry);
281
- }
282
- for (const [key, secondEntry] of secondInfo) {
283
- if (!firstInfo.has(key)) {
284
- resultInfo.set(key, secondEntry);
285
- }
286
- }
287
- return serializeObject(resultInfo, secondDynamicInfo);
288
- };
289
- /**
290
- * @param firstEntry a
291
- * @param secondEntry b
292
- * @param internalCaching should parsing of objects and nested merges be cached
293
- * @returns new entry
294
- */
295
- const mergeEntries = (firstEntry, secondEntry, internalCaching) => {
296
- switch (getValueType(secondEntry.base)) {
297
- case VALUE_TYPE_ATOM:
298
- case VALUE_TYPE_DELETE:
299
- // No need to consider firstEntry at all
300
- // second value override everything
301
- // = second.base + second.byProperty
302
- return secondEntry;
303
- case VALUE_TYPE_UNDEFINED: {
304
- if (!firstEntry.byProperty) {
305
- // = first.base + second.byProperty
306
- return {
307
- base: firstEntry.base,
308
- byProperty: secondEntry.byProperty,
309
- byValues: secondEntry.byValues
310
- };
311
- }
312
- if (firstEntry.byProperty !== secondEntry.byProperty) {
313
- throw new Error(`${firstEntry.byProperty} and ${secondEntry.byProperty} for a single property is not supported`);
314
- }
315
- // = first.base + (first.byProperty + second.byProperty)
316
- // need to merge first and second byValues
317
- const newByValues = new Map(firstEntry.byValues);
318
- for (const [key, value] of secondEntry.byValues) {
319
- const firstValue = getFromByValues(firstEntry.byValues, key);
320
- newByValues.set(key, mergeSingleValue(firstValue, value, internalCaching));
321
- }
322
- return {
323
- base: firstEntry.base,
324
- byProperty: firstEntry.byProperty,
325
- byValues: newByValues
326
- };
327
- }
328
- default: {
329
- if (!firstEntry.byProperty) {
330
- // The simple case
331
- // = (first.base + second.base) + second.byProperty
332
- return {
333
- base: mergeSingleValue(firstEntry.base, secondEntry.base, internalCaching),
334
- byProperty: secondEntry.byProperty,
335
- byValues: secondEntry.byValues
336
- };
337
- }
338
- let newBase;
339
- const intermediateByValues = new Map(firstEntry.byValues);
340
- for (const [key, value] of intermediateByValues) {
341
- intermediateByValues.set(key, mergeSingleValue(value, secondEntry.base, internalCaching));
342
- }
343
- if (Array.from(firstEntry.byValues.values()).every(value => {
344
- const type = getValueType(value);
345
- return type === VALUE_TYPE_ATOM || type === VALUE_TYPE_DELETE;
346
- })) {
347
- // = (first.base + second.base) + ((first.byProperty + second.base) + second.byProperty)
348
- newBase = mergeSingleValue(firstEntry.base, secondEntry.base, internalCaching);
349
- }
350
- else {
351
- // = first.base + ((first.byProperty (+default) + second.base) + second.byProperty)
352
- newBase = firstEntry.base;
353
- if (!intermediateByValues.has("default"))
354
- intermediateByValues.set("default", secondEntry.base);
355
- }
356
- if (!secondEntry.byProperty) {
357
- // = first.base + (first.byProperty + second.base)
358
- return {
359
- base: newBase,
360
- byProperty: firstEntry.byProperty,
361
- byValues: intermediateByValues
362
- };
363
- }
364
- if (firstEntry.byProperty !== secondEntry.byProperty) {
365
- throw new Error(`${firstEntry.byProperty} and ${secondEntry.byProperty} for a single property is not supported`);
366
- }
367
- const newByValues = new Map(intermediateByValues);
368
- for (const [key, value] of secondEntry.byValues) {
369
- const firstValue = getFromByValues(intermediateByValues, key);
370
- newByValues.set(key, mergeSingleValue(firstValue, value, internalCaching));
371
- }
372
- return {
373
- base: newBase,
374
- byProperty: firstEntry.byProperty,
375
- byValues: newByValues
376
- };
377
- }
378
- }
379
- };
380
- /**
381
- * @param byValues all values
382
- * @param key value of the selector
383
- * @returns value
384
- */
385
- const getFromByValues = (byValues, key) => {
386
- if (key !== "default" && byValues.has(key)) {
387
- return byValues.get(key);
388
- }
389
- return byValues.get("default");
390
- };
391
- /**
392
- * @param a value
393
- * @param b value
394
- * @param internalCaching should parsing of objects and nested merges be cached
395
- * @returns value
396
- */
397
- const mergeSingleValue = (a, b, internalCaching) => {
398
- const bType = getValueType(b);
399
- const aType = getValueType(a);
400
- switch (bType) {
401
- case VALUE_TYPE_DELETE:
402
- case VALUE_TYPE_ATOM:
403
- return b;
404
- case VALUE_TYPE_OBJECT: {
405
- return aType !== VALUE_TYPE_OBJECT
406
- ? b
407
- : internalCaching
408
- ? (0, exports.cachedCleverMerge)(a, b)
409
- : (0, exports.cleverMerge)(a, b);
410
- }
411
- case VALUE_TYPE_UNDEFINED:
412
- return a;
413
- case VALUE_TYPE_ARRAY_EXTEND:
414
- switch (aType !== VALUE_TYPE_ATOM
415
- ? aType
416
- : Array.isArray(a)
417
- ? VALUE_TYPE_ARRAY_EXTEND
418
- : VALUE_TYPE_OBJECT) {
419
- case VALUE_TYPE_UNDEFINED:
420
- return b;
421
- case VALUE_TYPE_DELETE:
422
- return b.filter((item) => item !== "...");
423
- case VALUE_TYPE_ARRAY_EXTEND: {
424
- const newArray = [];
425
- for (const item of b) {
426
- if (item === "...") {
427
- for (const item of a) {
428
- newArray.push(item);
429
- }
430
- }
431
- else {
432
- newArray.push(item);
433
- }
434
- }
435
- return newArray;
436
- }
437
- case VALUE_TYPE_OBJECT:
438
- return b.map((item) => (item === "..." ? a : item));
439
- default:
440
- throw new Error("Not implemented");
441
- }
442
- default:
443
- throw new Error("Not implemented");
444
- }
445
- };
446
- /**
447
- * @param obj the object
448
- * @returns the object without operations like "..." or DELETE
449
- */
450
- const removeOperations = (obj) => {
451
- const newObj = {};
452
- for (const key of Object.keys(obj)) {
453
- const value = obj[key];
454
- const type = getValueType(value);
455
- switch (type) {
456
- case VALUE_TYPE_UNDEFINED:
457
- case VALUE_TYPE_DELETE:
458
- break;
459
- case VALUE_TYPE_OBJECT:
460
- newObj[key] = (0, exports.removeOperations)(value);
461
- break;
462
- case VALUE_TYPE_ARRAY_EXTEND:
463
- newObj[key] = value.filter(i => i !== "...");
464
- break;
465
- default:
466
- newObj[key] = value;
467
- break;
468
- }
469
- }
470
- return newObj;
471
- };
472
- exports.removeOperations = removeOperations;
473
- /**
474
- * @param obj the object
475
- * @param byProperty the by description
476
- * @param values values
477
- * @returns object with merged byProperty
478
- */
479
- const resolveByProperty = (obj, byProperty, ...values) => {
480
- if (!isPropertyInObject(obj, byProperty)) {
481
- return obj;
482
- }
483
- const { [byProperty]: _byValue, ..._remaining } = obj;
484
- const remaining = _remaining;
485
- const byValue = _byValue;
486
- if (typeof byValue === "object") {
487
- const key = values[0];
488
- if (key in byValue) {
489
- return (0, exports.cachedCleverMerge)(remaining, byValue[key]);
490
- }
491
- if ("default" in byValue) {
492
- return (0, exports.cachedCleverMerge)(remaining, byValue.default);
493
- }
494
- return remaining;
495
- }
496
- if (typeof byValue === "function") {
497
- const result = byValue.apply(null, values);
498
- return (0, exports.cachedCleverMerge)(remaining, (0, exports.resolveByProperty)(result, byProperty, ...values));
499
- }
500
- };
501
- exports.resolveByProperty = resolveByProperty;
502
- function isPropertyInObject(obj, property) {
503
- return typeof obj === "object" && obj !== null && property in obj;
504
- }
@@ -1,108 +0,0 @@
1
- "use strict";
2
- /**
3
- * The following code is modified based on
4
- * https://github.com/webpack/webpack/tree/4b4ca3bb53f36a5b8fc6bc1bd976ed7af161bd80/lib/util
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.compareNumbers = exports.compareSelect = exports.compareChunkGroupsByIndex = exports.compareChunksById = exports.compareIds = exports.concatComparators = void 0;
13
- class TwoKeyWeakMap {
14
- constructor() {
15
- this._map = new WeakMap();
16
- }
17
- get(key1, key2) {
18
- const childMap = this._map.get(key1);
19
- if (childMap === undefined) {
20
- return undefined;
21
- }
22
- return childMap.get(key2);
23
- }
24
- set(key1, key2, value) {
25
- let childMap = this._map.get(key1);
26
- if (childMap === undefined) {
27
- childMap = new WeakMap();
28
- this._map.set(key1, childMap);
29
- }
30
- childMap.set(key2, value);
31
- }
32
- }
33
- const concatComparatorsCache = new TwoKeyWeakMap();
34
- const concatComparators = (...comps) => {
35
- const [c1, c2, ...cRest] = comps;
36
- if (c2 === undefined) {
37
- return c1;
38
- }
39
- if (cRest.length > 0) {
40
- const [c3, ...cRest2] = cRest;
41
- return (0, exports.concatComparators)(c1, (0, exports.concatComparators)(c2, c3, ...cRest2));
42
- }
43
- const cacheEntry = concatComparatorsCache.get(c1, c2);
44
- if (cacheEntry !== undefined)
45
- return cacheEntry;
46
- const result = (a, b) => {
47
- const res = c1(a, b);
48
- if (res !== 0)
49
- return res;
50
- return c2(a, b);
51
- };
52
- concatComparatorsCache.set(c1, c2, result);
53
- return result;
54
- };
55
- exports.concatComparators = concatComparators;
56
- const compareIds = (a, b) => {
57
- if (typeof a !== typeof b) {
58
- return typeof a < typeof b ? -1 : 1;
59
- }
60
- if (a < b)
61
- return -1;
62
- if (a > b)
63
- return 1;
64
- return 0;
65
- };
66
- exports.compareIds = compareIds;
67
- const compareChunksById = (a, b) => {
68
- return (0, exports.compareIds)(a.id || "", b.id || "");
69
- };
70
- exports.compareChunksById = compareChunksById;
71
- const compareChunkGroupsByIndex = (a, b) => {
72
- return a.index < b.index ? -1 : 1;
73
- };
74
- exports.compareChunkGroupsByIndex = compareChunkGroupsByIndex;
75
- const compareSelectCache = new TwoKeyWeakMap();
76
- const compareSelect = (getter, comparator) => {
77
- const cacheEntry = compareSelectCache.get(getter, comparator);
78
- if (cacheEntry !== undefined)
79
- return cacheEntry;
80
- const result = (a, b) => {
81
- const aValue = getter(a);
82
- const bValue = getter(b);
83
- if (aValue !== undefined && aValue !== null) {
84
- if (bValue !== undefined && bValue !== null) {
85
- return comparator(aValue, bValue);
86
- }
87
- return -1;
88
- }
89
- if (bValue !== undefined && bValue !== null) {
90
- return 1;
91
- }
92
- return 0;
93
- };
94
- compareSelectCache.set(getter, comparator, result);
95
- return result;
96
- };
97
- exports.compareSelect = compareSelect;
98
- const compareNumbers = (a, b) => {
99
- if (typeof a !== typeof b) {
100
- return typeof a < typeof b ? -1 : 1;
101
- }
102
- if (a < b)
103
- return -1;
104
- if (a > b)
105
- return 1;
106
- return 0;
107
- };
108
- exports.compareNumbers = compareNumbers;