@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,108 +0,0 @@
1
- "use strict";
2
- /**
3
- * The following code is modified based on
4
- * https://github.com/webpack/webpack/blob/4b4ca3b/lib/util/ArrayQueue.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
- /**
13
- * @template T
14
- */
15
- class ArrayQueue {
16
- constructor(items) {
17
- this._list = items ? Array.from(items) : [];
18
- this._listReversed = [];
19
- }
20
- /**
21
- * Returns the number of elements in this queue.
22
- * @returns {number} The number of elements in this queue.
23
- */
24
- get length() {
25
- return this._list.length + this._listReversed.length;
26
- }
27
- /**
28
- * Empties the queue.
29
- */
30
- clear() {
31
- this._list.length = 0;
32
- this._listReversed.length = 0;
33
- }
34
- /**
35
- * Appends the specified element to this queue.
36
- * @param {T} item The element to add.
37
- * @returns {void}
38
- */
39
- enqueue(item) {
40
- this._list.push(item);
41
- }
42
- /**
43
- * Retrieves and removes the head of this queue.
44
- * @returns {T | undefined} The head of the queue of `undefined` if this queue is empty.
45
- */
46
- dequeue() {
47
- if (this._listReversed.length === 0) {
48
- if (this._list.length === 0)
49
- return undefined;
50
- if (this._list.length === 1)
51
- return this._list.pop();
52
- if (this._list.length < 16)
53
- return this._list.shift();
54
- const temp = this._listReversed;
55
- this._listReversed = this._list;
56
- this._listReversed.reverse();
57
- this._list = temp;
58
- }
59
- return this._listReversed.pop();
60
- }
61
- /**
62
- * Finds and removes an item
63
- * @param {T} item the item
64
- * @returns {void}
65
- */
66
- delete(item) {
67
- const i = this._list.indexOf(item);
68
- if (i >= 0) {
69
- this._list.splice(i, 1);
70
- }
71
- else {
72
- const i = this._listReversed.indexOf(item);
73
- if (i >= 0)
74
- this._listReversed.splice(i, 1);
75
- }
76
- }
77
- [Symbol.iterator]() {
78
- let i = -1;
79
- let reversed = false;
80
- return {
81
- next: () => {
82
- if (!reversed) {
83
- i++;
84
- if (i < this._list.length) {
85
- return {
86
- done: false,
87
- value: this._list[i]
88
- };
89
- }
90
- reversed = true;
91
- i = this._listReversed.length;
92
- }
93
- i--;
94
- if (i < 0) {
95
- return {
96
- done: true,
97
- value: undefined
98
- };
99
- }
100
- return {
101
- done: false,
102
- value: this._listReversed[i]
103
- };
104
- }
105
- };
106
- }
107
- }
108
- exports.default = ArrayQueue;
@@ -1,39 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.JsAssetInfo = void 0;
4
- class JsAssetInfo {
5
- static __from_binding(jsAssetInfo) {
6
- const { immutable, minimized, development, hotModuleReplacement, related, chunkhash, fullhash, contenthash, javascriptModule, sourceFilename, extras } = jsAssetInfo;
7
- return {
8
- ...extras,
9
- immutable,
10
- minimized,
11
- development,
12
- hotModuleReplacement,
13
- related,
14
- fullhash,
15
- chunkhash,
16
- contenthash,
17
- javascriptModule,
18
- sourceFilename
19
- };
20
- }
21
- static __to_binding(assetInfo = {}) {
22
- let { immutable = false, minimized = false, development = false, hotModuleReplacement = false, related = {}, fullhash = [], chunkhash = [], contenthash = [], javascriptModule, sourceFilename, ...extras } = assetInfo;
23
- extras = extras ?? {};
24
- return {
25
- immutable,
26
- minimized,
27
- development,
28
- hotModuleReplacement,
29
- related,
30
- fullhash,
31
- chunkhash,
32
- contenthash,
33
- extras,
34
- javascriptModule,
35
- sourceFilename
36
- };
37
- }
38
- }
39
- exports.JsAssetInfo = JsAssetInfo;
@@ -1,35 +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.countIterable = exports.someInIterable = exports.last = void 0;
13
- const last = (set) => {
14
- let last;
15
- for (const item of set)
16
- last = item;
17
- return last;
18
- };
19
- exports.last = last;
20
- const someInIterable = (iterable, filter) => {
21
- for (const item of iterable) {
22
- if (filter(item))
23
- return true;
24
- }
25
- return false;
26
- };
27
- exports.someInIterable = someInIterable;
28
- const countIterable = (iterable) => {
29
- let i = 0;
30
- // eslint-disable-next-line no-unused-vars
31
- for (const _ of iterable)
32
- i++;
33
- return i;
34
- };
35
- exports.countIterable = countIterable;
@@ -1,24 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- class MergeCaller {
4
- constructor(fn, debounceTime) {
5
- this.timer = null;
6
- this.callArgs = [];
7
- this.finalCall = () => {
8
- this.timer = null;
9
- const args = this.callArgs;
10
- this.callArgs = [];
11
- this.callFn(args);
12
- };
13
- this.debounceTime = debounceTime;
14
- this.callFn = fn;
15
- }
16
- push(...data) {
17
- if (this.timer) {
18
- clearTimeout(this.timer);
19
- }
20
- this.callArgs.push(...data);
21
- this.timer = setTimeout(this.finalCall, this.debounceTime);
22
- }
23
- }
24
- exports.default = MergeCaller;
@@ -1,24 +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.formatSize = void 0;
13
- const formatSize = (size) => {
14
- if (typeof size !== "number" || Number.isNaN(size) === true) {
15
- return "unknown size";
16
- }
17
- if (size <= 0) {
18
- return "0 bytes";
19
- }
20
- const abbreviations = ["bytes", "KiB", "MiB", "GiB"];
21
- const index = Math.floor(Math.log(size) / Math.log(1024));
22
- return `${+(size / 1024 ** index).toPrecision(3)} ${abbreviations[index]}`;
23
- };
24
- exports.formatSize = formatSize;
@@ -1,18 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.JsSplitChunkSizes = void 0;
4
- class JsSplitChunkSizes {
5
- static __to_binding(sizes) {
6
- if (typeof sizes === "number") {
7
- return sizes;
8
- }
9
- if (sizes && typeof sizes === "object") {
10
- const chunkSizes = {
11
- sizes: sizes
12
- };
13
- return chunkSizes;
14
- }
15
- return sizes;
16
- }
17
- }
18
- exports.JsSplitChunkSizes = JsSplitChunkSizes;
@@ -1,9 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.assertNotNill = void 0;
4
- function assertNotNill(value) {
5
- if (value == null) {
6
- throw Error(`${value} should not be undefined or null`);
7
- }
8
- }
9
- exports.assertNotNill = assertNotNill;
@@ -1,2 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
@@ -1,124 +0,0 @@
1
- "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.checkVersion = void 0;
7
- const node_fs_1 = require("node:fs");
8
- const node_path_1 = __importDefault(require("node:path"));
9
- const NodePlatformArchToAbi = {
10
- android: {
11
- arm64: "",
12
- arm: "eabi"
13
- },
14
- win32: {
15
- x64: "msvc",
16
- ia32: "msvc",
17
- arm64: "msvc"
18
- },
19
- darwin: {
20
- x64: "",
21
- arm64: ""
22
- },
23
- freebsd: {
24
- x64: ""
25
- },
26
- linux: {
27
- x64: {
28
- musl: "musl",
29
- gnu: "gnu"
30
- },
31
- arm64: {
32
- musl: "musl",
33
- gnu: "gnu"
34
- },
35
- arm: "gnueabihf"
36
- }
37
- };
38
- function isMusl() {
39
- // For Node 10
40
- if (!process.report || typeof process.report.getReport !== "function") {
41
- try {
42
- const lddPath = require("node:child_process")
43
- .execSync("which ldd")
44
- .toString()
45
- .trim();
46
- return (0, node_fs_1.readFileSync)(lddPath, "utf8").includes("musl");
47
- }
48
- catch (e) {
49
- return true;
50
- }
51
- }
52
- else {
53
- // @ts-expect-error getReport returns an object containing header object
54
- const { glibcVersionRuntime } = process.report.getReport().header;
55
- return !glibcVersionRuntime;
56
- }
57
- }
58
- const BINDING_VERSION = require("@rspack/binding/package.json").version;
59
- const CORE_VERSION = require("../../package.json").version;
60
- const getAddonPlatformArchAbi = () => {
61
- const { platform, arch } = process;
62
- let binding = "";
63
- binding += platform;
64
- const abi = NodePlatformArchToAbi[platform][arch];
65
- if (abi === undefined)
66
- return new Error(`unsupported cpu arch: ${arch}`);
67
- binding += `-${arch}`;
68
- if (typeof abi === "string") {
69
- binding += abi.length ? `-${abi}` : "";
70
- }
71
- else if (typeof abi === "object") {
72
- binding += `-${abi[isMusl() ? "musl" : "gnu"]}`;
73
- }
74
- else {
75
- return new Error(`unsupported abi: ${abi}`);
76
- }
77
- return binding;
78
- };
79
- /**
80
- * Error: version checked with error
81
- * null: version checked without any error
82
- * undefined: version to be checked
83
- */
84
- let result;
85
- /**
86
- * Check if these version matches:
87
- * `@rspack/core`, `@rspack/binding`, `@rspack/binding-<platform>-<arch>-<abi>`
88
- */
89
- const checkVersion = () => {
90
- if (result !== undefined) {
91
- return result;
92
- }
93
- const platformArchAbi = getAddonPlatformArchAbi();
94
- if (platformArchAbi instanceof Error) {
95
- return (result = platformArchAbi);
96
- }
97
- let ADDON_VERSION;
98
- try {
99
- const BINDING_PKG_DIR = node_path_1.default.dirname(require.resolve("@rspack/binding/package.json"));
100
- const isLocal = (0, node_fs_1.readdirSync)(BINDING_PKG_DIR).some(item => item === `rspack.${platformArchAbi}.node`);
101
- if (isLocal) {
102
- // Treat addon version the same as binding version if running locally
103
- ADDON_VERSION = BINDING_VERSION;
104
- }
105
- else {
106
- // Fetch addon package if installed from remote
107
- ADDON_VERSION = require(require.resolve(`@rspack/binding-${platformArchAbi}/package.json`, {
108
- paths: [BINDING_PKG_DIR]
109
- })).version;
110
- }
111
- }
112
- catch (error) {
113
- if (error instanceof Error) {
114
- return (result = new Error(`${error.toString()}. Maybe you forget to install the correct addon package ${`@rspack/binding-${platformArchAbi}`} or forget to build binding locally?`));
115
- }
116
- return (result = new Error(error));
117
- }
118
- const isMatch = [CORE_VERSION, BINDING_VERSION, ADDON_VERSION].every((v, _, arr) => v === arr[0]);
119
- if (!isMatch) {
120
- return (result = new Error(`Unmatched version @rspack/core@${CORE_VERSION}, @rspack/binding@${BINDING_VERSION}, @rspack/binding-${platformArchAbi}@${ADDON_VERSION}`));
121
- }
122
- return (result = null);
123
- };
124
- exports.checkVersion = checkVersion;