@rspack/core 1.0.10 → 1.0.12

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 (219) hide show
  1. package/compiled/browserslist/index.js +94 -49
  2. package/compiled/browserslist/package.json +1 -1
  3. package/dist/builtin-plugin/css-extract/utils.d.ts +1 -0
  4. package/dist/config/types.d.ts +309 -0
  5. package/dist/config/zod.d.ts +22 -534
  6. package/dist/cssExtractHmr.js +224 -0
  7. package/dist/cssExtractLoader.js +277 -0
  8. package/dist/index.js +23255 -31
  9. package/dist/{builtin-plugin/css-extract/hmr/hotModuleReplacement.d.ts → runtime/cssExtractHmr.d.ts} +1 -0
  10. package/dist/runtime/moduleFederationDefaultRuntime.d.ts +2 -0
  11. package/dist/stats/statsFactoryUtils.d.ts +1 -0
  12. package/package.json +8 -5
  13. package/compiled/json-parse-even-better-errors/index.d.ts +0 -1
  14. package/compiled/json-parse-even-better-errors/index.js +0 -193
  15. package/compiled/json-parse-even-better-errors/package.json +0 -1
  16. package/compiled/neo-async/index.d.ts +0 -685
  17. package/compiled/neo-async/index.js +0 -9207
  18. package/compiled/neo-async/license +0 -22
  19. package/compiled/neo-async/package.json +0 -1
  20. package/compiled/zod-validation-error/index.d.ts +0 -41
  21. package/compiled/zod-validation-error/index.js +0 -335
  22. package/compiled/zod-validation-error/license +0 -9
  23. package/compiled/zod-validation-error/package.json +0 -1
  24. package/dist/Chunk.js +0 -118
  25. package/dist/ChunkGraph.js +0 -27
  26. package/dist/ChunkGroup.js +0 -76
  27. package/dist/Compilation.js +0 -854
  28. package/dist/Compiler.js +0 -925
  29. package/dist/ContextModuleFactory.js +0 -36
  30. package/dist/DependenciesBlock.js +0 -30
  31. package/dist/Dependency.js +0 -43
  32. package/dist/Entrypoint.js +0 -21
  33. package/dist/ErrorHelpers.js +0 -62
  34. package/dist/ExecuteModulePlugin.js +0 -46
  35. package/dist/FileSystem.js +0 -34
  36. package/dist/FileSystemInfo.js +0 -2
  37. package/dist/Module.js +0 -226
  38. package/dist/ModuleTypeConstants.js +0 -92
  39. package/dist/MultiCompiler.js +0 -440
  40. package/dist/MultiStats.js +0 -161
  41. package/dist/MultiWatching.js +0 -62
  42. package/dist/NormalModule.js +0 -97
  43. package/dist/NormalModuleFactory.js +0 -43
  44. package/dist/Resolver.js +0 -39
  45. package/dist/ResolverFactory.js +0 -61
  46. package/dist/RspackError.js +0 -21
  47. package/dist/RuleSetCompiler.js +0 -10
  48. package/dist/RuntimeGlobals.js +0 -357
  49. package/dist/RuntimeModule.js +0 -58
  50. package/dist/Stats.js +0 -161
  51. package/dist/Template.js +0 -206
  52. package/dist/Watching.js +0 -290
  53. package/dist/builtin-loader/index.js +0 -17
  54. package/dist/builtin-loader/lightningcss/index.js +0 -175
  55. package/dist/builtin-loader/swc/index.js +0 -5
  56. package/dist/builtin-loader/swc/pluginImport.js +0 -35
  57. package/dist/builtin-loader/swc/react.js +0 -7
  58. package/dist/builtin-loader/swc/types.js +0 -2
  59. package/dist/builtin-plugin/APIPlugin.js +0 -6
  60. package/dist/builtin-plugin/ArrayPushCallbackChunkFormatPlugin.js +0 -6
  61. package/dist/builtin-plugin/AssetModulesPlugin.js +0 -6
  62. package/dist/builtin-plugin/AsyncWebAssemblyModulesPlugin.js +0 -6
  63. package/dist/builtin-plugin/BannerPlugin.js +0 -22
  64. package/dist/builtin-plugin/BundlerInfoRspackPlugin.js +0 -12
  65. package/dist/builtin-plugin/ChunkPrefetchPreloadPlugin.js +0 -6
  66. package/dist/builtin-plugin/CommonJsChunkFormatPlugin.js +0 -6
  67. package/dist/builtin-plugin/ContextReplacementPlugin.js +0 -43
  68. package/dist/builtin-plugin/CopyRspackPlugin.js +0 -21
  69. package/dist/builtin-plugin/CssModulesPlugin.js +0 -6
  70. package/dist/builtin-plugin/DataUriPlugin.js +0 -6
  71. package/dist/builtin-plugin/DefinePlugin.js +0 -44
  72. package/dist/builtin-plugin/DeterministicChunkIdsPlugin.js +0 -6
  73. package/dist/builtin-plugin/DeterministicModuleIdsPlugin.js +0 -6
  74. package/dist/builtin-plugin/DynamicEntryPlugin.js +0 -36
  75. package/dist/builtin-plugin/ElectronTargetPlugin.js +0 -6
  76. package/dist/builtin-plugin/EnableChunkLoadingPlugin.js +0 -6
  77. package/dist/builtin-plugin/EnableLibraryPlugin.js +0 -39
  78. package/dist/builtin-plugin/EnableWasmLoadingPlugin.js +0 -6
  79. package/dist/builtin-plugin/EnsureChunkConditionsPlugin.js +0 -6
  80. package/dist/builtin-plugin/EntryPlugin.js +0 -34
  81. package/dist/builtin-plugin/EvalDevToolModulePlugin.js +0 -6
  82. package/dist/builtin-plugin/EvalSourceMapDevToolPlugin.js +0 -16
  83. package/dist/builtin-plugin/ExternalsPlugin.js +0 -51
  84. package/dist/builtin-plugin/FetchCompileAsyncWasmPlugin.js +0 -6
  85. package/dist/builtin-plugin/FileUriPlugin.js +0 -6
  86. package/dist/builtin-plugin/FlagDependencyExportsPlugin.js +0 -6
  87. package/dist/builtin-plugin/FlagDependencyUsagePlugin.js +0 -6
  88. package/dist/builtin-plugin/HotModuleReplacementPlugin.js +0 -18
  89. package/dist/builtin-plugin/HtmlRspackPlugin.js +0 -285
  90. package/dist/builtin-plugin/HttpExternalsRspackPlugin.js +0 -11
  91. package/dist/builtin-plugin/IgnorePlugin.js +0 -20
  92. package/dist/builtin-plugin/InferAsyncModulesPlugin.js +0 -6
  93. package/dist/builtin-plugin/JavascriptModulesPlugin.js +0 -55
  94. package/dist/builtin-plugin/JsLoaderRspackPlugin.js +0 -9
  95. package/dist/builtin-plugin/JsonModulesPlugin.js +0 -6
  96. package/dist/builtin-plugin/LightningCssMiminizerRspackPlugin.js +0 -30
  97. package/dist/builtin-plugin/LimitChunkCountPlugin.js +0 -8
  98. package/dist/builtin-plugin/MangleExportsPlugin.js +0 -6
  99. package/dist/builtin-plugin/MergeDuplicateChunksPlugin.js +0 -6
  100. package/dist/builtin-plugin/ModuleChunkFormatPlugin.js +0 -6
  101. package/dist/builtin-plugin/ModuleConcatenationPlugin.js +0 -6
  102. package/dist/builtin-plugin/NamedChunkIdsPlugin.js +0 -6
  103. package/dist/builtin-plugin/NamedModuleIdsPlugin.js +0 -6
  104. package/dist/builtin-plugin/NaturalChunkIdsPlugin.js +0 -6
  105. package/dist/builtin-plugin/NaturalModuleIdsPlugin.js +0 -6
  106. package/dist/builtin-plugin/NoEmitOnErrorsPlugin.js +0 -6
  107. package/dist/builtin-plugin/NodeTargetPlugin.js +0 -6
  108. package/dist/builtin-plugin/ProgressPlugin.js +0 -15
  109. package/dist/builtin-plugin/ProvidePlugin.js +0 -14
  110. package/dist/builtin-plugin/RealContentHashPlugin.js +0 -6
  111. package/dist/builtin-plugin/RemoveEmptyChunksPlugin.js +0 -6
  112. package/dist/builtin-plugin/RuntimeChunkPlugin.js +0 -6
  113. package/dist/builtin-plugin/RuntimePlugin.js +0 -6
  114. package/dist/builtin-plugin/SideEffectsFlagPlugin.js +0 -6
  115. package/dist/builtin-plugin/SizeLimitsPlugin.js +0 -9
  116. package/dist/builtin-plugin/SourceMapDevToolPlugin.js +0 -14
  117. package/dist/builtin-plugin/SplitChunksPlugin.js +0 -92
  118. package/dist/builtin-plugin/SwcJsMinimizerPlugin.js +0 -80
  119. package/dist/builtin-plugin/WarnCaseSensitiveModulesPlugin.js +0 -6
  120. package/dist/builtin-plugin/WebWorkerTemplatePlugin.js +0 -6
  121. package/dist/builtin-plugin/WorkerPlugin.js +0 -31
  122. package/dist/builtin-plugin/base.js +0 -58
  123. package/dist/builtin-plugin/css-extract/hmr/hotModuleReplacement.js +0 -182
  124. package/dist/builtin-plugin/css-extract/hmr/normalizeUrl.d.ts +0 -2
  125. package/dist/builtin-plugin/css-extract/hmr/normalizeUrl.js +0 -31
  126. package/dist/builtin-plugin/css-extract/index.js +0 -105
  127. package/dist/builtin-plugin/css-extract/loader.js +0 -204
  128. package/dist/builtin-plugin/css-extract/utils.js +0 -51
  129. package/dist/builtin-plugin/index.js +0 -84
  130. package/dist/builtin-plugin/lazy-compilation/backend.js +0 -139
  131. package/dist/builtin-plugin/lazy-compilation/lazyCompilation.js +0 -6
  132. package/dist/builtin-plugin/lazy-compilation/plugin.js +0 -60
  133. package/dist/config/adapter.js +0 -691
  134. package/dist/config/adapterRuleUse.js +0 -107
  135. package/dist/config/browserslistTargetHandler.js +0 -345
  136. package/dist/config/defaults.js +0 -876
  137. package/dist/config/index.js +0 -20
  138. package/dist/config/normalization.js +0 -299
  139. package/dist/config/target.js +0 -318
  140. package/dist/config/types.js +0 -3
  141. package/dist/config/zod.js +0 -1030
  142. package/dist/container/ContainerPlugin.js +0 -50
  143. package/dist/container/ContainerReferencePlugin.js +0 -49
  144. package/dist/container/ModuleFederationPlugin.js +0 -137
  145. package/dist/container/ModuleFederationPluginV1.js +0 -63
  146. package/dist/container/ModuleFederationRuntimePlugin.js +0 -6
  147. package/dist/container/options.js +0 -48
  148. package/dist/error/ConcurrentCompilationError.js +0 -20
  149. package/dist/exports.js +0 -183
  150. package/dist/lib/AbstractMethodError.js +0 -51
  151. package/dist/lib/Cache.js +0 -111
  152. package/dist/lib/CacheFacade.js +0 -321
  153. package/dist/lib/Dependency.js +0 -11
  154. package/dist/lib/EntryOptionPlugin.js +0 -89
  155. package/dist/lib/EnvironmentPlugin.js +0 -57
  156. package/dist/lib/HookWebpackError.js +0 -83
  157. package/dist/lib/IgnoreWarningsPlugin.js +0 -35
  158. package/dist/lib/LoaderOptionsPlugin.js +0 -74
  159. package/dist/lib/LoaderTargetPlugin.js +0 -37
  160. package/dist/lib/ModuleFilenameHelpers.js +0 -83
  161. package/dist/lib/NormalModuleReplacementPlugin.js +0 -85
  162. package/dist/lib/WebpackError.js +0 -20
  163. package/dist/lib/cache/MemoryCachePlugin.js +0 -40
  164. package/dist/lib/cache/getLazyHashedEtag.js +0 -73
  165. package/dist/lib/cache/mergeEtags.js +0 -74
  166. package/dist/lib/formatLocation.js +0 -64
  167. package/dist/loader-runner/LoaderLoadingError.js +0 -19
  168. package/dist/loader-runner/index.js +0 -735
  169. package/dist/loader-runner/loadLoader.js +0 -64
  170. package/dist/logging/Logger.js +0 -143
  171. package/dist/logging/createConsoleLogger.js +0 -176
  172. package/dist/logging/runtime.js +0 -37
  173. package/dist/logging/truncateArgs.js +0 -81
  174. package/dist/node/NodeEnvironmentPlugin.js +0 -50
  175. package/dist/node/NodeTemplatePlugin.js +0 -26
  176. package/dist/node/NodeWatchFileSystem.js +0 -144
  177. package/dist/node/nodeConsole.js +0 -146
  178. package/dist/rspack.js +0 -123
  179. package/dist/rspackOptionsApply.js +0 -274
  180. package/dist/sharing/ConsumeSharedPlugin.js +0 -69
  181. package/dist/sharing/ProvideSharedPlugin.js +0 -50
  182. package/dist/sharing/SharePlugin.js +0 -66
  183. package/dist/sharing/ShareRuntimePlugin.js +0 -26
  184. package/dist/sharing/utils.js +0 -8
  185. package/dist/stats/DefaultStatsFactoryPlugin.js +0 -1173
  186. package/dist/stats/DefaultStatsPresetPlugin.js +0 -305
  187. package/dist/stats/DefaultStatsPrinterPlugin.js +0 -1069
  188. package/dist/stats/StatsFactory.js +0 -167
  189. package/dist/stats/StatsPrinter.js +0 -142
  190. package/dist/stats/statsFactoryUtils.js +0 -341
  191. package/dist/util/ArrayQueue.js +0 -108
  192. package/dist/util/AssetInfo.js +0 -39
  193. package/dist/util/IterableHelpers.js +0 -35
  194. package/dist/util/MergeCaller.js +0 -24
  195. package/dist/util/SizeFormatHelpers.js +0 -24
  196. package/dist/util/SplitChunkSize.js +0 -18
  197. package/dist/util/assertNotNil.js +0 -9
  198. package/dist/util/assetCondition.js +0 -2
  199. package/dist/util/bindingVersionCheck.js +0 -124
  200. package/dist/util/cleverMerge.js +0 -504
  201. package/dist/util/comparators.js +0 -108
  202. package/dist/util/createHash.js +0 -161
  203. package/dist/util/createReadonlyMap.js +0 -29
  204. package/dist/util/fake.js +0 -28
  205. package/dist/util/fs.js +0 -120
  206. package/dist/util/hash/BatchedHash.js +0 -69
  207. package/dist/util/hash/index.js +0 -39
  208. package/dist/util/hash/md4.js +0 -27
  209. package/dist/util/hash/wasm-hash.js +0 -167
  210. package/dist/util/hash/xxhash64.js +0 -27
  211. package/dist/util/identifier.js +0 -330
  212. package/dist/util/index.js +0 -123
  213. package/dist/util/memoize.js +0 -61
  214. package/dist/util/scheme.js +0 -57
  215. package/dist/util/smartGrouping.js +0 -148
  216. package/dist/util/source.js +0 -42
  217. package/dist/util/validate.js +0 -77
  218. package/dist/util/webpack.js +0 -27
  219. /package/dist/{container/default.runtime.js → moduleFederationDefaultRuntime.js} +0 -0
@@ -1,144 +0,0 @@
1
- "use strict";
2
- /**
3
- * The following code is modified based on
4
- * https://github.com/webpack/webpack/blob/4b4ca3b/lib/node/NodeWatchFileSystem.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
- const node_util_1 = __importDefault(require("node:util"));
16
- const watchpack_1 = __importDefault(require("../../compiled/watchpack"));
17
- class NodeWatchFileSystem {
18
- constructor(inputFileSystem) {
19
- this.inputFileSystem = inputFileSystem;
20
- this.watcherOptions = {
21
- aggregateTimeout: 0
22
- };
23
- this.watcher = new watchpack_1.default(this.watcherOptions);
24
- }
25
- watch(files, directories, missing, startTime, options, callback, callbackUndelayed) {
26
- if (!files || typeof files[Symbol.iterator] !== "function") {
27
- throw new Error("Invalid arguments: 'files'");
28
- }
29
- if (!directories || typeof directories[Symbol.iterator] !== "function") {
30
- throw new Error("Invalid arguments: 'directories'");
31
- }
32
- if (!missing || typeof missing[Symbol.iterator] !== "function") {
33
- throw new Error("Invalid arguments: 'missing'");
34
- }
35
- if (typeof callback !== "function") {
36
- throw new Error("Invalid arguments: 'callback'");
37
- }
38
- if (typeof startTime !== "number" && startTime) {
39
- throw new Error("Invalid arguments: 'startTime'");
40
- }
41
- if (typeof options !== "object") {
42
- throw new Error("Invalid arguments: 'options'");
43
- }
44
- if (typeof callbackUndelayed !== "function" && callbackUndelayed) {
45
- throw new Error("Invalid arguments: 'callbackUndelayed'");
46
- }
47
- const oldWatcher = this.watcher;
48
- this.watcher = new watchpack_1.default(options);
49
- if (callbackUndelayed) {
50
- this.watcher.once("change", callbackUndelayed);
51
- }
52
- const fetchTimeInfo = () => {
53
- const fileTimeInfoEntries = new Map();
54
- const contextTimeInfoEntries = new Map();
55
- if (this.watcher) {
56
- this.watcher.collectTimeInfoEntries(fileTimeInfoEntries, contextTimeInfoEntries);
57
- }
58
- return { fileTimeInfoEntries, contextTimeInfoEntries };
59
- };
60
- this.watcher.once("aggregated", (changes, removals) => {
61
- // pause emitting events (avoids clearing aggregated changes and removals on timeout)
62
- this.watcher.pause();
63
- if (this.inputFileSystem?.purge) {
64
- const fs = this.inputFileSystem;
65
- for (const item of changes) {
66
- fs.purge?.(item);
67
- }
68
- for (const item of removals) {
69
- fs.purge?.(item);
70
- }
71
- }
72
- const { fileTimeInfoEntries, contextTimeInfoEntries } = fetchTimeInfo();
73
- callback(null, fileTimeInfoEntries, contextTimeInfoEntries, changes, removals);
74
- });
75
- this.watcher.watch({ files, directories, missing, startTime });
76
- if (oldWatcher) {
77
- oldWatcher.close();
78
- }
79
- return {
80
- close: () => {
81
- if (this.watcher) {
82
- this.watcher.close();
83
- this.watcher = null;
84
- }
85
- },
86
- pause: () => {
87
- if (this.watcher) {
88
- this.watcher.pause();
89
- }
90
- },
91
- getAggregatedRemovals: node_util_1.default.deprecate(() => {
92
- const items = this.watcher?.aggregatedRemovals;
93
- if (items && this.inputFileSystem?.purge) {
94
- const fs = this.inputFileSystem;
95
- for (const item of items) {
96
- fs.purge?.(item);
97
- }
98
- }
99
- return items;
100
- }, "Watcher.getAggregatedRemovals is deprecated in favor of Watcher.getInfo since that's more performant.", "DEP_WEBPACK_WATCHER_GET_AGGREGATED_REMOVALS"),
101
- getAggregatedChanges: node_util_1.default.deprecate(() => {
102
- const items = this.watcher?.aggregatedChanges;
103
- if (items && this.inputFileSystem?.purge) {
104
- const fs = this.inputFileSystem;
105
- for (const item of items) {
106
- fs.purge?.(item);
107
- }
108
- }
109
- return items;
110
- }, "Watcher.getAggregatedChanges is deprecated in favor of Watcher.getInfo since that's more performant.", "DEP_WEBPACK_WATCHER_GET_AGGREGATED_CHANGES"),
111
- getFileTimeInfoEntries: node_util_1.default.deprecate(() => {
112
- return fetchTimeInfo().fileTimeInfoEntries;
113
- }, "Watcher.getFileTimeInfoEntries is deprecated in favor of Watcher.getInfo since that's more performant.", "DEP_WEBPACK_WATCHER_FILE_TIME_INFO_ENTRIES"),
114
- getContextTimeInfoEntries: node_util_1.default.deprecate(() => {
115
- return fetchTimeInfo().contextTimeInfoEntries;
116
- }, "Watcher.getContextTimeInfoEntries is deprecated in favor of Watcher.getInfo since that's more performant.", "DEP_WEBPACK_WATCHER_CONTEXT_TIME_INFO_ENTRIES"),
117
- getInfo: () => {
118
- const removals = this.watcher?.aggregatedRemovals;
119
- const changes = this.watcher?.aggregatedChanges;
120
- if (this.inputFileSystem?.purge) {
121
- const fs = this.inputFileSystem;
122
- if (removals) {
123
- for (const item of removals) {
124
- fs.purge?.(item);
125
- }
126
- }
127
- if (changes) {
128
- for (const item of changes) {
129
- fs.purge?.(item);
130
- }
131
- }
132
- }
133
- const { fileTimeInfoEntries, contextTimeInfoEntries } = fetchTimeInfo();
134
- return {
135
- changes,
136
- removals,
137
- fileTimeInfoEntries,
138
- contextTimeInfoEntries
139
- };
140
- }
141
- };
142
- }
143
- }
144
- exports.default = NodeWatchFileSystem;
@@ -1,146 +0,0 @@
1
- "use strict";
2
- /**
3
- * The following code is modified based on
4
- * https://github.com/webpack/webpack/blob/4b4ca3b/lib/node/nodeConsole.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 __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
12
- if (k2 === undefined) k2 = k;
13
- var desc = Object.getOwnPropertyDescriptor(m, k);
14
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
15
- desc = { enumerable: true, get: function() { return m[k]; } };
16
- }
17
- Object.defineProperty(o, k2, desc);
18
- }) : (function(o, m, k, k2) {
19
- if (k2 === undefined) k2 = k;
20
- o[k2] = m[k];
21
- }));
22
- var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
23
- Object.defineProperty(o, "default", { enumerable: true, value: v });
24
- }) : function(o, v) {
25
- o["default"] = v;
26
- });
27
- var __importStar = (this && this.__importStar) || function (mod) {
28
- if (mod && mod.__esModule) return mod;
29
- var result = {};
30
- if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
31
- __setModuleDefault(result, mod);
32
- return result;
33
- };
34
- Object.defineProperty(exports, "__esModule", { value: true });
35
- const util = __importStar(require("node:util"));
36
- const truncateArgs_1 = require("../logging/truncateArgs");
37
- function default_1({ colors, appendOnly, stream }) {
38
- let currentStatusMessage = undefined;
39
- let hasStatusMessage = false;
40
- let currentIndent = "";
41
- let currentCollapsed = 0;
42
- const indent = (str, prefix, colorPrefix, colorSuffix) => {
43
- if (str === "")
44
- return str;
45
- const prefixWithIndent = currentIndent + prefix;
46
- if (colors) {
47
- return (prefixWithIndent +
48
- colorPrefix +
49
- str.replace(/\n/g, `${colorSuffix}\n${prefix}${colorPrefix}`) +
50
- colorSuffix);
51
- }
52
- return prefixWithIndent + str.replace(/\n/g, `\n${prefix}`);
53
- };
54
- const clearStatusMessage = () => {
55
- if (hasStatusMessage) {
56
- stream.write("\x1b[2K\r");
57
- hasStatusMessage = false;
58
- }
59
- };
60
- const writeStatusMessage = () => {
61
- if (!currentStatusMessage)
62
- return;
63
- // cannot be resolved without assertion, copy from webpack
64
- // Property 'columns' does not exist on type 'WritableStream'.ts(2339)
65
- const l = stream.columns;
66
- const args = l
67
- ? (0, truncateArgs_1.truncateArgs)(currentStatusMessage, l - 1)
68
- : currentStatusMessage;
69
- const str = args.join(" ");
70
- const coloredStr = `\u001b[1m${str}\u001b[39m\u001b[22m`;
71
- stream.write(`\x1b[2K\r${coloredStr}`);
72
- hasStatusMessage = true;
73
- };
74
- const writeColored = (prefix, colorPrefix, colorSuffix) => {
75
- return (...args) => {
76
- if (currentCollapsed > 0)
77
- return;
78
- clearStatusMessage();
79
- const str = indent(util.format(...args), prefix, colorPrefix, colorSuffix);
80
- stream.write(`${str}\n`);
81
- writeStatusMessage();
82
- };
83
- };
84
- const writeGroupMessage = writeColored("<-> ", "\u001b[1m\u001b[36m", "\u001b[39m\u001b[22m");
85
- const writeGroupCollapsedMessage = writeColored("<+> ", "\u001b[1m\u001b[36m", "\u001b[39m\u001b[22m");
86
- return {
87
- log: writeColored(" ", "\u001b[1m", "\u001b[22m"),
88
- debug: writeColored(" ", "", ""),
89
- trace: writeColored(" ", "", ""),
90
- info: writeColored("<i> ", "\u001b[1m\u001b[32m", "\u001b[39m\u001b[22m"),
91
- warn: writeColored("<w> ", "\u001b[1m\u001b[33m", "\u001b[39m\u001b[22m"),
92
- error: writeColored("<e> ", "\u001b[1m\u001b[31m", "\u001b[39m\u001b[22m"),
93
- logTime: writeColored("<t> ", "\u001b[1m\u001b[35m", "\u001b[39m\u001b[22m"),
94
- group: (...args) => {
95
- writeGroupMessage(...args);
96
- if (currentCollapsed > 0) {
97
- currentCollapsed++;
98
- }
99
- else {
100
- currentIndent += " ";
101
- }
102
- },
103
- groupCollapsed: (...args) => {
104
- writeGroupCollapsedMessage(...args);
105
- currentCollapsed++;
106
- },
107
- groupEnd: () => {
108
- if (currentCollapsed > 0)
109
- currentCollapsed--;
110
- else if (currentIndent.length >= 2)
111
- currentIndent = currentIndent.slice(0, currentIndent.length - 2);
112
- },
113
- profile: console.profile && (name => console.profile(name)),
114
- profileEnd: console.profileEnd && (name => console.profileEnd(name)),
115
- clear: (!appendOnly &&
116
- console.clear &&
117
- (() => {
118
- clearStatusMessage();
119
- console.clear();
120
- writeStatusMessage();
121
- })),
122
- status: appendOnly
123
- ? writeColored("<s> ", "", "")
124
- : (name, ...argsWithEmpty) => {
125
- const args = argsWithEmpty.filter(Boolean);
126
- if (name === undefined && args.length === 0) {
127
- clearStatusMessage();
128
- currentStatusMessage = undefined;
129
- }
130
- else if (typeof name === "string" &&
131
- name.startsWith("[webpack.Progress] ")) {
132
- currentStatusMessage = [name.slice(19), ...args];
133
- writeStatusMessage();
134
- }
135
- else if (name === "[webpack.Progress]") {
136
- currentStatusMessage = [...args];
137
- writeStatusMessage();
138
- }
139
- else {
140
- currentStatusMessage = [name, ...args];
141
- writeStatusMessage();
142
- }
143
- }
144
- };
145
- }
146
- exports.default = default_1;
package/dist/rspack.js DELETED
@@ -1,123 +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.Stats = exports.rspack = exports.MultiStats = exports.createMultiCompiler = exports.createCompiler = void 0;
7
- /**
8
- * The following code is modified based on
9
- * https://github.com/webpack/webpack/blob/4b4ca3b/lib
10
- *
11
- * MIT Licensed
12
- * Author Tobias Koppers @sokra
13
- * Copyright (c) JS Foundation and other contributors
14
- * https://github.com/webpack/webpack/blob/main/LICENSE
15
- */
16
- const node_assert_1 = __importDefault(require("node:assert"));
17
- const node_util_1 = __importDefault(require("node:util"));
18
- const Compiler_1 = require("./Compiler");
19
- const MultiCompiler_1 = require("./MultiCompiler");
20
- const MultiStats_1 = __importDefault(require("./MultiStats"));
21
- exports.MultiStats = MultiStats_1.default;
22
- const Stats_1 = require("./Stats");
23
- Object.defineProperty(exports, "Stats", { enumerable: true, get: function () { return Stats_1.Stats; } });
24
- const config_1 = require("./config");
25
- const NodeEnvironmentPlugin_1 = __importDefault(require("./node/NodeEnvironmentPlugin"));
26
- const rspackOptionsApply_1 = require("./rspackOptionsApply");
27
- const util_1 = require("./util");
28
- const validate_1 = require("./util/validate");
29
- function createMultiCompiler(options) {
30
- const compilers = options.map(createCompiler);
31
- const compiler = new MultiCompiler_1.MultiCompiler(compilers, options);
32
- for (const childCompiler of compilers) {
33
- if (childCompiler.options.dependencies) {
34
- compiler.setDependencies(childCompiler, childCompiler.options.dependencies);
35
- }
36
- }
37
- return compiler;
38
- }
39
- exports.createMultiCompiler = createMultiCompiler;
40
- function createCompiler(userOptions) {
41
- const options = (0, config_1.getNormalizedRspackOptions)(userOptions);
42
- (0, config_1.applyRspackOptionsBaseDefaults)(options);
43
- (0, node_assert_1.default)(!(0, util_1.isNil)(options.context));
44
- const compiler = new Compiler_1.Compiler(options.context, options);
45
- new NodeEnvironmentPlugin_1.default({
46
- infrastructureLogging: options.infrastructureLogging
47
- }).apply(compiler);
48
- if (Array.isArray(options.plugins)) {
49
- for (const plugin of options.plugins) {
50
- if (typeof plugin === "function") {
51
- plugin.call(compiler, compiler);
52
- }
53
- else if (plugin) {
54
- plugin.apply(compiler);
55
- }
56
- }
57
- }
58
- (0, config_1.applyRspackOptionsDefaults)(compiler.options);
59
- compiler.hooks.environment.call();
60
- compiler.hooks.afterEnvironment.call();
61
- new rspackOptionsApply_1.RspackOptionsApply().process(compiler.options, compiler);
62
- compiler.hooks.initialize.call();
63
- return compiler;
64
- }
65
- exports.createCompiler = createCompiler;
66
- function isMultiRspackOptions(o) {
67
- return Array.isArray(o);
68
- }
69
- function rspack(options, callback) {
70
- try {
71
- for (const o of (0, util_1.asArray)(options)) {
72
- (0, validate_1.validate)(o, config_1.rspackOptions);
73
- }
74
- }
75
- catch (e) {
76
- if (e instanceof Error && callback) {
77
- callback(e);
78
- return null;
79
- }
80
- throw e;
81
- }
82
- const create = () => {
83
- if (isMultiRspackOptions(options)) {
84
- const compiler = createMultiCompiler(options);
85
- const watch = options.some(options => options.watch);
86
- const watchOptions = options.map(options => options.watchOptions || {});
87
- return { compiler, watch, watchOptions };
88
- }
89
- const compiler = createCompiler(options);
90
- const watch = options.watch;
91
- const watchOptions = options.watchOptions || {};
92
- return { compiler, watch, watchOptions };
93
- };
94
- if (callback) {
95
- try {
96
- const { compiler, watch, watchOptions } = create();
97
- if (watch) {
98
- compiler.watch(watchOptions, callback);
99
- }
100
- else {
101
- compiler.run((err, stats) => {
102
- compiler.close(() => {
103
- callback(err, stats);
104
- });
105
- });
106
- }
107
- return compiler;
108
- }
109
- catch (err) {
110
- process.nextTick(() => callback(err));
111
- return null;
112
- }
113
- }
114
- else {
115
- const { compiler, watch } = create();
116
- if (watch) {
117
- node_util_1.default.deprecate(() => { }, "A 'callback' argument needs to be provided to the 'rspack(options, callback)' function when the 'watch' option is set. There is no way to handle the 'watch' option without a callback.")();
118
- }
119
- return compiler;
120
- }
121
- }
122
- exports.rspack = rspack;
123
- exports.default = rspack;