@rspack/core 0.6.5 → 0.7.0-beta.0-canary-bcf6575-20240516085135

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 (148) hide show
  1. package/dist/Chunk.d.ts +1 -1
  2. package/dist/Chunk.js +1 -1
  3. package/dist/ChunkGroup.d.ts +2 -0
  4. package/dist/ChunkGroup.js +4 -0
  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 +15 -0
  81. package/dist/builtin-plugin/SizeLimitsPlugin.js +9 -0
  82. package/dist/builtin-plugin/SourceMapDevToolPlugin.d.ts +1 -1
  83. package/dist/builtin-plugin/SplitChunksPlugin.d.ts +2 -2
  84. package/dist/builtin-plugin/SplitChunksPlugin.js +4 -4
  85. package/dist/builtin-plugin/SwcCssMinimizerPlugin.d.ts +1 -1
  86. package/dist/builtin-plugin/SwcJsMinimizerPlugin.d.ts +1 -1
  87. package/dist/builtin-plugin/WarnCaseSensitiveModulesPlugin.d.ts +1 -1
  88. package/dist/builtin-plugin/WebWorkerTemplatePlugin.d.ts +1 -1
  89. package/dist/builtin-plugin/WorkerPlugin.d.ts +2 -2
  90. package/dist/builtin-plugin/base.d.ts +1 -1
  91. package/dist/builtin-plugin/css-extract/index.d.ts +5 -4
  92. package/dist/builtin-plugin/css-extract/loader.d.ts +1 -1
  93. package/dist/builtin-plugin/css-extract/loader.js +2 -2
  94. package/dist/builtin-plugin/index.d.ts +44 -43
  95. package/dist/builtin-plugin/index.js +44 -43
  96. package/dist/config/adapter.d.ts +2 -2
  97. package/dist/config/adapter.js +6 -5
  98. package/dist/config/adapterRuleUse.d.ts +2 -1
  99. package/dist/config/adapterRuleUse.js +2 -2
  100. package/dist/config/defaults.js +21 -4
  101. package/dist/config/index.d.ts +2 -2
  102. package/dist/config/index.js +2 -2
  103. package/dist/config/normalization.d.ts +2 -2
  104. package/dist/config/normalization.js +1 -0
  105. package/dist/config/zod.d.ts +317 -189
  106. package/dist/config/zod.js +23 -29
  107. package/dist/container/ContainerPlugin.d.ts +1 -1
  108. package/dist/container/ContainerReferencePlugin.d.ts +1 -1
  109. package/dist/container/ContainerReferencePlugin.js +1 -1
  110. package/dist/container/ModuleFederationPlugin.js +1 -1
  111. package/dist/container/ModuleFederationPluginV1.d.ts +1 -1
  112. package/dist/container/ModuleFederationPluginV1.js +1 -1
  113. package/dist/container/ModuleFederationRuntimePlugin.d.ts +1 -1
  114. package/dist/exports.d.ts +36 -30
  115. package/dist/exports.js +36 -28
  116. package/dist/fileSystem.d.ts +12 -8
  117. package/dist/fileSystem.js +25 -48
  118. package/dist/index.d.ts +1 -1
  119. package/dist/index.js +1 -1
  120. package/dist/lite-tapable/index.d.ts +6 -0
  121. package/dist/lite-tapable/index.js +107 -1
  122. package/dist/loader-runner/index.js +13 -13
  123. package/dist/logging/Logger.d.ts +1 -1
  124. package/dist/logging/createConsoleLogger.js +0 -14
  125. package/dist/node/NodeEnvironmentPlugin.d.ts +1 -1
  126. package/dist/node/NodeEnvironmentPlugin.js +1 -1
  127. package/dist/node/nodeConsole.js +0 -4
  128. package/dist/rspack.d.ts +4 -13
  129. package/dist/rspack.js +8 -8
  130. package/dist/rspackOptionsApply.d.ts +1 -10
  131. package/dist/rspackOptionsApply.js +17 -5
  132. package/dist/sharing/ConsumeSharedPlugin.d.ts +1 -1
  133. package/dist/sharing/ConsumeSharedPlugin.js +1 -1
  134. package/dist/stats/DefaultStatsFactoryPlugin.js +2 -2
  135. package/dist/stats/StatsFactory.d.ts +2 -2
  136. package/dist/stats/StatsFactory.js +0 -9
  137. package/dist/stats/StatsPrinter.d.ts +1 -1
  138. package/dist/stats/statsFactoryUtils.d.ts +1 -1
  139. package/dist/util/comparators.d.ts +1 -1
  140. package/dist/util/fs.d.ts +64 -0
  141. package/dist/util/fs.js +122 -0
  142. package/dist/util/index.d.ts +2 -1
  143. package/dist/util/index.js +16 -11
  144. package/dist/util/source.d.ts +18 -0
  145. package/dist/util/source.js +66 -0
  146. package/package.json +6 -5
  147. package/dist/util/createSource.d.ts +0 -5
  148. package/dist/util/createSource.js +0 -65
package/dist/Chunk.d.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  import { type JsChunk, type JsCompilation } from "@rspack/binding";
2
- import { ChunkGroup } from "./ChunkGroup";
3
2
  import { Compilation } from ".";
3
+ import { ChunkGroup } from "./ChunkGroup";
4
4
  export declare class Chunk {
5
5
  #private;
6
6
  name?: string;
package/dist/Chunk.js CHANGED
@@ -14,9 +14,9 @@ var _Chunk_inner, _Chunk_inner_compilation;
14
14
  Object.defineProperty(exports, "__esModule", { value: true });
15
15
  exports.Chunk = void 0;
16
16
  const binding_1 = require("@rspack/binding");
17
+ const _1 = require(".");
17
18
  const ChunkGroup_1 = require("./ChunkGroup");
18
19
  const comparators_1 = require("./util/comparators");
19
- const _1 = require(".");
20
20
  class Chunk {
21
21
  static __from_binding(chunk, compilation) {
22
22
  if (compilation instanceof _1.Compilation) {
@@ -1,10 +1,12 @@
1
1
  import { type JsChunkGroup, type JsCompilation } from "@rspack/binding";
2
+ import { Chunk } from "./Chunk";
2
3
  export declare class ChunkGroup {
3
4
  #private;
4
5
  static __from_binding(chunk: JsChunkGroup, compilation: JsCompilation): ChunkGroup;
5
6
  protected constructor(inner: JsChunkGroup, compilation: JsCompilation);
6
7
  getFiles(): string[];
7
8
  getParents(): ChunkGroup[];
9
+ get chunks(): Chunk[];
8
10
  get index(): number | undefined;
9
11
  get name(): string | undefined;
10
12
  __internal_inner_ukey(): number;
@@ -14,6 +14,7 @@ var _ChunkGroup_inner, _ChunkGroup_inner_compilation;
14
14
  Object.defineProperty(exports, "__esModule", { value: true });
15
15
  exports.ChunkGroup = void 0;
16
16
  const binding_1 = require("@rspack/binding");
17
+ const Chunk_1 = require("./Chunk");
17
18
  class ChunkGroup {
18
19
  static __from_binding(chunk, compilation) {
19
20
  return new ChunkGroup(chunk, compilation);
@@ -39,6 +40,9 @@ class ChunkGroup {
39
40
  return ChunkGroup.__from_binding(cg, __classPrivateFieldGet(this, _ChunkGroup_inner_compilation, "f"));
40
41
  });
41
42
  }
43
+ get chunks() {
44
+ return __classPrivateFieldGet(this, _ChunkGroup_inner, "f").chunks.map(c => Chunk_1.Chunk.__from_binding(c, __classPrivateFieldGet(this, _ChunkGroup_inner_compilation, "f")));
45
+ }
42
46
  get index() {
43
47
  return __classPrivateFieldGet(this, _ChunkGroup_inner, "f").index;
44
48
  }
@@ -8,24 +8,24 @@
8
8
  * Copyright (c) JS Foundation and other contributors
9
9
  * https://github.com/webpack/webpack/blob/main/LICENSE
10
10
  */
11
+ import type { ExternalObject, JsAssetInfo, JsCompilation, JsModule, JsPathData, JsRuntimeModule, JsStatsError, JsStatsWarning } from "@rspack/binding";
11
12
  import * as tapable from "tapable";
12
13
  import { Source } from "webpack-sources";
13
- import type { ExternalObject, JsAssetInfo, JsCompilation, JsModule, JsRuntimeModule, JsStatsChunk, JsPathData, JsStatsWarning } from "@rspack/binding";
14
- import { RspackOptionsNormalized, StatsOptions, OutputNormalized, StatsValue, RspackPluginInstance, Filename } from "./config";
15
- import * as liteTapable from "./lite-tapable";
14
+ import { Filename, OutputNormalized, RspackOptionsNormalized, RspackPluginInstance, StatsOptions, StatsValue } from "./config";
16
15
  import { ContextModuleFactory } from "./ContextModuleFactory";
16
+ import * as liteTapable from "./lite-tapable";
17
17
  import ResolverFactory = require("./ResolverFactory");
18
+ import { Chunk } from "./Chunk";
19
+ import { ChunkGraph } from "./ChunkGraph";
18
20
  import { Compiler } from "./Compiler";
21
+ import { Entrypoint } from "./Entrypoint";
19
22
  import { Logger } from "./logging/Logger";
23
+ import { CodeGenerationResult, Module } from "./Module";
20
24
  import { NormalModuleFactory } from "./NormalModuleFactory";
21
25
  import { Stats } from "./Stats";
22
26
  import { StatsFactory } from "./stats/StatsFactory";
23
27
  import { StatsPrinter } from "./stats/StatsPrinter";
24
28
  import MergeCaller from "./util/MergeCaller";
25
- import { Chunk } from "./Chunk";
26
- import { CodeGenerationResult, Module } from "./Module";
27
- import { ChunkGraph } from "./ChunkGraph";
28
- import { Entrypoint } from "./Entrypoint";
29
29
  export type AssetInfo = Partial<JsAssetInfo> & Record<string, any>;
30
30
  export type Assets = Record<string, Source>;
31
31
  export interface Asset {
@@ -93,16 +93,16 @@ export declare class Compilation {
93
93
  runtimeModule: liteTapable.SyncHook<[JsRuntimeModule, Chunk], void>;
94
94
  afterSeal: liteTapable.AsyncSeriesHook<[], void>;
95
95
  };
96
- options: RspackOptionsNormalized;
97
- outputOptions: OutputNormalized;
96
+ name?: string;
97
+ startTime?: number;
98
+ endTime?: number;
98
99
  compiler: Compiler;
99
100
  resolverFactory: ResolverFactory;
100
101
  inputFileSystem: any;
102
+ options: RspackOptionsNormalized;
103
+ outputOptions: OutputNormalized;
101
104
  logging: Map<string, LogEntry[]>;
102
- name?: string;
103
105
  childrenCounters: Record<string, number>;
104
- startTime?: number;
105
- endTime?: number;
106
106
  children: Compilation[];
107
107
  chunkGraph: ChunkGraph;
108
108
  fileSystemInfo: {
@@ -118,14 +118,20 @@ export declare class Compilation {
118
118
  get fullHash(): string | null;
119
119
  /**
120
120
  * Get a map of all assets.
121
- *
122
- * Source: [assets](https://github.com/webpack/webpack/blob/9fcaa243573005d6fdece9a3f8d89a0e8b399613/lib/Compilation.js#L1008-L1009)
123
121
  */
124
122
  get assets(): Record<string, Source>;
125
123
  /**
126
124
  * Get a map of all entrypoints.
127
125
  */
128
126
  get entrypoints(): ReadonlyMap<string, Entrypoint>;
127
+ get modules(): Module[];
128
+ get chunks(): Chunk[];
129
+ /**
130
+ * Get the named chunks.
131
+ *
132
+ * Note: This is a proxy for webpack internal API, only method `get` is supported now.
133
+ */
134
+ get namedChunks(): Map<string, Readonly<Chunk>>;
129
135
  getCache(name: string): import("./lib/CacheFacade");
130
136
  createStatsOptions(optionsOrPreset: StatsValue | undefined, context?: CreateStatsOptionsContext): StatsOptions;
131
137
  createStatsFactory(options: StatsOptions): StatsFactory;
@@ -133,18 +139,12 @@ export declare class Compilation {
133
139
  /**
134
140
  * Update an existing asset. Trying to update an asset that doesn't exist will throw an error.
135
141
  *
136
- * See: [Compilation.updateAsset](https://webpack.js.org/api/compilation-object/#updateasset)
137
- * Source: [updateAsset](https://github.com/webpack/webpack/blob/9fcaa243573005d6fdece9a3f8d89a0e8b399613/lib/Compilation.js#L4320)
138
- *
139
142
  * FIXME: *AssetInfo* may be undefined in update fn for webpack impl, but still not implemented in rspack
140
143
  */
141
144
  updateAsset(filename: string, newSourceOrFunction: Source | ((source: Source) => Source), assetInfoUpdateOrFunction?: AssetInfo | ((assetInfo: AssetInfo) => AssetInfo)): void;
142
145
  /**
143
146
  * Emit an not existing asset. Trying to emit an asset that already exists will throw an error.
144
147
  *
145
- * See: [Compilation.emitAsset](https://webpack.js.org/api/compilation-object/#emitasset)
146
- * Source: [emitAsset](https://github.com/webpack/webpack/blob/9fcaa243573005d6fdece9a3f8d89a0e8b399613/lib/Compilation.js#L4239)
147
- *
148
148
  * @param file - file name
149
149
  * @param source - asset source
150
150
  * @param assetInfo - extra asset information
@@ -154,15 +154,22 @@ export declare class Compilation {
154
154
  renameAsset(filename: string, newFilename: string): void;
155
155
  /**
156
156
  * Get an array of Asset
157
+ */
158
+ getAssets(): ReadonlyArray<Asset>;
159
+ getAsset(name: string): Readonly<Asset> | void;
160
+ /**
161
+ * Note: This is not a webpack public API, maybe removed in future.
162
+ *
163
+ * @internal
164
+ */
165
+ __internal__pushDiagnostic(severity: "error" | "warning", title: string, message: string): void;
166
+ /**
167
+ * Note: This is not a webpack public API, maybe removed in future.
157
168
  *
158
- * See: [Compilation.getAssets](https://webpack.js.org/api/compilation-object/#getassets)
159
- * Source: [getAssets](https://github.com/webpack/webpack/blob/9fcaa243573005d6fdece9a3f8d89a0e8b399613/lib/Compilation.js#L4448)
169
+ * @internal
160
170
  */
161
- getAssets(): Readonly<Asset>[];
162
- getAsset(name: string): Asset | void;
163
- pushDiagnostic(severity: "error" | "warning", title: string, message: string): void;
164
- __internal__pushNativeDiagnostics(diagnostics: ExternalObject<any>): void;
165
- get errors(): any;
171
+ __internal__pushNativeDiagnostics(diagnostics: ExternalObject<"Diagnostic[]">): void;
172
+ get errors(): JsStatsError[];
166
173
  get warnings(): JsStatsWarning[];
167
174
  getPath(filename: Filename, data?: PathData): string;
168
175
  getPathWithInfo(filename: Filename, data?: PathData): import("@rspack/binding").PathWithInfo;
@@ -193,44 +200,6 @@ export declare class Compilation {
193
200
  add: (dep: string) => void;
194
201
  addAll: (deps: Iterable<string>) => void;
195
202
  };
196
- get modules(): Module[];
197
- get chunks(): Chunk[];
198
- /**
199
- * Get the named chunks.
200
- *
201
- * Note: This is a proxy for webpack internal API, only method `get` is supported now.
202
- */
203
- get namedChunks(): Map<string, Readonly<Chunk>>;
204
- /**
205
- * Get the associated `modules` of an given chunk.
206
- *
207
- * Note: This is not a webpack public API, maybe removed in future.
208
- *
209
- * @internal
210
- */
211
- __internal__getAssociatedModules(chunk: JsStatsChunk): any[] | undefined;
212
- /**
213
- * Find a modules in an array.
214
- *
215
- * Note: This is not a webpack public API, maybe removed in future.
216
- *
217
- * @internal
218
- */
219
- __internal__findJsModule(identifier: string, modules: Map<string, JsModule>): JsModule | undefined;
220
- /**
221
- *
222
- * Note: This is not a webpack public API, maybe removed in future.
223
- *
224
- * @internal
225
- */
226
- __internal__getModules(): JsModule[];
227
- /**
228
- *
229
- * Note: This is not a webpack public API, maybe removed in future.
230
- *
231
- * @internal
232
- */
233
- __internal__getChunks(): Chunk[];
234
203
  getStats(): Stats;
235
204
  createChildCompiler(name: string, outputOptions: OutputNormalized, plugins: RspackPluginInstance[]): Compiler;
236
205
  _rebuildModuleCaller: MergeCaller<[string, (err: Error, m: Module) => void]>;
@@ -275,6 +244,18 @@ export declare class Compilation {
275
244
  * @internal
276
245
  */
277
246
  __internal__hasAsset(name: string): boolean;
247
+ /**
248
+ * Note: This is not a webpack public API, maybe removed in future.
249
+ *
250
+ * @internal
251
+ */
252
+ __internal__getModules(): JsModule[];
253
+ /**
254
+ * Note: This is not a webpack public API, maybe removed in future.
255
+ *
256
+ * @internal
257
+ */
258
+ __internal__getChunks(): Chunk[];
278
259
  __internal_getInner(): JsCompilation;
279
260
  seal(): void;
280
261
  unseal(): void;