@rspack/core 1.0.0-alpha.2 → 1.0.0-alpha.4

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 (166) hide show
  1. package/compiled/browserslist/index.js +17 -17
  2. package/compiled/enhanced-resolve/index.js +107 -107
  3. package/compiled/graceful-fs/index.js +8 -8
  4. package/compiled/json-parse-even-better-errors/index.js +2 -2
  5. package/compiled/neo-async/index.js +2 -2
  6. package/compiled/watchpack/index.js +15 -15
  7. package/compiled/webpack-sources/index.js +76 -76
  8. package/compiled/zod/index.js +30 -30
  9. package/compiled/zod-validation-error/index.js +6 -6
  10. package/dist/ChunkGraph.d.ts +1 -1
  11. package/dist/Compilation.d.ts +9 -9
  12. package/dist/Compilation.js +27 -24
  13. package/dist/Compiler.d.ts +6 -6
  14. package/dist/Compiler.js +5 -6
  15. package/dist/ContextModuleFactory.d.ts +1 -1
  16. package/dist/ErrorHelpers.d.ts +16 -7
  17. package/dist/ErrorHelpers.js +34 -33
  18. package/dist/ExecuteModulePlugin.js +1 -1
  19. package/dist/FileSystem.d.ts +2 -2
  20. package/dist/Module.d.ts +5 -5
  21. package/dist/Module.js +3 -6
  22. package/dist/MultiCompiler.d.ts +3 -3
  23. package/dist/MultiCompiler.js +1 -1
  24. package/dist/MultiStats.d.ts +2 -2
  25. package/dist/MultiWatching.d.ts +2 -2
  26. package/dist/NormalModule.d.ts +1 -1
  27. package/dist/NormalModuleFactory.d.ts +1 -1
  28. package/dist/Resolver.d.ts +19 -0
  29. package/dist/Resolver.js +39 -0
  30. package/dist/ResolverFactory.d.ts +12 -46
  31. package/dist/ResolverFactory.js +55 -120
  32. package/dist/RspackError.d.ts +1 -1
  33. package/dist/RuntimeGlobals.d.ts +1 -1
  34. package/dist/RuntimeGlobals.js +3 -3
  35. package/dist/Stats.d.ts +2 -2
  36. package/dist/Stats.js +4 -4
  37. package/dist/Template.js +2 -2
  38. package/dist/Watching.d.ts +3 -3
  39. package/dist/builtin-loader/swc/index.d.ts +0 -2
  40. package/dist/builtin-loader/swc/index.js +1 -3
  41. package/dist/builtin-loader/swc/pluginImport.d.ts +17 -1
  42. package/dist/builtin-loader/swc/react.d.ts +11 -1
  43. package/dist/builtin-plugin/APIPlugin.d.ts +3 -3
  44. package/dist/builtin-plugin/ArrayPushCallbackChunkFormatPlugin.d.ts +3 -3
  45. package/dist/builtin-plugin/AssetModulesPlugin.d.ts +3 -3
  46. package/dist/builtin-plugin/AsyncWebAssemblyModulesPlugin.d.ts +3 -3
  47. package/dist/builtin-plugin/BannerPlugin.d.ts +25 -4
  48. package/dist/builtin-plugin/BundlerInfoRspackPlugin.d.ts +4 -4
  49. package/dist/builtin-plugin/ChunkPrefetchPreloadPlugin.d.ts +3 -3
  50. package/dist/builtin-plugin/CommonJsChunkFormatPlugin.d.ts +3 -3
  51. package/dist/builtin-plugin/CopyRspackPlugin.d.ts +4 -4
  52. package/dist/builtin-plugin/CssModulesPlugin.d.ts +3 -3
  53. package/dist/builtin-plugin/DataUriPlugin.d.ts +3 -3
  54. package/dist/builtin-plugin/DefinePlugin.d.ts +10 -4
  55. package/dist/builtin-plugin/DefinePlugin.js +42 -8
  56. package/dist/builtin-plugin/DeterministicChunkIdsPlugin.d.ts +3 -3
  57. package/dist/builtin-plugin/DeterministicModuleIdsPlugin.d.ts +3 -3
  58. package/dist/builtin-plugin/DynamicEntryPlugin.d.ts +5 -5
  59. package/dist/builtin-plugin/ElectronTargetPlugin.d.ts +3 -3
  60. package/dist/builtin-plugin/EnableChunkLoadingPlugin.d.ts +3 -3
  61. package/dist/builtin-plugin/EnableLibraryPlugin.d.ts +2 -2
  62. package/dist/builtin-plugin/EnableWasmLoadingPlugin.d.ts +3 -3
  63. package/dist/builtin-plugin/EnsureChunkConditionsPlugin.d.ts +3 -3
  64. package/dist/builtin-plugin/EntryPlugin.d.ts +5 -5
  65. package/dist/builtin-plugin/EntryPlugin.js +1 -1
  66. package/dist/builtin-plugin/EvalDevToolModulePlugin.d.ts +4 -4
  67. package/dist/builtin-plugin/EvalSourceMapDevToolPlugin.d.ts +5 -5
  68. package/dist/builtin-plugin/ExternalsPlugin.d.ts +22 -6
  69. package/dist/builtin-plugin/FetchCompileAsyncWasmPlugin.d.ts +3 -3
  70. package/dist/builtin-plugin/FileUriPlugin.d.ts +3 -3
  71. package/dist/builtin-plugin/FlagDependencyExportsPlugin.d.ts +3 -3
  72. package/dist/builtin-plugin/FlagDependencyUsagePlugin.d.ts +3 -3
  73. package/dist/builtin-plugin/HotModuleReplacementPlugin.d.ts +2 -2
  74. package/dist/builtin-plugin/HtmlRspackPlugin.d.ts +19 -4
  75. package/dist/builtin-plugin/HttpExternalsRspackPlugin.d.ts +4 -4
  76. package/dist/builtin-plugin/IgnorePlugin.d.ts +4 -4
  77. package/dist/builtin-plugin/InferAsyncModulesPlugin.d.ts +3 -3
  78. package/dist/builtin-plugin/JavascriptModulesPlugin.d.ts +2 -2
  79. package/dist/builtin-plugin/JsLoaderRspackPlugin.d.ts +4 -4
  80. package/dist/builtin-plugin/JsonModulesPlugin.d.ts +3 -3
  81. package/dist/builtin-plugin/LightningCssMiminizerRspackPlugin.d.ts +4 -4
  82. package/dist/builtin-plugin/LimitChunkCountPlugin.d.ts +4 -4
  83. package/dist/builtin-plugin/MangleExportsPlugin.d.ts +3 -3
  84. package/dist/builtin-plugin/MergeDuplicateChunksPlugin.d.ts +3 -3
  85. package/dist/builtin-plugin/ModuleChunkFormatPlugin.d.ts +3 -3
  86. package/dist/builtin-plugin/ModuleConcatenationPlugin.d.ts +3 -3
  87. package/dist/builtin-plugin/NamedChunkIdsPlugin.d.ts +3 -3
  88. package/dist/builtin-plugin/NamedModuleIdsPlugin.d.ts +3 -3
  89. package/dist/builtin-plugin/NaturalChunkIdsPlugin.d.ts +3 -3
  90. package/dist/builtin-plugin/NaturalModuleIdsPlugin.d.ts +3 -3
  91. package/dist/builtin-plugin/NodeTargetPlugin.d.ts +3 -3
  92. package/dist/builtin-plugin/ProgressPlugin.d.ts +4 -4
  93. package/dist/builtin-plugin/ProvidePlugin.d.ts +3 -3
  94. package/dist/builtin-plugin/RealContentHashPlugin.d.ts +3 -3
  95. package/dist/builtin-plugin/RemoveEmptyChunksPlugin.d.ts +3 -3
  96. package/dist/builtin-plugin/RuntimeChunkPlugin.d.ts +4 -4
  97. package/dist/builtin-plugin/RuntimePlugin.d.ts +3 -3
  98. package/dist/builtin-plugin/SideEffectsFlagPlugin.d.ts +3 -3
  99. package/dist/builtin-plugin/SizeLimitsPlugin.d.ts +9 -4
  100. package/dist/builtin-plugin/SourceMapDevToolPlugin.d.ts +4 -4
  101. package/dist/builtin-plugin/SplitChunksPlugin.d.ts +3 -3
  102. package/dist/builtin-plugin/SwcCssMinimizerPlugin.d.ts +12 -4
  103. package/dist/builtin-plugin/SwcCssMinimizerPlugin.js +7 -1
  104. package/dist/builtin-plugin/SwcJsMinimizerPlugin.d.ts +4 -4
  105. package/dist/builtin-plugin/SwcJsMinimizerPlugin.js +2 -2
  106. package/dist/builtin-plugin/WarnCaseSensitiveModulesPlugin.d.ts +3 -3
  107. package/dist/builtin-plugin/WebWorkerTemplatePlugin.d.ts +3 -3
  108. package/dist/builtin-plugin/WorkerPlugin.d.ts +3 -3
  109. package/dist/builtin-plugin/WorkerPlugin.js +5 -1
  110. package/dist/builtin-plugin/base.d.ts +6 -6
  111. package/dist/builtin-plugin/base.js +4 -4
  112. package/dist/builtin-plugin/css-extract/index.d.ts +1 -1
  113. package/dist/builtin-plugin/css-extract/loader.js +15 -5
  114. package/dist/builtin-plugin/css-extract/utils.d.ts +1 -1
  115. package/dist/builtin-plugin/index.d.ts +1 -7
  116. package/dist/builtin-plugin/index.js +3 -17
  117. package/dist/builtin-plugin/lazy-compilation/lazyCompilation.d.ts +11 -17
  118. package/dist/builtin-plugin/lazy-compilation/plugin.d.ts +2 -2
  119. package/dist/config/adapter.d.ts +5 -4
  120. package/dist/config/adapter.js +23 -11
  121. package/dist/config/adapterRuleUse.d.ts +7 -7
  122. package/dist/config/adapterRuleUse.js +1 -1
  123. package/dist/config/browserslistTargetHandler.js +1 -1
  124. package/dist/config/defaults.d.ts +1 -1
  125. package/dist/config/defaults.js +4 -3
  126. package/dist/config/zod.d.ts +491 -384
  127. package/dist/config/zod.js +44 -42
  128. package/dist/container/ContainerPlugin.d.ts +3 -3
  129. package/dist/container/ContainerReferencePlugin.d.ts +4 -4
  130. package/dist/container/ModuleFederationPlugin.d.ts +2 -2
  131. package/dist/container/ModuleFederationPlugin.js +2 -2
  132. package/dist/container/ModuleFederationPluginV1.d.ts +5 -5
  133. package/dist/container/ModuleFederationRuntimePlugin.d.ts +3 -3
  134. package/dist/container/default.runtime.js +1 -1
  135. package/dist/lib/EntryOptionPlugin.d.ts +2 -2
  136. package/dist/lib/NormalModuleReplacementPlugin.d.ts +2 -2
  137. package/dist/loader-runner/index.d.ts +2 -2
  138. package/dist/loader-runner/index.js +38 -51
  139. package/dist/loader-runner/loadLoader.js +1 -1
  140. package/dist/logging/runtime.js +1 -1
  141. package/dist/node/NodeTemplatePlugin.d.ts +1 -1
  142. package/dist/node/NodeWatchFileSystem.d.ts +1 -1
  143. package/dist/rspack.d.ts +3 -3
  144. package/dist/rspack.js +1 -1
  145. package/dist/rspackOptionsApply.d.ts +1 -1
  146. package/dist/rspackOptionsApply.js +1 -19
  147. package/dist/sharing/ConsumeSharedPlugin.d.ts +2 -2
  148. package/dist/sharing/ConsumeSharedPlugin.js +1 -1
  149. package/dist/sharing/ProvideSharedPlugin.d.ts +2 -2
  150. package/dist/sharing/SharePlugin.d.ts +1 -1
  151. package/dist/sharing/ShareRuntimePlugin.d.ts +2 -2
  152. package/dist/stats/DefaultStatsFactoryPlugin.js +246 -46
  153. package/dist/stats/DefaultStatsPresetPlugin.js +17 -17
  154. package/dist/stats/DefaultStatsPrinterPlugin.js +1 -1
  155. package/dist/stats/StatsFactory.d.ts +2 -2
  156. package/dist/stats/statsFactoryUtils.d.ts +16 -1
  157. package/dist/util/SplitChunkSize.d.ts +1 -1
  158. package/dist/util/bindingVersionCheck.js +1 -1
  159. package/dist/util/comparators.d.ts +1 -1
  160. package/dist/util/fs.d.ts +1 -1
  161. package/dist/util/identifier.d.ts +65 -62
  162. package/dist/util/identifier.js +30 -55
  163. package/dist/util/index.d.ts +1 -1
  164. package/dist/util/index.js +4 -2
  165. package/dist/util/validate.d.ts +1 -1
  166. package/package.json +7 -34
package/dist/Module.js CHANGED
@@ -10,7 +10,7 @@ var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (
10
10
  if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
11
11
  return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
12
12
  };
13
- var _Module_inner, _Module_originalSource, _CodeGenerationResult_inner, _CodeGenerationResults_inner;
13
+ var _Module_inner, _Module_originalSource, _CodeGenerationResult_inner;
14
14
  Object.defineProperty(exports, "__esModule", { value: true });
15
15
  exports.CodeGenerationResults = exports.CodeGenerationResult = exports.Module = void 0;
16
16
  const source_1 = require("./util/source");
@@ -22,6 +22,7 @@ class Module {
22
22
  _Module_inner.set(this, void 0);
23
23
  _Module_originalSource.set(this, void 0);
24
24
  __classPrivateFieldSet(this, _Module_inner, module, "f");
25
+ this.type = module.type;
25
26
  this.context = module.context;
26
27
  this.resource = module.resource;
27
28
  this.request = module.request;
@@ -69,10 +70,6 @@ class CodeGenerationResult {
69
70
  exports.CodeGenerationResult = CodeGenerationResult;
70
71
  _CodeGenerationResult_inner = new WeakMap();
71
72
  class CodeGenerationResults {
72
- constructor(result) {
73
- _CodeGenerationResults_inner.set(this, void 0);
74
- __classPrivateFieldSet(this, _CodeGenerationResults_inner, result, "f");
75
- }
73
+ constructor(_result) { }
76
74
  }
77
75
  exports.CodeGenerationResults = CodeGenerationResults;
78
- _CodeGenerationResults_inner = new WeakMap();
@@ -8,11 +8,11 @@
8
8
  * https://github.com/webpack/webpack/blob/main/LICENSE
9
9
  */
10
10
  import * as liteTapable from "@rspack/lite-tapable";
11
- import { Compiler, RspackOptions } from ".";
11
+ import type { Compiler, RspackOptions } from ".";
12
12
  import MultiStats from "./MultiStats";
13
13
  import MultiWatching from "./MultiWatching";
14
- import { WatchOptions } from "./config";
15
- import { WatchFileSystem } from "./util/fs";
14
+ import type { WatchOptions } from "./config";
15
+ import type { WatchFileSystem } from "./util/fs";
16
16
  export interface MultiCompilerOptions {
17
17
  /**
18
18
  * how many Compilers are allows to run at the same time in parallel
@@ -67,7 +67,7 @@ class MultiCompiler {
67
67
  };
68
68
  this.compilers = compilers;
69
69
  this._options = {
70
- parallelism: options?.parallelism || Infinity
70
+ parallelism: options?.parallelism || Number.POSITIVE_INFINITY
71
71
  };
72
72
  this.dependencies = new WeakMap();
73
73
  this.running = false;
@@ -7,8 +7,8 @@
7
7
  * Copyright (c) JS Foundation and other contributors
8
8
  * https://github.com/webpack/webpack/blob/main/LICENSE
9
9
  */
10
- import { Stats } from "./Stats";
11
- import { StatsCompilation } from "./stats/statsFactoryUtils";
10
+ import type { Stats } from "./Stats";
11
+ import type { StatsCompilation } from "./stats/statsFactoryUtils";
12
12
  export default class MultiStats {
13
13
  #private;
14
14
  stats: Stats[];
@@ -7,8 +7,8 @@
7
7
  * Copyright (c) JS Foundation and other contributors
8
8
  * https://github.com/webpack/webpack/blob/main/LICENSE
9
9
  */
10
- import { MultiCompiler } from "./MultiCompiler";
11
- import { Watching } from "./Watching";
10
+ import type { MultiCompiler } from "./MultiCompiler";
11
+ import type { Watching } from "./Watching";
12
12
  declare class MultiWatching {
13
13
  watchings: Watching[];
14
14
  compiler: MultiCompiler;
@@ -1,7 +1,7 @@
1
1
  /// <reference types="node" />
2
2
  import * as liteTapable from "@rspack/lite-tapable";
3
3
  import { Compilation } from "./Compilation";
4
- import { LoaderContext } from "./config";
4
+ import type { LoaderContext } from "./config";
5
5
  export declare class NormalModule {
6
6
  static getCompilationHooks(compilation: Compilation): {
7
7
  loader: liteTapable.SyncHook<[LoaderContext<{}>], void, {
@@ -1,6 +1,6 @@
1
1
  import type * as binding from "@rspack/binding";
2
2
  import * as liteTapable from "@rspack/lite-tapable";
3
- import { ResolveData, ResourceDataWithData } from "./Module";
3
+ import type { ResolveData, ResourceDataWithData } from "./Module";
4
4
  export type NormalModuleCreateData = binding.JsNormalModuleFactoryCreateModuleArgs & {
5
5
  settings: {};
6
6
  };
@@ -0,0 +1,19 @@
1
+ import type * as binding from "@rspack/binding";
2
+ import { type Resolve } from "./config";
3
+ interface ResolveContext {
4
+ }
5
+ type ErrorWithDetail = Error & {
6
+ details?: string;
7
+ };
8
+ type ResolveOptionsWithDependencyType = Resolve & {
9
+ dependencyCategory?: string;
10
+ resolveToContext?: boolean;
11
+ };
12
+ export declare class Resolver {
13
+ binding: binding.JsResolver;
14
+ constructor(binding: binding.JsResolver);
15
+ resolveSync(context: object, path: string, request: string): string | false;
16
+ resolve(context: object, path: string, request: string, resolveContext: ResolveContext, callback: (err: null | ErrorWithDetail, res?: string | false) => void): void;
17
+ withOptions({ dependencyCategory, resolveToContext, ...resolve }: ResolveOptionsWithDependencyType): Resolver;
18
+ }
19
+ export {};
@@ -0,0 +1,39 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.Resolver = void 0;
4
+ const config_1 = require("./config");
5
+ function isString(value) {
6
+ return typeof value === "string";
7
+ }
8
+ class Resolver {
9
+ constructor(binding) {
10
+ this.binding = binding;
11
+ }
12
+ resolveSync(context, path, request) {
13
+ return this.binding.resolveSync(path, request);
14
+ }
15
+ resolve(context, path, request, resolveContext, callback) {
16
+ try {
17
+ const res = this.binding.resolveSync(path, request);
18
+ callback(null, res);
19
+ }
20
+ catch (err) {
21
+ callback(err);
22
+ }
23
+ }
24
+ withOptions({ dependencyCategory, resolveToContext, ...resolve }) {
25
+ const rawResolve = (0, config_1.getRawResolve)(resolve);
26
+ // TODO: rspack_resolver is unimplemented regex
27
+ if (Array.isArray(rawResolve.restrictions)) {
28
+ rawResolve.restrictions =
29
+ rawResolve.restrictions.filter(isString);
30
+ }
31
+ const binding = this.binding.withOptions({
32
+ dependencyCategory,
33
+ resolveToContext,
34
+ ...rawResolve
35
+ });
36
+ return new Resolver(binding);
37
+ }
38
+ }
39
+ exports.Resolver = Resolver;
@@ -1,48 +1,14 @@
1
- export = ResolverFactory;
2
- declare class ResolverFactory {
3
- hooks: Readonly<{
4
- /** @type {HookMap<SyncWaterfallHook<[ResolveOptionsWithDependencyType]>>} */
5
- resolveOptions: HookMap<SyncWaterfallHook<[ResolveOptionsWithDependencyType]>>;
6
- /** @type {HookMap<SyncHook<[Resolver, ResolveOptions, ResolveOptionsWithDependencyType]>>} */
7
- resolver: HookMap<SyncHook<[Resolver, ResolveOptions, ResolveOptionsWithDependencyType]>>;
8
- }>;
9
- /** @type {Map<string, ResolverCache>} */
10
- cache: Map<string, ResolverCache>;
11
- /**
12
- * @param {string} type type of resolver
13
- * @param {ResolveOptionsWithDependencyType=} resolveOptions options
14
- * @returns {ResolverWithOptions} the resolver
15
- */
16
- get(type: string, resolveOptions?: ResolveOptionsWithDependencyType | undefined): ResolverWithOptions;
17
- /**
18
- * @param {string} type type of resolver
19
- * @param {ResolveOptionsWithDependencyType} resolveOptionsWithDepType options
20
- * @returns {ResolverWithOptions} the resolver
21
- */
22
- _create(type: string, resolveOptionsWithDepType: ResolveOptionsWithDependencyType): ResolverWithOptions;
23
- }
24
- declare namespace ResolverFactory {
25
- export { ResolveOptions, Resolver, WebpackResolveOptions, ResolvePluginInstance, ResolveOptionsWithDependencyType, WithOptions, ResolverWithOptions, ResolverCache };
26
- }
27
- import { HookMap } from "@rspack/lite-tapable";
28
- import { SyncWaterfallHook } from "@rspack/lite-tapable";
29
- type ResolveOptionsWithDependencyType = WebpackResolveOptions & {
30
- dependencyType?: string;
1
+ import * as binding from "@rspack/binding";
2
+ import { Resolver } from "./Resolver";
3
+ import { type Resolve } from "./config";
4
+ type ResolveOptionsWithDependencyType = Resolve & {
5
+ dependencyCategory?: string;
31
6
  resolveToContext?: boolean;
32
7
  };
33
- import { SyncHook } from "@rspack/lite-tapable";
34
- type Resolver = import("../compiled/enhanced-resolve").Resolver;
35
- type ResolveOptions = import("../compiled/enhanced-resolve").ResolveOptions;
36
- type ResolverCache = {
37
- direct: WeakMap<Object, ResolverWithOptions>;
38
- stringified: Map<string, ResolverWithOptions>;
39
- };
40
- type ResolverWithOptions = Resolver & WithOptions;
41
- type WebpackResolveOptions = any;
42
- type ResolvePluginInstance = any;
43
- type WithOptions = {
44
- /**
45
- * create a resolver with additional/different options
46
- */
47
- withOptions: (arg0: Partial<ResolveOptionsWithDependencyType>) => ResolverWithOptions;
48
- };
8
+ export declare class ResolverFactory {
9
+ #private;
10
+ static __to_binding(resolver_factory: ResolverFactory): binding.JsResolverFactory;
11
+ constructor();
12
+ get(type: string, resolveOptions?: ResolveOptionsWithDependencyType): Resolver;
13
+ }
14
+ export {};
@@ -1,126 +1,61 @@
1
- /**
2
- * The following code is modified based on
3
- * https://github.com/webpack/webpack/blob/4b4ca3b/lib/ResolverFactory.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
1
  "use strict";
11
- const Factory = require("../compiled/enhanced-resolve").ResolverFactory;
12
- const { HookMap, SyncHook, SyncWaterfallHook } = require("@rspack/lite-tapable");
13
- const { cachedCleverMerge, removeOperations, resolveByProperty } = require("./util/cleverMerge");
14
- /** @typedef {import("../compiled/enhanced-resolve").ResolveOptions} ResolveOptions */
15
- /** @typedef {import("../compiled/enhanced-resolve").Resolver} Resolver */
16
- // /** @typedef {import("../declarations/WebpackOptions").ResolveOptions} WebpackResolveOptions */
17
- // /** @typedef {import("../declarations/WebpackOptions").ResolvePluginInstance} ResolvePluginInstance */
18
- /** @typedef {any} WebpackResolveOptions */
19
- /** @typedef {any} ResolvePluginInstance */
20
- /** @typedef {WebpackResolveOptions & {dependencyType?: string, resolveToContext?: boolean }} ResolveOptionsWithDependencyType */
21
- /**
22
- * @typedef {Object} WithOptions
23
- * @property {function(Partial<ResolveOptionsWithDependencyType>): ResolverWithOptions} withOptions create a resolver with additional/different options
24
- */
25
- /** @typedef {Resolver & WithOptions} ResolverWithOptions */
26
- // need to be hoisted on module level for caching identity
27
- const EMPTY_RESOLVE_OPTIONS = {};
28
- /**
29
- * @param {ResolveOptionsWithDependencyType} resolveOptionsWithDepType enhanced options
30
- * @returns {ResolveOptions} merged options
31
- */
32
- const convertToResolveOptions = resolveOptionsWithDepType => {
33
- const { dependencyType, plugins, ...remaining } = resolveOptionsWithDepType;
34
- // check type compat
35
- /** @type {Partial<ResolveOptions>} */
36
- const partialOptions = {
37
- ...remaining,
38
- plugins: plugins &&
39
- /** @type {ResolvePluginInstance[]} */ (
40
- // @ts-expect-error
41
- plugins.filter(item => item !== "..."))
42
- };
43
- if (!partialOptions.fileSystem) {
44
- throw new Error("fileSystem is missing in resolveOptions, but it's required for enhanced-resolve");
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
45
7
  }
46
- // These weird types validate that we checked all non-optional properties
47
- const options =
48
- /** @type {Partial<ResolveOptions> & Pick<ResolveOptions, "fileSystem">} */ (partialOptions);
49
- // @ts-expect-error
50
- return removeOperations(resolveByProperty(options, "byDependency", dependencyType));
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || function (mod) {
19
+ if (mod && mod.__esModule) return mod;
20
+ var result = {};
21
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
+ __setModuleDefault(result, mod);
23
+ return result;
51
24
  };
52
- /**
53
- * @typedef {Object} ResolverCache
54
- * @property {WeakMap<Object, ResolverWithOptions>} direct
55
- * @property {Map<string, ResolverWithOptions>} stringified
56
- */
57
- module.exports = class ResolverFactory {
58
- constructor() {
59
- this.hooks = Object.freeze({
60
- /** @type {HookMap<SyncWaterfallHook<[ResolveOptionsWithDependencyType]>>} */
61
- resolveOptions: new HookMap(() => new SyncWaterfallHook(["resolveOptions"])),
62
- /** @type {HookMap<SyncHook<[Resolver, ResolveOptions, ResolveOptionsWithDependencyType]>>} */
63
- resolver: new HookMap(() => new SyncHook(["resolver", "resolveOptions", "userResolveOptions"]))
64
- });
65
- /** @type {Map<string, ResolverCache>} */
66
- this.cache = new Map();
25
+ var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
26
+ if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
27
+ if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
28
+ return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
29
+ };
30
+ var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
31
+ if (kind === "m") throw new TypeError("Private method is not writable");
32
+ if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
33
+ if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it");
34
+ return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
35
+ };
36
+ var _ResolverFactory_binding;
37
+ Object.defineProperty(exports, "__esModule", { value: true });
38
+ exports.ResolverFactory = void 0;
39
+ const binding = __importStar(require("@rspack/binding"));
40
+ const Resolver_1 = require("./Resolver");
41
+ const config_1 = require("./config");
42
+ class ResolverFactory {
43
+ static __to_binding(resolver_factory) {
44
+ return __classPrivateFieldGet(resolver_factory, _ResolverFactory_binding, "f");
67
45
  }
68
- /**
69
- * @param {string} type type of resolver
70
- * @param {ResolveOptionsWithDependencyType=} resolveOptions options
71
- * @returns {ResolverWithOptions} the resolver
72
- */
73
- get(type, resolveOptions = EMPTY_RESOLVE_OPTIONS) {
74
- let typedCaches = this.cache.get(type);
75
- if (!typedCaches) {
76
- typedCaches = {
77
- direct: new WeakMap(),
78
- stringified: new Map()
79
- };
80
- this.cache.set(type, typedCaches);
81
- }
82
- const cachedResolver = typedCaches.direct.get(resolveOptions);
83
- if (cachedResolver) {
84
- return cachedResolver;
85
- }
86
- const ident = JSON.stringify(resolveOptions);
87
- const resolver = typedCaches.stringified.get(ident);
88
- if (resolver) {
89
- typedCaches.direct.set(resolveOptions, resolver);
90
- return resolver;
91
- }
92
- const newResolver = this._create(type, resolveOptions);
93
- typedCaches.direct.set(resolveOptions, newResolver);
94
- typedCaches.stringified.set(ident, newResolver);
95
- return newResolver;
46
+ constructor() {
47
+ _ResolverFactory_binding.set(this, void 0);
48
+ __classPrivateFieldSet(this, _ResolverFactory_binding, new binding.JsResolverFactory(), "f");
96
49
  }
97
- /**
98
- * @param {string} type type of resolver
99
- * @param {ResolveOptionsWithDependencyType} resolveOptionsWithDepType options
100
- * @returns {ResolverWithOptions} the resolver
101
- */
102
- _create(type, resolveOptionsWithDepType) {
103
- /** @type {ResolveOptionsWithDependencyType} */
104
- const originalResolveOptions = { ...resolveOptionsWithDepType };
105
- const resolveOptions = convertToResolveOptions(this.hooks.resolveOptions.for(type).call(resolveOptionsWithDepType));
106
- const resolver = /** @type {ResolverWithOptions} */ (Factory.createResolver(resolveOptions));
107
- if (!resolver) {
108
- throw new Error("No resolver created");
109
- }
110
- /** @type {WeakMap<Partial<ResolveOptionsWithDependencyType>, ResolverWithOptions>} */
111
- const childCache = new WeakMap();
112
- resolver.withOptions = options => {
113
- const cacheEntry = childCache.get(options);
114
- if (cacheEntry !== undefined)
115
- return cacheEntry;
116
- const mergedOptions = cachedCleverMerge(originalResolveOptions, options);
117
- const resolver = this.get(type, mergedOptions);
118
- childCache.set(options, resolver);
119
- return resolver;
120
- };
121
- this.hooks.resolver
122
- .for(type)
123
- .call(resolver, resolveOptions, originalResolveOptions);
124
- return resolver;
50
+ get(type, resolveOptions) {
51
+ const { dependencyCategory, resolveToContext, ...resolve } = resolveOptions || {};
52
+ const binding = __classPrivateFieldGet(this, _ResolverFactory_binding, "f").get(type, {
53
+ ...(0, config_1.getRawResolve)(resolve),
54
+ dependencyCategory,
55
+ resolveToContext
56
+ });
57
+ return new Resolver_1.Resolver(binding);
125
58
  }
126
- };
59
+ }
60
+ exports.ResolverFactory = ResolverFactory;
61
+ _ResolverFactory_binding = new WeakMap();
@@ -1,4 +1,4 @@
1
- import * as binding from "@rspack/binding";
1
+ import type * as binding from "@rspack/binding";
2
2
  export type RspackError = binding.JsRspackError;
3
3
  export declare class JsDiagnostic {
4
4
  static __to_binding(error: Error | RspackError, severity: binding.JsRspackSeverity): binding.JsDiagnostic;
@@ -7,7 +7,7 @@
7
7
  * Copyright (c) JS Foundation and other contributors
8
8
  * https://github.com/webpack/webpack/blob/main/LICENSE
9
9
  */
10
- import { JsRuntimeGlobals } from "@rspack/binding";
10
+ import type { JsRuntimeGlobals } from "@rspack/binding";
11
11
  export declare function __from_binding_runtime_globals(runtimeRequirements: JsRuntimeGlobals): Set<string>;
12
12
  export declare function __to_binding_runtime_globals(runtimeRequirements: Set<string>): JsRuntimeGlobals;
13
13
  export declare const RuntimeGlobals: {
@@ -13,7 +13,7 @@ exports.RuntimeGlobals = exports.__to_binding_runtime_globals = exports.__from_b
13
13
  const REVERSE_RUNTIME_GLOBALS = new Map();
14
14
  function __from_binding_runtime_globals(runtimeRequirements) {
15
15
  const res = new Set();
16
- for (let flag of runtimeRequirements.value) {
16
+ for (const flag of runtimeRequirements.value) {
17
17
  if (flag in exports.RuntimeGlobals) {
18
18
  res.add(exports.RuntimeGlobals[flag]);
19
19
  }
@@ -28,7 +28,7 @@ function __to_binding_runtime_globals(runtimeRequirements) {
28
28
  const res = {
29
29
  value: []
30
30
  };
31
- for (let flag of Array.from(runtimeRequirements)) {
31
+ for (const flag of Array.from(runtimeRequirements)) {
32
32
  const item = REVERSE_RUNTIME_GLOBALS.get(flag);
33
33
  if (typeof item === "string") {
34
34
  res.value.push(item);
@@ -352,6 +352,6 @@ exports.RuntimeGlobals = {
352
352
  */
353
353
  asyncModule: "__webpack_require__.a"
354
354
  };
355
- for (let entry of Object.entries(exports.RuntimeGlobals)) {
355
+ for (const entry of Object.entries(exports.RuntimeGlobals)) {
356
356
  REVERSE_RUNTIME_GLOBALS.set(entry[1], entry[0]);
357
357
  }
package/dist/Stats.d.ts CHANGED
@@ -1,5 +1,5 @@
1
- import { Compilation } from "./Compilation";
2
- import { StatsOptions, StatsValue } from "./config";
1
+ import type { Compilation } from "./Compilation";
2
+ import type { StatsOptions, StatsValue } from "./config";
3
3
  import type { StatsCompilation } from "./stats/statsFactoryUtils";
4
4
  export type { StatsAsset, StatsChunk, StatsCompilation, StatsError, StatsModule, StatsWarnings } from "./stats/statsFactoryUtils";
5
5
  export declare class Stats {
package/dist/Stats.js CHANGED
@@ -102,7 +102,7 @@ function normalizeStatsPreset(options) {
102
102
  else if (!options)
103
103
  return {};
104
104
  else {
105
- let obj = { ...presetToOptions(options.preset), ...options };
105
+ const obj = { ...presetToOptions(options.preset), ...options };
106
106
  delete obj.preset;
107
107
  return obj;
108
108
  }
@@ -118,15 +118,15 @@ function presetToOptions(name) {
118
118
  case "verbose":
119
119
  return {
120
120
  all: true,
121
- modulesSpace: Infinity
121
+ modulesSpace: Number.POSITIVE_INFINITY
122
122
  };
123
123
  case "errors-only":
124
124
  return {
125
125
  all: false,
126
126
  errors: true,
127
127
  errorsCount: true,
128
- logging: "error"
129
- // TODO: moduleTrace: true,
128
+ logging: "error",
129
+ moduleTrace: true
130
130
  };
131
131
  case "errors-warnings":
132
132
  return {
package/dist/Template.js CHANGED
@@ -246,8 +246,8 @@ class Template {
246
246
  * or false if not every module has a number based id
247
247
  */
248
248
  static getModulesArrayBounds(modules) {
249
- let maxId = -Infinity;
250
- let minId = Infinity;
249
+ let maxId = Number.NEGATIVE_INFINITY;
250
+ let minId = Number.POSITIVE_INFINITY;
251
251
  for (const module of modules) {
252
252
  const moduleId = module.id;
253
253
  if (typeof moduleId !== "number")
@@ -1,8 +1,8 @@
1
- import { Callback } from "@rspack/lite-tapable";
1
+ import type { Callback } from "@rspack/lite-tapable";
2
2
  import type { Compiler } from ".";
3
3
  import { Stats } from ".";
4
- import { WatchOptions } from "./config";
5
- import { Watcher } from "./util/fs";
4
+ import type { WatchOptions } from "./config";
5
+ import type { Watcher } from "./util/fs";
6
6
  export declare class Watching {
7
7
  #private;
8
8
  watcher?: Watcher;
@@ -1,5 +1,3 @@
1
1
  export { resolvePluginImport } from "./pluginImport";
2
2
  export type { PluginImportOptions } from "./pluginImport";
3
- export type { ReactOptions } from "./react";
4
- export { resolveReact } from "./react";
5
3
  export type { SwcLoaderEnvConfig, SwcLoaderEsParserConfig, SwcLoaderJscConfig, SwcLoaderModuleConfig, SwcLoaderOptions, SwcLoaderParserConfig, SwcLoaderTransformConfig, SwcLoaderTsParserConfig } from "./types";
@@ -1,7 +1,5 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.resolveReact = exports.resolvePluginImport = void 0;
3
+ exports.resolvePluginImport = void 0;
4
4
  var pluginImport_1 = require("./pluginImport");
5
5
  Object.defineProperty(exports, "resolvePluginImport", { enumerable: true, get: function () { return pluginImport_1.resolvePluginImport; } });
6
- var react_1 = require("./react");
7
- Object.defineProperty(exports, "resolveReact", { enumerable: true, get: function () { return react_1.resolveReact; } });
@@ -1,4 +1,20 @@
1
- import type { RawPluginImportConfig } from "@rspack/binding";
1
+ type RawStyleConfig = {
2
+ styleLibraryDirectory?: string;
3
+ custom?: string;
4
+ css?: string;
5
+ bool?: boolean;
6
+ };
7
+ type RawPluginImportConfig = {
8
+ libraryName: string;
9
+ libraryDirectory?: string;
10
+ customName?: string;
11
+ customStyleName?: string;
12
+ style?: RawStyleConfig;
13
+ camelToDashComponentName?: boolean;
14
+ transformToDefaultImport?: boolean;
15
+ ignoreEsComponent?: Array<string>;
16
+ ignoreStyleComponent?: Array<string>;
17
+ };
2
18
  type PluginImportConfig = {
3
19
  libraryName: string;
4
20
  libraryDirectory?: string;
@@ -1,4 +1,14 @@
1
- import type { RawReactOptions } from "@rspack/binding";
1
+ type RawReactOptions = {
2
+ runtime?: "automatic" | "classic";
3
+ importSource?: string;
4
+ pragma?: string;
5
+ pragmaFrag?: string;
6
+ throwIfNamespace?: boolean;
7
+ development?: boolean;
8
+ useBuiltins?: boolean;
9
+ useSpread?: boolean;
10
+ refresh?: boolean;
11
+ };
2
12
  declare function resolveReact(react: ReactOptions): RawReactOptions;
3
13
  type ReactOptions = RawReactOptions | undefined;
4
14
  export { resolveReact };
@@ -2,9 +2,9 @@ import { BuiltinPluginName } from "@rspack/binding";
2
2
  export declare const APIPlugin: {
3
3
  new (): {
4
4
  name: BuiltinPluginName;
5
- _options: void;
6
- affectedHooks: "make" | "compile" | "emit" | "afterEmit" | "invalid" | "done" | "thisCompilation" | "afterDone" | "compilation" | "normalModuleFactory" | "contextModuleFactory" | "initialize" | "shouldEmit" | "infrastructureLog" | "beforeRun" | "run" | "assetEmitted" | "failed" | "shutdown" | "watchRun" | "watchClose" | "environment" | "afterEnvironment" | "afterPlugins" | "afterResolvers" | "beforeCompile" | "afterCompile" | "finishMake" | "entryOption" | undefined;
7
- raw(): import("@rspack/binding").BuiltinPlugin;
5
+ _args: [];
6
+ affectedHooks: "done" | "compilation" | "failed" | "environment" | "emit" | "make" | "compile" | "afterEmit" | "invalid" | "thisCompilation" | "afterDone" | "normalModuleFactory" | "contextModuleFactory" | "initialize" | "shouldEmit" | "infrastructureLog" | "beforeRun" | "run" | "assetEmitted" | "shutdown" | "watchRun" | "watchClose" | "afterEnvironment" | "afterPlugins" | "afterResolvers" | "beforeCompile" | "afterCompile" | "finishMake" | "entryOption" | undefined;
7
+ raw(compiler: import("../Compiler").Compiler): import("@rspack/binding").BuiltinPlugin;
8
8
  apply(compiler: import("../Compiler").Compiler): void;
9
9
  };
10
10
  };
@@ -2,9 +2,9 @@ import { BuiltinPluginName } from "@rspack/binding";
2
2
  export declare const ArrayPushCallbackChunkFormatPlugin: {
3
3
  new (): {
4
4
  name: BuiltinPluginName;
5
- _options: void;
6
- affectedHooks: "make" | "compile" | "emit" | "afterEmit" | "invalid" | "done" | "thisCompilation" | "afterDone" | "compilation" | "normalModuleFactory" | "contextModuleFactory" | "initialize" | "shouldEmit" | "infrastructureLog" | "beforeRun" | "run" | "assetEmitted" | "failed" | "shutdown" | "watchRun" | "watchClose" | "environment" | "afterEnvironment" | "afterPlugins" | "afterResolvers" | "beforeCompile" | "afterCompile" | "finishMake" | "entryOption" | undefined;
7
- raw(): import("@rspack/binding").BuiltinPlugin;
5
+ _args: [];
6
+ affectedHooks: "done" | "compilation" | "failed" | "environment" | "emit" | "make" | "compile" | "afterEmit" | "invalid" | "thisCompilation" | "afterDone" | "normalModuleFactory" | "contextModuleFactory" | "initialize" | "shouldEmit" | "infrastructureLog" | "beforeRun" | "run" | "assetEmitted" | "shutdown" | "watchRun" | "watchClose" | "afterEnvironment" | "afterPlugins" | "afterResolvers" | "beforeCompile" | "afterCompile" | "finishMake" | "entryOption" | undefined;
7
+ raw(compiler: import("../Compiler").Compiler): import("@rspack/binding").BuiltinPlugin;
8
8
  apply(compiler: import("../Compiler").Compiler): void;
9
9
  };
10
10
  };
@@ -2,9 +2,9 @@ import { BuiltinPluginName } from "@rspack/binding";
2
2
  export declare const AssetModulesPlugin: {
3
3
  new (): {
4
4
  name: BuiltinPluginName;
5
- _options: void;
6
- affectedHooks: "make" | "compile" | "emit" | "afterEmit" | "invalid" | "done" | "thisCompilation" | "afterDone" | "compilation" | "normalModuleFactory" | "contextModuleFactory" | "initialize" | "shouldEmit" | "infrastructureLog" | "beforeRun" | "run" | "assetEmitted" | "failed" | "shutdown" | "watchRun" | "watchClose" | "environment" | "afterEnvironment" | "afterPlugins" | "afterResolvers" | "beforeCompile" | "afterCompile" | "finishMake" | "entryOption" | undefined;
7
- raw(): import("@rspack/binding").BuiltinPlugin;
5
+ _args: [];
6
+ affectedHooks: "done" | "compilation" | "failed" | "environment" | "emit" | "make" | "compile" | "afterEmit" | "invalid" | "thisCompilation" | "afterDone" | "normalModuleFactory" | "contextModuleFactory" | "initialize" | "shouldEmit" | "infrastructureLog" | "beforeRun" | "run" | "assetEmitted" | "shutdown" | "watchRun" | "watchClose" | "afterEnvironment" | "afterPlugins" | "afterResolvers" | "beforeCompile" | "afterCompile" | "finishMake" | "entryOption" | undefined;
7
+ raw(compiler: import("../Compiler").Compiler): import("@rspack/binding").BuiltinPlugin;
8
8
  apply(compiler: import("../Compiler").Compiler): void;
9
9
  };
10
10
  };
@@ -2,9 +2,9 @@ import { BuiltinPluginName } from "@rspack/binding";
2
2
  export declare const AsyncWebAssemblyModulesPlugin: {
3
3
  new (): {
4
4
  name: BuiltinPluginName;
5
- _options: void;
6
- affectedHooks: "make" | "compile" | "emit" | "afterEmit" | "invalid" | "done" | "thisCompilation" | "afterDone" | "compilation" | "normalModuleFactory" | "contextModuleFactory" | "initialize" | "shouldEmit" | "infrastructureLog" | "beforeRun" | "run" | "assetEmitted" | "failed" | "shutdown" | "watchRun" | "watchClose" | "environment" | "afterEnvironment" | "afterPlugins" | "afterResolvers" | "beforeCompile" | "afterCompile" | "finishMake" | "entryOption" | undefined;
7
- raw(): import("@rspack/binding").BuiltinPlugin;
5
+ _args: [];
6
+ affectedHooks: "done" | "compilation" | "failed" | "environment" | "emit" | "make" | "compile" | "afterEmit" | "invalid" | "thisCompilation" | "afterDone" | "normalModuleFactory" | "contextModuleFactory" | "initialize" | "shouldEmit" | "infrastructureLog" | "beforeRun" | "run" | "assetEmitted" | "shutdown" | "watchRun" | "watchClose" | "afterEnvironment" | "afterPlugins" | "afterResolvers" | "beforeCompile" | "afterCompile" | "finishMake" | "entryOption" | undefined;
7
+ raw(compiler: import("../Compiler").Compiler): import("@rspack/binding").BuiltinPlugin;
8
8
  apply(compiler: import("../Compiler").Compiler): void;
9
9
  };
10
10
  };