@rspack/core 0.6.5-canary-6d6fcd3-20240514084813 → 0.6.5-canary-231c64e-20240515075232

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 (145) hide show
  1. package/dist/Chunk.d.ts +1 -1
  2. package/dist/Chunk.js +1 -1
  3. package/dist/ChunkGroup.d.ts +1 -1
  4. package/dist/ChunkGroup.js +3 -3
  5. package/dist/Compilation.d.ts +46 -65
  6. package/dist/Compilation.js +128 -222
  7. package/dist/Compiler.d.ts +75 -44
  8. package/dist/Compiler.js +325 -278
  9. package/dist/ContextModuleFactory.d.ts +7 -3
  10. package/dist/ContextModuleFactory.js +2 -2
  11. package/dist/Entrypoint.d.ts +1 -1
  12. package/dist/Entrypoint.js +1 -1
  13. package/dist/ExecuteModulePlugin.js +1 -1
  14. package/dist/Module.d.ts +11 -0
  15. package/dist/Module.js +2 -2
  16. package/dist/MultiCompiler.d.ts +10 -25
  17. package/dist/MultiCompiler.js +3 -3
  18. package/dist/MultiStats.d.ts +1 -1
  19. package/dist/NormalModuleFactory.d.ts +1 -1
  20. package/dist/Stats.d.ts +2 -2
  21. package/dist/Watching.d.ts +0 -9
  22. package/dist/Watching.js +12 -2
  23. package/dist/builtin-loader/swc/index.d.ts +6 -6
  24. package/dist/builtin-loader/swc/index.js +3 -3
  25. package/dist/builtin-loader/swc/types.d.ts +2 -2
  26. package/dist/builtin-plugin/APIPlugin.d.ts +1 -1
  27. package/dist/builtin-plugin/ArrayPushCallbackChunkFormatPlugin.d.ts +1 -1
  28. package/dist/builtin-plugin/AssetModulesPlugin.d.ts +1 -1
  29. package/dist/builtin-plugin/AsyncWebAssemblyModulesPlugin.d.ts +1 -1
  30. package/dist/builtin-plugin/BannerPlugin.d.ts +2 -2
  31. package/dist/builtin-plugin/BannerPlugin.js +1 -1
  32. package/dist/builtin-plugin/BundlerInfoRspackPlugin.d.ts +1 -1
  33. package/dist/builtin-plugin/ChunkPrefetchPreloadPlugin.d.ts +1 -1
  34. package/dist/builtin-plugin/CommonJsChunkFormatPlugin.d.ts +1 -1
  35. package/dist/builtin-plugin/CopyRspackPlugin.d.ts +1 -1
  36. package/dist/builtin-plugin/CssModulesPlugin.d.ts +1 -1
  37. package/dist/builtin-plugin/DataUriPlugin.d.ts +1 -1
  38. package/dist/builtin-plugin/DefinePlugin.d.ts +1 -1
  39. package/dist/builtin-plugin/DeterministicChunkIdsPlugin.d.ts +1 -1
  40. package/dist/builtin-plugin/DeterministicModuleIdsPlugin.d.ts +1 -1
  41. package/dist/builtin-plugin/DynamicEntryPlugin.d.ts +1 -1
  42. package/dist/builtin-plugin/DynamicEntryPlugin.js +1 -1
  43. package/dist/builtin-plugin/ElectronTargetPlugin.d.ts +1 -1
  44. package/dist/builtin-plugin/EnableChunkLoadingPlugin.d.ts +1 -1
  45. package/dist/builtin-plugin/EnableLibraryPlugin.d.ts +1 -1
  46. package/dist/builtin-plugin/EnableWasmLoadingPlugin.d.ts +1 -1
  47. package/dist/builtin-plugin/EnsureChunkConditionsPlugin.d.ts +1 -1
  48. package/dist/builtin-plugin/EntryPlugin.d.ts +1 -1
  49. package/dist/builtin-plugin/EntryPlugin.js +1 -1
  50. package/dist/builtin-plugin/EvalDevToolModulePlugin.d.ts +1 -1
  51. package/dist/builtin-plugin/EvalSourceMapDevToolPlugin.d.ts +1 -1
  52. package/dist/builtin-plugin/ExternalsPlugin.d.ts +3 -3
  53. package/dist/builtin-plugin/FileUriPlugin.d.ts +1 -1
  54. package/dist/builtin-plugin/FlagDependencyExportsPlugin.d.ts +1 -1
  55. package/dist/builtin-plugin/FlagDependencyUsagePlugin.d.ts +1 -1
  56. package/dist/builtin-plugin/HtmlRspackPlugin.d.ts +2 -2
  57. package/dist/builtin-plugin/HtmlRspackPlugin.js +2 -2
  58. package/dist/builtin-plugin/HttpExternalsRspackPlugin.d.ts +1 -1
  59. package/dist/builtin-plugin/IgnorePlugin.d.ts +1 -1
  60. package/dist/builtin-plugin/InferAsyncModulesPlugin.d.ts +1 -1
  61. package/dist/builtin-plugin/JavascriptModulesPlugin.d.ts +1 -1
  62. package/dist/builtin-plugin/JsLoaderRspackPlugin.d.ts +1 -1
  63. package/dist/builtin-plugin/JsLoaderRspackPlugin.js +1 -1
  64. package/dist/builtin-plugin/JsonModulesPlugin.d.ts +1 -1
  65. package/dist/builtin-plugin/LimitChunkCountPlugin.d.ts +1 -1
  66. package/dist/builtin-plugin/MangleExportsPlugin.d.ts +1 -1
  67. package/dist/builtin-plugin/MergeDuplicateChunksPlugin.d.ts +1 -1
  68. package/dist/builtin-plugin/ModuleChunkFormatPlugin.d.ts +1 -1
  69. package/dist/builtin-plugin/ModuleConcatenationPlugin.d.ts +1 -1
  70. package/dist/builtin-plugin/NamedChunkIdsPlugin.d.ts +1 -1
  71. package/dist/builtin-plugin/NamedModuleIdsPlugin.d.ts +1 -1
  72. package/dist/builtin-plugin/NodeTargetPlugin.d.ts +1 -1
  73. package/dist/builtin-plugin/ProgressPlugin.d.ts +1 -1
  74. package/dist/builtin-plugin/ProvidePlugin.d.ts +1 -1
  75. package/dist/builtin-plugin/RealContentHashPlugin.d.ts +1 -1
  76. package/dist/builtin-plugin/RemoveEmptyChunksPlugin.d.ts +1 -1
  77. package/dist/builtin-plugin/RuntimeChunkPlugin.d.ts +1 -1
  78. package/dist/builtin-plugin/RuntimePlugin.d.ts +1 -1
  79. package/dist/builtin-plugin/SideEffectsFlagPlugin.d.ts +1 -1
  80. package/dist/builtin-plugin/SizeLimitsPlugin.d.ts +1 -1
  81. package/dist/builtin-plugin/SourceMapDevToolPlugin.d.ts +1 -1
  82. package/dist/builtin-plugin/SplitChunksPlugin.d.ts +2 -2
  83. package/dist/builtin-plugin/SplitChunksPlugin.js +4 -4
  84. package/dist/builtin-plugin/SwcCssMinimizerPlugin.d.ts +1 -1
  85. package/dist/builtin-plugin/SwcJsMinimizerPlugin.d.ts +1 -1
  86. package/dist/builtin-plugin/WarnCaseSensitiveModulesPlugin.d.ts +1 -1
  87. package/dist/builtin-plugin/WebWorkerTemplatePlugin.d.ts +1 -1
  88. package/dist/builtin-plugin/WorkerPlugin.d.ts +2 -2
  89. package/dist/builtin-plugin/base.d.ts +1 -1
  90. package/dist/builtin-plugin/css-extract/index.d.ts +5 -4
  91. package/dist/builtin-plugin/css-extract/loader.d.ts +1 -1
  92. package/dist/builtin-plugin/css-extract/loader.js +2 -2
  93. package/dist/builtin-plugin/index.d.ts +43 -43
  94. package/dist/builtin-plugin/index.js +43 -43
  95. package/dist/config/adapter.d.ts +2 -2
  96. package/dist/config/adapterRuleUse.d.ts +2 -1
  97. package/dist/config/adapterRuleUse.js +2 -2
  98. package/dist/config/defaults.js +3 -3
  99. package/dist/config/index.d.ts +2 -2
  100. package/dist/config/index.js +2 -2
  101. package/dist/config/normalization.d.ts +1 -1
  102. package/dist/config/zod.d.ts +169 -176
  103. package/dist/config/zod.js +2 -15
  104. package/dist/container/ContainerPlugin.d.ts +1 -1
  105. package/dist/container/ContainerReferencePlugin.d.ts +1 -1
  106. package/dist/container/ContainerReferencePlugin.js +1 -1
  107. package/dist/container/ModuleFederationPlugin.js +1 -1
  108. package/dist/container/ModuleFederationPluginV1.d.ts +1 -1
  109. package/dist/container/ModuleFederationPluginV1.js +1 -1
  110. package/dist/container/ModuleFederationRuntimePlugin.d.ts +1 -1
  111. package/dist/exports.d.ts +34 -30
  112. package/dist/exports.js +21 -18
  113. package/dist/fileSystem.d.ts +12 -8
  114. package/dist/fileSystem.js +25 -48
  115. package/dist/index.d.ts +1 -1
  116. package/dist/index.js +1 -1
  117. package/dist/lite-tapable/index.d.ts +6 -0
  118. package/dist/lite-tapable/index.js +107 -1
  119. package/dist/loader-runner/index.js +13 -13
  120. package/dist/logging/Logger.d.ts +1 -1
  121. package/dist/logging/createConsoleLogger.js +0 -14
  122. package/dist/node/NodeEnvironmentPlugin.d.ts +1 -1
  123. package/dist/node/NodeEnvironmentPlugin.js +1 -1
  124. package/dist/node/nodeConsole.js +0 -4
  125. package/dist/rspack.d.ts +4 -13
  126. package/dist/rspack.js +8 -8
  127. package/dist/rspackOptionsApply.d.ts +1 -10
  128. package/dist/rspackOptionsApply.js +14 -5
  129. package/dist/sharing/ConsumeSharedPlugin.d.ts +1 -1
  130. package/dist/sharing/ConsumeSharedPlugin.js +1 -1
  131. package/dist/stats/DefaultStatsFactoryPlugin.js +2 -2
  132. package/dist/stats/StatsFactory.d.ts +2 -2
  133. package/dist/stats/StatsFactory.js +0 -9
  134. package/dist/stats/StatsPrinter.d.ts +1 -1
  135. package/dist/stats/statsFactoryUtils.d.ts +1 -1
  136. package/dist/util/comparators.d.ts +1 -1
  137. package/dist/util/fs.d.ts +64 -0
  138. package/dist/util/fs.js +122 -0
  139. package/dist/util/index.d.ts +2 -1
  140. package/dist/util/index.js +16 -11
  141. package/dist/util/source.d.ts +18 -0
  142. package/dist/util/source.js +66 -0
  143. package/package.json +4 -4
  144. package/dist/util/createSource.d.ts +0 -5
  145. package/dist/util/createSource.js +0 -65
@@ -11,12 +11,12 @@
11
11
  Object.defineProperty(exports, "__esModule", { value: true });
12
12
  exports.runLoaders = exports.parsePathQueryFragment = void 0;
13
13
  const webpack_sources_1 = require("webpack-sources");
14
- const NormalModule_1 = require("../NormalModule");
15
14
  const adapterRuleUse_1 = require("../config/adapterRuleUse");
15
+ const NormalModule_1 = require("../NormalModule");
16
16
  const util_1 = require("../util");
17
+ const createHash_1 = require("../util/createHash");
17
18
  const identifier_1 = require("../util/identifier");
18
19
  const memoize_1 = require("../util/memoize");
19
- const createHash_1 = require("../util/createHash");
20
20
  const loadLoader = require("./loadLoader");
21
21
  const querystring = require("node:querystring");
22
22
  const PATH_QUERY_FRAGMENT_REGEXP = /^((?:\0.|[^?#\0])*)(\?(?:\0.|[^#\0])*)?(#.*)?$/;
@@ -151,7 +151,7 @@ async function runLoaders(compiler, rawContext) {
151
151
  "When using a function for Rule.use in config you need to " +
152
152
  "provide an 'ident' property for referenced loader options.");
153
153
  }
154
- obj.options = compiler.ruleSet.references.get(ident);
154
+ obj.options = compiler.__internal__ruleSet.references.get(ident);
155
155
  if (obj.options === undefined) {
156
156
  throw new Error(`Invalid ident("${ident}") is provided by referenced loader`);
157
157
  }
@@ -201,7 +201,7 @@ async function runLoaders(compiler, rawContext) {
201
201
  if (!callback) {
202
202
  return new Promise((resolve, reject) => {
203
203
  compiler
204
- .compilation.__internal_getInner()
204
+ ._lastCompilation.__internal_getInner()
205
205
  .importModule(request, options.publicPath, options.baseUri, rawContext._moduleIdentifier, loaderContext.context, (err, res) => {
206
206
  if (err)
207
207
  reject(err);
@@ -225,7 +225,7 @@ async function runLoaders(compiler, rawContext) {
225
225
  });
226
226
  }
227
227
  return compiler
228
- .compilation.__internal_getInner()
228
+ ._lastCompilation.__internal_getInner()
229
229
  .importModule(request, options.publicPath, options.baseUri, rawContext._moduleIdentifier, loaderContext.context, (err, res) => {
230
230
  if (err) {
231
231
  callback(err, undefined);
@@ -386,22 +386,22 @@ async function runLoaders(compiler, rawContext) {
386
386
  };
387
387
  };
388
388
  loaderContext.getLogger = function getLogger(name) {
389
- return compiler.compilation.getLogger([name, resource].filter(Boolean).join("|"));
389
+ return compiler._lastCompilation.getLogger([name, resource].filter(Boolean).join("|"));
390
390
  };
391
391
  loaderContext.rootContext = compiler.context;
392
392
  loaderContext.emitError = function emitError(error) {
393
393
  const title = "Module Error";
394
394
  const message = error instanceof Error ? (0, util_1.concatErrorMsgAndStack)(error) : error;
395
- compiler.compilation.pushDiagnostic("error", title, `${message}\n(from: ${(0, util_1.stringifyLoaderObject)(loaderContext.loaders[loaderContext.loaderIndex])})`);
395
+ compiler._lastCompilation.__internal__pushDiagnostic("error", title, `${message}\n(from: ${(0, util_1.stringifyLoaderObject)(loaderContext.loaders[loaderContext.loaderIndex])})`);
396
396
  };
397
397
  loaderContext.emitWarning = function emitWarning(warning) {
398
398
  const title = "Module Warning";
399
399
  const message = warning instanceof Error ? (0, util_1.concatErrorMsgAndStack)(warning) : warning;
400
- compiler.compilation.pushDiagnostic("warning", title, `${message}\n(from: ${(0, util_1.stringifyLoaderObject)(loaderContext.loaders[loaderContext.loaderIndex])})`);
400
+ compiler._lastCompilation.__internal__pushDiagnostic("warning", title, `${message}\n(from: ${(0, util_1.stringifyLoaderObject)(loaderContext.loaders[loaderContext.loaderIndex])})`);
401
401
  };
402
402
  loaderContext.__internal__pushNativeDiagnostics =
403
403
  function __internal__pushNativeDiagnostics(diagnostics) {
404
- compiler.compilation.__internal__pushNativeDiagnostics(diagnostics);
404
+ compiler._lastCompilation.__internal__pushNativeDiagnostics(diagnostics);
405
405
  };
406
406
  loaderContext.emitFile = function emitFile(name, content, sourceMap, assetInfo) {
407
407
  let source;
@@ -425,7 +425,7 @@ async function runLoaders(compiler, rawContext) {
425
425
  }
426
426
  assetFilenames.push(name),
427
427
  // @ts-expect-error
428
- compiler.compilation.emitAsset(name, source, assetInfo);
428
+ compiler._lastCompilation.emitAsset(name, source, assetInfo);
429
429
  };
430
430
  loaderContext.fs = compiler.inputFileSystem;
431
431
  const getAbsolutify = (0, memoize_1.memoize)(() => identifier_1.absolutify.bindCache(compiler.root));
@@ -444,7 +444,7 @@ async function runLoaders(compiler, rawContext) {
444
444
  : getContextify()(context, request);
445
445
  },
446
446
  createHash: type => {
447
- return (0, createHash_1.createHash)(type || compiler.compilation.outputOptions.hashFunction);
447
+ return (0, createHash_1.createHash)(type || compiler._lastCompilation.outputOptions.hashFunction);
448
448
  }
449
449
  };
450
450
  loaderContext.addBuildDependency = function addBuildDependency(file) {
@@ -477,7 +477,7 @@ async function runLoaders(compiler, rawContext) {
477
477
  return missingDependencies.slice();
478
478
  };
479
479
  loaderContext._compiler = compiler;
480
- loaderContext._compilation = compiler.compilation;
480
+ loaderContext._compilation = compiler._lastCompilation;
481
481
  loaderContext.getOptions = function () {
482
482
  const loader = getCurrentLoader(loaderContext);
483
483
  let options = loader === null || loader === void 0 ? void 0 : loader.options;
@@ -500,7 +500,7 @@ async function runLoaders(compiler, rawContext) {
500
500
  }
501
501
  return options;
502
502
  };
503
- let compilation = compiler.compilation;
503
+ let compilation = compiler._lastCompilation;
504
504
  let step = 0;
505
505
  while (compilation) {
506
506
  NormalModule_1.NormalModule.getCompilationHooks(compilation).loader.call(loaderContext);
@@ -30,7 +30,7 @@ export type LogTypeEnum = (typeof LogType)[keyof typeof LogType];
30
30
  declare const LOG_SYMBOL: unique symbol;
31
31
  declare const TIMERS_SYMBOL: unique symbol;
32
32
  declare const TIMERS_AGGREGATES_SYMBOL: unique symbol;
33
- export type LogFunction = (type: LogTypeEnum, args?: any[]) => void;
33
+ export type LogFunction = (type: LogTypeEnum, args: any[]) => void;
34
34
  export type GetChildLogger = (name: string | (() => string)) => Logger;
35
35
  export declare class Logger {
36
36
  getChildLogger: GetChildLogger;
@@ -100,9 +100,7 @@ module.exports = ({ level = "info", debug = false, console }) => {
100
100
  case LogType.debug:
101
101
  if (!debug)
102
102
  return;
103
- // eslint-disable-next-line node/no-unsupported-features/node-builtins
104
103
  if (typeof console.debug === "function") {
105
- // eslint-disable-next-line node/no-unsupported-features/node-builtins
106
104
  console.debug(...labeledArgs());
107
105
  }
108
106
  else {
@@ -138,9 +136,7 @@ module.exports = ({ level = "info", debug = false, console }) => {
138
136
  if (!debug && loglevel > LogLevel.log)
139
137
  return;
140
138
  if (!debug && loglevel > LogLevel.verbose) {
141
- // eslint-disable-next-line node/no-unsupported-features/node-builtins
142
139
  if (typeof console.groupCollapsed === "function") {
143
- // eslint-disable-next-line node/no-unsupported-features/node-builtins
144
140
  console.groupCollapsed(...labeledArgs());
145
141
  }
146
142
  else {
@@ -152,9 +148,7 @@ module.exports = ({ level = "info", debug = false, console }) => {
152
148
  case LogType.group:
153
149
  if (!debug && loglevel > LogLevel.log)
154
150
  return;
155
- // eslint-disable-next-line node/no-unsupported-features/node-builtins
156
151
  if (typeof console.group === "function") {
157
- // eslint-disable-next-line node/no-unsupported-features/node-builtins
158
152
  console.group(...labeledArgs());
159
153
  }
160
154
  else {
@@ -164,9 +158,7 @@ module.exports = ({ level = "info", debug = false, console }) => {
164
158
  case LogType.groupEnd:
165
159
  if (!debug && loglevel > LogLevel.log)
166
160
  return;
167
- // eslint-disable-next-line node/no-unsupported-features/node-builtins
168
161
  if (typeof console.groupEnd === "function") {
169
- // eslint-disable-next-line node/no-unsupported-features/node-builtins
170
162
  console.groupEnd();
171
163
  }
172
164
  break;
@@ -184,25 +176,19 @@ module.exports = ({ level = "info", debug = false, console }) => {
184
176
  break;
185
177
  }
186
178
  case LogType.profile:
187
- // eslint-disable-next-line node/no-unsupported-features/node-builtins
188
179
  if (typeof console.profile === "function") {
189
- // eslint-disable-next-line node/no-unsupported-features/node-builtins
190
180
  console.profile(...labeledArgs());
191
181
  }
192
182
  break;
193
183
  case LogType.profileEnd:
194
- // eslint-disable-next-line node/no-unsupported-features/node-builtins
195
184
  if (typeof console.profileEnd === "function") {
196
- // eslint-disable-next-line node/no-unsupported-features/node-builtins
197
185
  console.profileEnd(...labeledArgs());
198
186
  }
199
187
  break;
200
188
  case LogType.clear:
201
189
  if (!debug && loglevel > LogLevel.log)
202
190
  return;
203
- // eslint-disable-next-line node/no-unsupported-features/node-builtins
204
191
  if (typeof console.clear === "function") {
205
- // eslint-disable-next-line node/no-unsupported-features/node-builtins
206
192
  console.clear();
207
193
  }
208
194
  break;
@@ -1,5 +1,5 @@
1
- import type { InfrastructureLogging } from "../config";
2
1
  import type { Compiler } from "..";
2
+ import type { InfrastructureLogging } from "../config";
3
3
  export interface NodeEnvironmentPluginOptions {
4
4
  infrastructureLogging: InfrastructureLogging;
5
5
  }
@@ -16,8 +16,8 @@ Object.defineProperty(exports, "__esModule", { value: true });
16
16
  const CachedInputFileSystem_1 = __importDefault(require("enhanced-resolve/lib/CachedInputFileSystem"));
17
17
  const graceful_fs_1 = __importDefault(require("../../compiled/graceful-fs"));
18
18
  const createConsoleLogger_1 = __importDefault(require("../logging/createConsoleLogger"));
19
- const NodeWatchFileSystem_1 = __importDefault(require("./NodeWatchFileSystem"));
20
19
  const nodeConsole_1 = __importDefault(require("./nodeConsole"));
20
+ const NodeWatchFileSystem_1 = __importDefault(require("./NodeWatchFileSystem"));
21
21
  class NodeEnvironmentPlugin {
22
22
  constructor(options) {
23
23
  this.options = options;
@@ -93,18 +93,14 @@ module.exports = ({ colors, appendOnly, stream }) => {
93
93
  else if (currentIndent.length >= 2)
94
94
  currentIndent = currentIndent.slice(0, currentIndent.length - 2);
95
95
  },
96
- // eslint-disable-next-line node/no-unsupported-features/node-builtins
97
96
  // @ts-expect-error
98
97
  profile: console.profile && (name => console.profile(name)),
99
- // eslint-disable-next-line node/no-unsupported-features/node-builtins
100
98
  // @ts-expect-error
101
99
  profileEnd: console.profileEnd && (name => console.profileEnd(name)),
102
100
  clear: !appendOnly &&
103
- // eslint-disable-next-line node/no-unsupported-features/node-builtins
104
101
  console.clear &&
105
102
  (() => {
106
103
  clearStatusMessage();
107
- // eslint-disable-next-line node/no-unsupported-features/node-builtins
108
104
  console.clear();
109
105
  writeStatusMessage();
110
106
  }),
package/dist/rspack.d.ts CHANGED
@@ -1,18 +1,9 @@
1
- /**
2
- * The following code is modified based on
3
- * https://github.com/webpack/webpack/blob/4b4ca3b/lib
4
- *
5
- * MIT Licensed
6
- * Author Tobias Koppers @sokra
7
- * Copyright (c) JS Foundation and other contributors
8
- * https://github.com/webpack/webpack/blob/main/LICENSE
9
- */
10
- import { RspackOptions } from "./config";
1
+ import { Callback } from "tapable";
11
2
  import { Compiler } from "./Compiler";
12
- import { Stats } from "./Stats";
3
+ import { RspackOptions } from "./config";
13
4
  import { MultiCompiler, MultiRspackOptions } from "./MultiCompiler";
14
- import { Callback } from "tapable";
15
5
  import MultiStats from "./MultiStats";
6
+ import { Stats } from "./Stats";
16
7
  declare function createMultiCompiler(options: MultiRspackOptions): MultiCompiler;
17
8
  declare function createCompiler(userOptions: RspackOptions): Compiler;
18
9
  declare function rspack(options: MultiRspackOptions): MultiCompiler;
@@ -21,5 +12,5 @@ declare function rspack(options: MultiRspackOptions | RspackOptions): MultiCompi
21
12
  declare function rspack(options: MultiRspackOptions, callback?: Callback<Error, MultiStats>): null | MultiCompiler;
22
13
  declare function rspack(options: RspackOptions, callback?: Callback<Error, Stats>): null | Compiler;
23
14
  declare function rspack(options: MultiRspackOptions | RspackOptions, callback?: Callback<Error, MultiStats | Stats>): null | MultiCompiler | Compiler;
24
- export { rspack, createCompiler, createMultiCompiler, Stats, MultiStats };
15
+ export { createCompiler, createMultiCompiler, MultiStats, rspack, Stats };
25
16
  export default rspack;
package/dist/rspack.js CHANGED
@@ -3,7 +3,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
3
3
  return (mod && mod.__esModule) ? mod : { "default": mod };
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.MultiStats = exports.Stats = exports.createMultiCompiler = exports.createCompiler = exports.rspack = void 0;
6
+ exports.Stats = exports.rspack = exports.MultiStats = exports.createMultiCompiler = exports.createCompiler = void 0;
7
7
  /**
8
8
  * The following code is modified based on
9
9
  * https://github.com/webpack/webpack/blob/4b4ca3b/lib
@@ -13,17 +13,17 @@ exports.MultiStats = exports.Stats = exports.createMultiCompiler = exports.creat
13
13
  * Copyright (c) JS Foundation and other contributors
14
14
  * https://github.com/webpack/webpack/blob/main/LICENSE
15
15
  */
16
- const config_1 = require("./config");
17
- const Compiler_1 = require("./Compiler");
18
- const Stats_1 = require("./Stats");
19
- Object.defineProperty(exports, "Stats", { enumerable: true, get: function () { return Stats_1.Stats; } });
16
+ const assert_1 = __importDefault(require("assert"));
20
17
  const util_1 = __importDefault(require("util"));
21
- const rspackOptionsApply_1 = require("./rspackOptionsApply");
22
- const NodeEnvironmentPlugin_1 = __importDefault(require("./node/NodeEnvironmentPlugin"));
18
+ const Compiler_1 = require("./Compiler");
19
+ const config_1 = require("./config");
23
20
  const MultiCompiler_1 = require("./MultiCompiler");
24
21
  const MultiStats_1 = __importDefault(require("./MultiStats"));
25
22
  exports.MultiStats = MultiStats_1.default;
26
- const assert_1 = __importDefault(require("assert"));
23
+ const NodeEnvironmentPlugin_1 = __importDefault(require("./node/NodeEnvironmentPlugin"));
24
+ const rspackOptionsApply_1 = require("./rspackOptionsApply");
25
+ const Stats_1 = require("./Stats");
26
+ Object.defineProperty(exports, "Stats", { enumerable: true, get: function () { return Stats_1.Stats; } });
27
27
  const util_2 = require("./util");
28
28
  const validate_1 = require("./util/validate");
29
29
  function createMultiCompiler(options) {
@@ -1,13 +1,4 @@
1
- /**
2
- * The following code is modified based on
3
- * https://github.com/webpack/webpack/blob/4b4ca3bb53f36a5b8fc6bc1bd976ed7af161bd80/lib/OptionsApply.js
4
- *
5
- * MIT Licensed
6
- * Author Tobias Koppers @sokra
7
- * Copyright (c) JS Foundation and other contributors
8
- * https://github.com/webpack/webpack/blob/main/LICENSE
9
- */
10
- import { RspackOptionsNormalized, Compiler } from ".";
1
+ import { Compiler, RspackOptionsNormalized } from ".";
11
2
  export declare class RspackOptionsApply {
12
3
  constructor();
13
4
  process(options: RspackOptionsNormalized, compiler: Compiler): void;
@@ -4,15 +4,24 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
6
  exports.RspackOptionsApply = void 0;
7
+ /**
8
+ * The following code is modified based on
9
+ * https://github.com/webpack/webpack/blob/4b4ca3bb53f36a5b8fc6bc1bd976ed7af161bd80/lib/OptionsApply.js
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 assert_1 = __importDefault(require("assert"));
7
17
  const graceful_fs_1 = __importDefault(require("../compiled/graceful-fs"));
18
+ const builtin_plugin_1 = require("./builtin-plugin");
19
+ const EntryOptionPlugin_1 = __importDefault(require("./lib/EntryOptionPlugin"));
20
+ const ignoreWarningsPlugin_1 = __importDefault(require("./lib/ignoreWarningsPlugin"));
8
21
  const DefaultStatsFactoryPlugin_1 = require("./stats/DefaultStatsFactoryPlugin");
9
22
  const DefaultStatsPrinterPlugin_1 = require("./stats/DefaultStatsPrinterPlugin");
10
- const cleverMerge_1 = require("./util/cleverMerge");
11
- const assert_1 = __importDefault(require("assert"));
12
- const ignoreWarningsPlugin_1 = __importDefault(require("./lib/ignoreWarningsPlugin"));
13
- const EntryOptionPlugin_1 = __importDefault(require("./lib/EntryOptionPlugin"));
14
- const builtin_plugin_1 = require("./builtin-plugin");
15
23
  const assertNotNil_1 = require("./util/assertNotNil");
24
+ const cleverMerge_1 = require("./util/cleverMerge");
16
25
  class RspackOptionsApply {
17
26
  constructor() { }
18
27
  process(options, compiler) {
@@ -1,6 +1,6 @@
1
1
  import { BuiltinPlugin, BuiltinPluginName } from "@rspack/binding";
2
- import { Compiler } from "../Compiler";
3
2
  import { RspackBuiltinPlugin } from "../builtin-plugin/base";
3
+ import { Compiler } from "../Compiler";
4
4
  export type ConsumeSharedPluginOptions = {
5
5
  consumes: Consumes;
6
6
  shareScope?: string;
@@ -4,8 +4,8 @@ exports.ConsumeSharedPlugin = void 0;
4
4
  const binding_1 = require("@rspack/binding");
5
5
  const base_1 = require("../builtin-plugin/base");
6
6
  const options_1 = require("../container/options");
7
- const utils_1 = require("./utils");
8
7
  const ShareRuntimePlugin_1 = require("./ShareRuntimePlugin");
8
+ const utils_1 = require("./utils");
9
9
  class ConsumeSharedPlugin extends base_1.RspackBuiltinPlugin {
10
10
  constructor(options) {
11
11
  var _a;
@@ -33,11 +33,11 @@ exports.DefaultStatsFactoryPlugin = void 0;
33
33
  * Copyright (c) JS Foundation and other contributors
34
34
  * https://github.com/webpack/webpack/blob/main/LICENSE
35
35
  */
36
+ const util = __importStar(require("node:util"));
37
+ const Logger_1 = require("../logging/Logger");
36
38
  const comparators_1 = require("../util/comparators");
37
39
  const identifier_1 = require("../util/identifier");
38
- const util = __importStar(require("node:util"));
39
40
  const statsFactoryUtils_1 = require("./statsFactoryUtils");
40
- const Logger_1 = require("../logging/Logger");
41
41
  const compareIds = comparators_1.compareIds;
42
42
  const GROUP_EXTENSION_REGEXP = /(\.[^.]+?)(?:\?|(?: \+ \d+ modules?)?$)/;
43
43
  const GROUP_PATH_REGEXP = /(.+)[/\\][^/\\]+?(?:\?|(?: \+ \d+ modules?)?$)/;
@@ -7,10 +7,10 @@
7
7
  * Copyright (c) JS Foundation and other contributors
8
8
  * https://github.com/webpack/webpack/blob/main/LICENSE
9
9
  */
10
+ import { JsStats, JsStatsError, JsStatsWarning } from "@rspack/binding";
10
11
  import { HookMap, SyncBailHook, SyncWaterfallHook } from "tapable";
11
- import { GroupConfig } from "../util/smartGrouping";
12
12
  import type { Compilation } from "../Compilation";
13
- import { JsStats, JsStatsError, JsStatsWarning } from "@rspack/binding";
13
+ import { GroupConfig } from "../util/smartGrouping";
14
14
  export type KnownStatsFactoryContext = {
15
15
  type: string;
16
16
  makePathsRelative?: ((arg0: string) => string) | undefined;
@@ -1,15 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.StatsFactory = void 0;
4
- /**
5
- * The following code is modified based on
6
- * https://github.com/webpack/webpack/tree/4b4ca3bb53f36a5b8fc6bc1bd976ed7af161bd80/lib/stats
7
- *
8
- * MIT Licensed
9
- * Author Tobias Koppers @sokra
10
- * Copyright (c) JS Foundation and other contributors
11
- * https://github.com/webpack/webpack/blob/main/LICENSE
12
- */
13
4
  const tapable_1 = require("tapable");
14
5
  const comparators_1 = require("../util/comparators");
15
6
  const smartGrouping_1 = require("../util/smartGrouping");
@@ -1,5 +1,5 @@
1
1
  import { HookMap, SyncBailHook, SyncWaterfallHook } from "tapable";
2
- import type { StatsAsset, StatsChunk, StatsChunkGroup, StatsModule, StatsModuleReason, StatsCompilation } from "./statsFactoryUtils";
2
+ import type { StatsAsset, StatsChunk, StatsChunkGroup, StatsCompilation, StatsModule, StatsModuleReason } from "./statsFactoryUtils";
3
3
  type PrintedElement = {
4
4
  element: string;
5
5
  content: string;
@@ -1,7 +1,7 @@
1
1
  import * as binding from "@rspack/binding";
2
- import { type Comparator } from "../util/comparators";
3
2
  import type { Compilation } from "../Compilation";
4
3
  import type { StatsOptions } from "../config";
4
+ import { type Comparator } from "../util/comparators";
5
5
  import type { StatsFactory, StatsFactoryContext } from "./StatsFactory";
6
6
  export type KnownStatsChunkGroup = binding.JsStatsChunkGroup;
7
7
  export type KnownStatsChunk = binding.JsStatsChunk;
@@ -16,5 +16,5 @@ export declare const compareIds: (a: string | number, b: string | number) => -1
16
16
  export declare const compareChunksById: (a: Chunk, b: Chunk) => -1 | 0 | 1;
17
17
  export declare const compareChunkGroupsByIndex: (a: ChunkGroup, b: ChunkGroup) => -1 | 0 | 1;
18
18
  export declare const compareSelect: <T, R>(getter: Selector<T, R>, comparator: Comparator) => Comparator;
19
- export declare const compareNumbers: (a: number, b: number) => 1 | -1 | 0;
19
+ export declare const compareNumbers: (a: number, b: number) => 0 | 1 | -1;
20
20
  export {};
package/dist/util/fs.d.ts CHANGED
@@ -1,3 +1,14 @@
1
+ /**
2
+ * The following code is modified based on
3
+ * https://github.com/webpack/webpack/blob/4b4ca3b/lib/util/fs.js
4
+ *
5
+ * MIT Licensed
6
+ * Author Tobias Koppers @sokra
7
+ * Copyright (c) JS Foundation and other contributors
8
+ * https://github.com/webpack/webpack/blob/main/LICENSE
9
+ */
10
+ /// <reference types="node" />
11
+ /// <reference types="node" />
1
12
  import { WatchOptions } from "../config";
2
13
  export interface Watcher {
3
14
  close(): void;
@@ -14,6 +25,58 @@ export interface WatcherInfo {
14
25
  fileTimeInfoEntries: Map<string, FileSystemInfoEntry | "ignore">;
15
26
  contextTimeInfoEntries: Map<string, FileSystemInfoEntry | "ignore">;
16
27
  }
28
+ interface IDirent {
29
+ isFile: () => boolean;
30
+ isDirectory: () => boolean;
31
+ isBlockDevice: () => boolean;
32
+ isCharacterDevice: () => boolean;
33
+ isSymbolicLink: () => boolean;
34
+ isFIFO: () => boolean;
35
+ isSocket: () => boolean;
36
+ name: string | Buffer;
37
+ }
38
+ interface IStats {
39
+ isFile: () => boolean;
40
+ isDirectory: () => boolean;
41
+ isBlockDevice: () => boolean;
42
+ isCharacterDevice: () => boolean;
43
+ isSymbolicLink: () => boolean;
44
+ isFIFO: () => boolean;
45
+ isSocket: () => boolean;
46
+ dev: number | bigint;
47
+ ino: number | bigint;
48
+ mode: number | bigint;
49
+ nlink: number | bigint;
50
+ uid: number | bigint;
51
+ gid: number | bigint;
52
+ rdev: number | bigint;
53
+ size: number | bigint;
54
+ blksize: number | bigint;
55
+ blocks: number | bigint;
56
+ atimeMs: number | bigint;
57
+ mtimeMs: number | bigint;
58
+ ctimeMs: number | bigint;
59
+ birthtimeMs: number | bigint;
60
+ atime: Date;
61
+ mtime: Date;
62
+ ctime: Date;
63
+ birthtime: Date;
64
+ }
65
+ export interface OutputFileSystem {
66
+ writeFile: (arg0: string, arg1: string | Buffer, arg2: (arg0?: null | NodeJS.ErrnoException) => void) => void;
67
+ mkdir: (arg0: string, arg1: (arg0?: null | NodeJS.ErrnoException) => void) => void;
68
+ readdir: (arg0: string, arg1: (arg0?: null | NodeJS.ErrnoException, arg1?: (string | Buffer)[] | IDirent[]) => void) => void;
69
+ rmdir: (arg0: string, arg1: (arg0?: null | NodeJS.ErrnoException) => void) => void;
70
+ unlink: (arg0: string, arg1: (arg0?: null | NodeJS.ErrnoException) => void) => void;
71
+ stat: (arg0: string, arg1: (arg0?: null | NodeJS.ErrnoException, arg1?: IStats) => void) => void;
72
+ lstat?: (arg0: string, arg1: (arg0?: null | NodeJS.ErrnoException, arg1?: IStats) => void) => void;
73
+ readFile: (arg0: string, arg1: (arg0?: null | NodeJS.ErrnoException, arg1?: string | Buffer) => void) => void;
74
+ join?: (arg0: string, arg1: string) => string;
75
+ relative?: (arg0: string, arg1: string) => string;
76
+ dirname?: (arg0: string) => string;
77
+ }
78
+ export declare function rmrf(fs: OutputFileSystem, p: string, callback: (err?: Error | null) => void): void;
79
+ export declare const mkdirp: (fs: OutputFileSystem, p: string, callback: (error?: Error) => void) => void;
17
80
  export interface FileSystemInfoEntry {
18
81
  safeTime: number;
19
82
  timestamp?: number;
@@ -21,3 +84,4 @@ export interface FileSystemInfoEntry {
21
84
  export interface WatchFileSystem {
22
85
  watch(files: Iterable<string>, directories: Iterable<string>, missing: Iterable<string>, startTime: number, options: WatchOptions, callback: (error: Error | null, fileTimeInfoEntries: Map<string, FileSystemInfoEntry | "ignore">, contextTimeInfoEntries: Map<string, FileSystemInfoEntry | "ignore">, changedFiles: Set<string>, removedFiles: Set<string>) => void, callbackUndelayed: (fileName: string, changeTime: number) => void): Watcher;
23
86
  }
87
+ export {};
package/dist/util/fs.js CHANGED
@@ -1,2 +1,124 @@
1
1
  "use strict";
2
+ /**
3
+ * The following code is modified based on
4
+ * https://github.com/webpack/webpack/blob/4b4ca3b/lib/util/fs.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
+ };
2
14
  Object.defineProperty(exports, "__esModule", { value: true });
15
+ exports.mkdirp = exports.rmrf = void 0;
16
+ const assert_1 = __importDefault(require("assert"));
17
+ const path_1 = __importDefault(require("path"));
18
+ function rmrf(fs, p, callback) {
19
+ fs.stat(p, (err, stats) => {
20
+ if (err) {
21
+ if (err.code === "ENOENT") {
22
+ return callback();
23
+ }
24
+ return callback(err);
25
+ }
26
+ if (stats.isDirectory()) {
27
+ fs.readdir(p, (err, files) => {
28
+ if (err) {
29
+ return callback(err);
30
+ }
31
+ let count = files.length;
32
+ if (count === 0) {
33
+ fs.rmdir(p, callback);
34
+ }
35
+ else {
36
+ files.forEach(file => {
37
+ (0, assert_1.default)(typeof file === "string");
38
+ const fullPath = join(fs, p, file);
39
+ rmrf(fs, fullPath, err => {
40
+ if (err) {
41
+ return callback(err);
42
+ }
43
+ count--;
44
+ if (count === 0) {
45
+ fs.rmdir(p, callback);
46
+ }
47
+ });
48
+ });
49
+ }
50
+ });
51
+ }
52
+ else {
53
+ fs.unlink(p, callback);
54
+ }
55
+ });
56
+ }
57
+ exports.rmrf = rmrf;
58
+ const join = (fs, rootPath, filename) => {
59
+ if (fs && fs.join) {
60
+ return fs.join(rootPath, filename);
61
+ }
62
+ else if (path_1.default.posix.isAbsolute(rootPath)) {
63
+ return path_1.default.posix.join(rootPath, filename);
64
+ }
65
+ else if (path_1.default.win32.isAbsolute(rootPath)) {
66
+ return path_1.default.win32.join(rootPath, filename);
67
+ }
68
+ else {
69
+ throw new Error(`${rootPath} is neither a posix nor a windows path, and there is no 'join' method defined in the file system`);
70
+ }
71
+ };
72
+ const dirname = (fs, absPath) => {
73
+ if (fs && fs.dirname) {
74
+ return fs.dirname(absPath);
75
+ }
76
+ else if (path_1.default.posix.isAbsolute(absPath)) {
77
+ return path_1.default.posix.dirname(absPath);
78
+ }
79
+ else if (path_1.default.win32.isAbsolute(absPath)) {
80
+ return path_1.default.win32.dirname(absPath);
81
+ }
82
+ else {
83
+ throw new Error(`${absPath} is neither a posix nor a windows path, and there is no 'dirname' method defined in the file system`);
84
+ }
85
+ };
86
+ const mkdirp = (fs, p, callback) => {
87
+ fs.mkdir(p, err => {
88
+ if (err) {
89
+ if (err.code === "ENOENT") {
90
+ const dir = dirname(fs, p);
91
+ if (dir === p) {
92
+ callback(err);
93
+ return;
94
+ }
95
+ (0, exports.mkdirp)(fs, dir, err => {
96
+ if (err) {
97
+ callback(err);
98
+ return;
99
+ }
100
+ fs.mkdir(p, err => {
101
+ if (err) {
102
+ if (err.code === "EEXIST") {
103
+ callback();
104
+ return;
105
+ }
106
+ callback(err);
107
+ return;
108
+ }
109
+ callback();
110
+ });
111
+ });
112
+ return;
113
+ }
114
+ else if (err.code === "EEXIST") {
115
+ callback();
116
+ return;
117
+ }
118
+ callback(err);
119
+ return;
120
+ }
121
+ callback();
122
+ });
123
+ };
124
+ exports.mkdirp = mkdirp;
@@ -11,7 +11,7 @@ export declare const toObject: (input: string | Buffer | object) => object;
11
11
  export declare function serializeObject(map: string | object | undefined | null): Buffer | undefined;
12
12
  export declare function isPromiseLike(value: unknown): value is Promise<any>;
13
13
  export declare function isJsStatsError(err: any): err is JsStatsError;
14
- export declare function concatErrorMsgAndStack(err: Error | JsStatsError): string;
14
+ export declare function concatErrorMsgAndStack(err: Error | JsStatsError | string): string;
15
15
  export declare function indent(str: string, prefix: string): string;
16
16
  export declare function stringifyLoaderObject(o: LoaderObject): string;
17
17
  export declare function asArray<T>(item: T[]): T[];
@@ -19,3 +19,4 @@ export declare function asArray<T>(item: readonly T[]): readonly T[];
19
19
  export declare function asArray<T>(item: T): T[];
20
20
  export declare function toJsAssetInfo(info?: AssetInfo): JsAssetInfo;
21
21
  export declare const deprecatedWarn: (content: string, enable?: boolean) => void;
22
+ export declare const unsupported: (name: string, issue?: string) => never;