@rspack/core 2.0.0-beta.3 → 2.0.0-beta.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.
@@ -10,7 +10,7 @@
10
10
  import type { AssetInfo, ChunkGroup, Dependency, ExternalObject, JsCompilation } from '@rspack/binding';
11
11
  import binding from '@rspack/binding';
12
12
  export type { AssetInfo } from '@rspack/binding';
13
- import * as liteTapable from '../compiled/@rspack/lite-tapable/dist/index.d.ts';
13
+ import * as liteTapable from '../compiled/@rspack/lite-tapable/dist';
14
14
  import type { Source } from '../compiled/webpack-sources';
15
15
  import type { EntryOptions, EntryPlugin } from './builtin-plugin/index.js';
16
16
  import type { Chunk } from './Chunk.js';
@@ -8,7 +8,7 @@
8
8
  * https://github.com/webpack/webpack/blob/main/LICENSE
9
9
  */
10
10
  import type binding from '@rspack/binding';
11
- import * as liteTapable from '../compiled/@rspack/lite-tapable/dist/index.d.ts';
11
+ import * as liteTapable from '../compiled/@rspack/lite-tapable/dist';
12
12
  import type Watchpack from '../compiled/watchpack';
13
13
  import type { Source } from '../compiled/webpack-sources';
14
14
  import type { Chunk } from './Chunk.js';
@@ -1,4 +1,4 @@
1
- import * as liteTapable from '../compiled/@rspack/lite-tapable/dist/index.d.ts';
1
+ import * as liteTapable from '../compiled/@rspack/lite-tapable/dist';
2
2
  import type { ContextModuleFactoryAfterResolveResult, ContextModuleFactoryBeforeResolveResult } from './Module.js';
3
3
  export declare class ContextModuleFactory {
4
4
  hooks: {
@@ -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 * as liteTapable from '../compiled/@rspack/lite-tapable/dist/index.d.ts';
10
+ import * as liteTapable from '../compiled/@rspack/lite-tapable/dist';
11
11
  import type { CompilationParams, Compiler, CompilerHooks, RspackOptions } from './index.js';
12
12
  import type { WatchOptions } from './config/index.js';
13
13
  import MultiStats from './MultiStats.js';
@@ -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 type { Callback } from '../compiled/@rspack/lite-tapable/dist/index.d.ts';
10
+ import type { Callback } from '../compiled/@rspack/lite-tapable/dist';
11
11
  import type { MultiCompiler } from './MultiCompiler.js';
12
12
  import type { Watching } from './Watching.js';
13
13
  declare class MultiWatching {
@@ -1,4 +1,4 @@
1
- import * as liteTapable from '../compiled/@rspack/lite-tapable/dist/index.d.ts';
1
+ import * as liteTapable from '../compiled/@rspack/lite-tapable/dist';
2
2
  import type { Compilation } from './Compilation.js';
3
3
  import type { LoaderContext } from './config/index.js';
4
4
  import type { Module } from './Module.js';
@@ -1,5 +1,5 @@
1
1
  import type binding from '@rspack/binding';
2
- import * as liteTapable from '../compiled/@rspack/lite-tapable/dist/index.d.ts';
2
+ import * as liteTapable from '../compiled/@rspack/lite-tapable/dist';
3
3
  import type { ResolveData, ResourceDataWithData } from './Module.js';
4
4
  import type { ResolveOptionsWithDependencyType, ResolverFactory } from './ResolverFactory.js';
5
5
  export type NormalModuleCreateData = binding.JsNormalModuleFactoryCreateModuleArgs & {
@@ -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 type { Callback } from '../compiled/@rspack/lite-tapable/dist/index.d.ts';
10
+ import type { Callback } from '../compiled/@rspack/lite-tapable/dist';
11
11
  import type { Compiler } from './index.js';
12
12
  import { Stats } from './index.js';
13
13
  import type { WatchOptions } from './config/index.js';
@@ -1,13 +1,15 @@
1
1
  import type { Compiler } from '../Compiler.js';
2
- import type { RspackOptionsNormalized } from '../config/index.js';
2
+ import type { OptimizationSplitChunksOptions, RspackOptionsNormalized } from '../config/index.js';
3
3
  export declare function applyLimits(options: RspackOptionsNormalized): void;
4
4
  export declare class EsmLibraryPlugin {
5
5
  static PLUGIN_NAME: string;
6
- options?: {
6
+ options: {
7
7
  preserveModules?: string;
8
+ splitChunks?: OptimizationSplitChunksOptions | false;
8
9
  };
9
10
  constructor(options?: {
10
11
  preserveModules?: string;
12
+ splitChunks?: OptimizationSplitChunksOptions | false;
11
13
  });
12
14
  apply(compiler: Compiler): void;
13
15
  }
@@ -1,5 +1,5 @@
1
1
  import { type BuiltinPlugin, BuiltinPluginName } from '@rspack/binding';
2
- import * as liteTapable from '../../compiled/@rspack/lite-tapable/dist/index.d.ts';
2
+ import * as liteTapable from '../../compiled/@rspack/lite-tapable/dist';
3
3
  import type { Chunk } from '../Chunk.js';
4
4
  import { type Compilation } from '../Compilation.js';
5
5
  import type Hash from '../util/hash/index.js';
@@ -1,5 +1,5 @@
1
1
  import { type JsRsdoctorAsset, type JsRsdoctorAssetPatch, type JsRsdoctorChunk, type JsRsdoctorChunkAssets, type JsRsdoctorChunkGraph, type JsRsdoctorChunkModules, type JsRsdoctorDependency, type JsRsdoctorEntrypoint, type JsRsdoctorEntrypointAssets, type JsRsdoctorExportInfo, type JsRsdoctorModule, type JsRsdoctorModuleGraph, type JsRsdoctorModuleGraphModule, type JsRsdoctorModuleIdsPatch, type JsRsdoctorModuleOriginalSource, type JsRsdoctorModuleSourcesPatch, type JsRsdoctorSideEffect, type JsRsdoctorSourcePosition, type JsRsdoctorSourceRange, type JsRsdoctorStatement, type JsRsdoctorVariable } from '@rspack/binding';
2
- import * as liteTapable from '../../compiled/@rspack/lite-tapable/dist/index.d.ts';
2
+ import * as liteTapable from '../../compiled/@rspack/lite-tapable/dist';
3
3
  import { type Compilation } from '../Compilation.js';
4
4
  import type { Compiler } from '../Compiler.js';
5
5
  import type { CreatePartialRegisters } from '../taps/types.js';
@@ -1,5 +1,5 @@
1
1
  import binding from '@rspack/binding';
2
- import * as liteTapable from '../../compiled/@rspack/lite-tapable/dist/index.d.ts';
2
+ import * as liteTapable from '../../compiled/@rspack/lite-tapable/dist';
3
3
  import type { Chunk } from '../Chunk.js';
4
4
  import { type Compilation } from '../Compilation.js';
5
5
  import type { CreatePartialRegisters } from '../taps/types.js';
@@ -1,4 +1,4 @@
1
- import { type BuiltinPlugin, BuiltinPluginName } from '@rspack/binding';
1
+ import { type BuiltinPlugin, BuiltinPluginName, type RawSplitChunksOptions } from '@rspack/binding';
2
2
  import type { Compiler } from '../Compiler.js';
3
3
  import type { OptimizationSplitChunksOptions } from '../config/index.js';
4
4
  import { RspackBuiltinPlugin } from './base.js';
@@ -9,3 +9,4 @@ export declare class SplitChunksPlugin extends RspackBuiltinPlugin {
9
9
  constructor(options: OptimizationSplitChunksOptions);
10
10
  raw(compiler: Compiler): BuiltinPlugin;
11
11
  }
12
+ export declare function toRawSplitChunksOptions(sc: false | OptimizationSplitChunksOptions, compiler: Compiler): RawSplitChunksOptions | undefined;
@@ -1,5 +1,5 @@
1
1
  import type { JsAfterEmitData, JsAfterTemplateExecutionData, JsAlterAssetTagGroupsData, JsAlterAssetTagsData, JsBeforeAssetTagGenerationData, JsBeforeEmitData } from '@rspack/binding';
2
- import * as liteTapable from '../../../compiled/@rspack/lite-tapable/dist/index.d.ts';
2
+ import * as liteTapable from '../../../compiled/@rspack/lite-tapable/dist';
3
3
  import { type Compilation } from '../../Compilation.js';
4
4
  import type { HtmlRspackPluginOptions } from './options.js';
5
5
  type ExtraPluginHookData = {
package/dist/index.js CHANGED
@@ -2671,8 +2671,77 @@ class EnableLibraryPlugin extends RspackBuiltinPlugin {
2671
2671
  }
2672
2672
  }
2673
2673
  let EnableWasmLoadingPlugin = base_create(binding_namespaceObject.BuiltinPluginName.EnableWasmLoadingPlugin, (type)=>type), EnsureChunkConditionsPlugin = base_create(binding_namespaceObject.BuiltinPluginName.EnsureChunkConditionsPlugin, ()=>{}), RemoveDuplicateModulesPlugin = base_create(binding_namespaceObject.BuiltinPluginName.RemoveDuplicateModulesPlugin, ()=>({}));
2674
+ class JsSplitChunkSizes {
2675
+ static __to_binding(sizes) {
2676
+ return 'number' == typeof sizes ? sizes : sizes && 'object' == typeof sizes ? {
2677
+ sizes: sizes
2678
+ } : sizes;
2679
+ }
2680
+ }
2681
+ class SplitChunksPlugin extends RspackBuiltinPlugin {
2682
+ options;
2683
+ name = binding_namespaceObject.BuiltinPluginName.SplitChunksPlugin;
2684
+ affectedHooks = 'thisCompilation';
2685
+ constructor(options){
2686
+ super(), this.options = options;
2687
+ }
2688
+ raw(compiler) {
2689
+ let rawOptions = toRawSplitChunksOptions(this.options, compiler);
2690
+ if (void 0 === rawOptions) throw Error('rawOptions should not be undefined');
2691
+ return createBuiltinPlugin(this.name, rawOptions);
2692
+ }
2693
+ }
2694
+ function toRawSplitChunksOptions(sc, compiler) {
2695
+ if (!sc) return;
2696
+ function getName(name) {
2697
+ return 'function' == typeof name ? (ctx)=>void 0 === ctx.module ? name(void 0) : name(ctx.module, getChunks(ctx.chunks), ctx.cacheGroupKey) : name;
2698
+ }
2699
+ function getChunks(chunks) {
2700
+ return 'function' == typeof chunks ? (chunk)=>chunks(chunk) : chunks;
2701
+ }
2702
+ let { name, chunks, defaultSizeTypes, cacheGroups = {}, fallbackCacheGroup, minSize, minSizeReduction, maxSize, maxAsyncSize, maxInitialSize, ...passThrough } = sc;
2703
+ return {
2704
+ name: getName(name),
2705
+ chunks: getChunks(chunks),
2706
+ defaultSizeTypes: defaultSizeTypes || [
2707
+ "javascript",
2708
+ 'unknown'
2709
+ ],
2710
+ cacheGroups: Object.entries(cacheGroups).filter(([_key, group])=>!1 !== group).map(([key, group])=>{
2711
+ let { test, name, chunks, minSize, minSizeReduction, maxSize, maxAsyncSize, maxInitialSize, ...passThrough } = group;
2712
+ return {
2713
+ key,
2714
+ test: 'function' == typeof test ? (ctx)=>{
2715
+ let info = {
2716
+ moduleGraph: compiler._lastCompilation.moduleGraph,
2717
+ chunkGraph: compiler._lastCompilation.chunkGraph
2718
+ };
2719
+ return test(ctx.module, info);
2720
+ } : test,
2721
+ name: getName(name),
2722
+ chunks: getChunks(chunks),
2723
+ minSize: JsSplitChunkSizes.__to_binding(minSize),
2724
+ minSizeReduction: JsSplitChunkSizes.__to_binding(minSizeReduction),
2725
+ maxSize: JsSplitChunkSizes.__to_binding(maxSize),
2726
+ maxAsyncSize: JsSplitChunkSizes.__to_binding(maxAsyncSize),
2727
+ maxInitialSize: JsSplitChunkSizes.__to_binding(maxInitialSize),
2728
+ ...passThrough
2729
+ };
2730
+ }),
2731
+ fallbackCacheGroup: {
2732
+ chunks: getChunks(chunks),
2733
+ ...fallbackCacheGroup
2734
+ },
2735
+ minSize: JsSplitChunkSizes.__to_binding(minSize),
2736
+ minSizeReduction: JsSplitChunkSizes.__to_binding(minSizeReduction),
2737
+ maxSize: JsSplitChunkSizes.__to_binding(maxSize),
2738
+ maxAsyncSize: JsSplitChunkSizes.__to_binding(maxAsyncSize),
2739
+ maxInitialSize: JsSplitChunkSizes.__to_binding(maxInitialSize),
2740
+ ...passThrough
2741
+ };
2742
+ }
2674
2743
  function applyLimits(options) {
2675
- options.optimization.concatenateModules = !1, options.optimization.removeEmptyChunks = !1, options.output.chunkFormat = !1, options.output.chunkLoading && 'import' !== options.output.chunkLoading && (options.output.chunkLoading = 'import'), void 0 === options.output.chunkLoading && (options.output.chunkLoading = 'import');
2744
+ options.optimization.concatenateModules = !1, options.optimization.removeEmptyChunks = !1, options.output.chunkFormat = !1, options.output.module = !0, options.output.chunkLoading && 'import' !== options.output.chunkLoading && (options.output.chunkLoading = 'import'), void 0 === options.output.chunkLoading && (options.output.chunkLoading = 'import');
2676
2745
  let { splitChunks } = options.optimization;
2677
2746
  void 0 === splitChunks && (splitChunks = options.optimization.splitChunks = {}), !1 !== splitChunks && (splitChunks.chunks = 'all', splitChunks.minSize = 0, splitChunks.maxAsyncRequests = 1 / 0, splitChunks.maxInitialRequests = 1 / 0, splitChunks.cacheGroups ??= {}, splitChunks.cacheGroups.default = !1, splitChunks.cacheGroups.defaultVendors = !1);
2678
2747
  }
@@ -2680,7 +2749,7 @@ class EsmLibraryPlugin {
2680
2749
  static PLUGIN_NAME = 'EsmLibraryPlugin';
2681
2750
  options;
2682
2751
  constructor(options){
2683
- this.options = options;
2752
+ this.options = options ?? {};
2684
2753
  }
2685
2754
  apply(compiler) {
2686
2755
  var config;
@@ -2689,7 +2758,8 @@ class EsmLibraryPlugin {
2689
2758
  compiler.__internal__registerBuiltinPlugin({
2690
2759
  name: binding_namespaceObject.BuiltinPluginName.EsmLibraryPlugin,
2691
2760
  options: {
2692
- preserveModules: this.options?.preserveModules
2761
+ preserveModules: this.options.preserveModules,
2762
+ splitChunks: toRawSplitChunksOptions(this.options.splitChunks ?? !1, compiler)
2693
2763
  }
2694
2764
  });
2695
2765
  }
@@ -5080,76 +5150,7 @@ let SideEffectsFlagPlugin = base_create(binding_namespaceObject.BuiltinPluginNam
5080
5150
  ...options,
5081
5151
  hints
5082
5152
  };
5083
- }), SourceMapDevToolPlugin = base_create(binding_namespaceObject.BuiltinPluginName.SourceMapDevToolPlugin, (options)=>options, 'compilation');
5084
- class JsSplitChunkSizes {
5085
- static __to_binding(sizes) {
5086
- return 'number' == typeof sizes ? sizes : sizes && 'object' == typeof sizes ? {
5087
- sizes: sizes
5088
- } : sizes;
5089
- }
5090
- }
5091
- class SplitChunksPlugin extends RspackBuiltinPlugin {
5092
- options;
5093
- name = binding_namespaceObject.BuiltinPluginName.SplitChunksPlugin;
5094
- affectedHooks = 'thisCompilation';
5095
- constructor(options){
5096
- super(), this.options = options;
5097
- }
5098
- raw(compiler) {
5099
- let rawOptions = function(sc, compiler) {
5100
- if (!sc) return;
5101
- function getName(name) {
5102
- return 'function' == typeof name ? (ctx)=>void 0 === ctx.module ? name(void 0) : name(ctx.module, getChunks(ctx.chunks), ctx.cacheGroupKey) : name;
5103
- }
5104
- function getChunks(chunks) {
5105
- return 'function' == typeof chunks ? (chunk)=>chunks(chunk) : chunks;
5106
- }
5107
- let { name, chunks, defaultSizeTypes, cacheGroups = {}, fallbackCacheGroup, minSize, minSizeReduction, maxSize, maxAsyncSize, maxInitialSize, ...passThrough } = sc;
5108
- return {
5109
- name: getName(name),
5110
- chunks: getChunks(chunks),
5111
- defaultSizeTypes: defaultSizeTypes || [
5112
- "javascript",
5113
- 'unknown'
5114
- ],
5115
- cacheGroups: Object.entries(cacheGroups).filter(([_key, group])=>!1 !== group).map(([key, group])=>{
5116
- let { test, name, chunks, minSize, minSizeReduction, maxSize, maxAsyncSize, maxInitialSize, ...passThrough } = group;
5117
- return {
5118
- key,
5119
- test: 'function' == typeof test ? (ctx)=>{
5120
- let info = {
5121
- moduleGraph: compiler._lastCompilation.moduleGraph,
5122
- chunkGraph: compiler._lastCompilation.chunkGraph
5123
- };
5124
- return test(ctx.module, info);
5125
- } : test,
5126
- name: getName(name),
5127
- chunks: getChunks(chunks),
5128
- minSize: JsSplitChunkSizes.__to_binding(minSize),
5129
- minSizeReduction: JsSplitChunkSizes.__to_binding(minSizeReduction),
5130
- maxSize: JsSplitChunkSizes.__to_binding(maxSize),
5131
- maxAsyncSize: JsSplitChunkSizes.__to_binding(maxAsyncSize),
5132
- maxInitialSize: JsSplitChunkSizes.__to_binding(maxInitialSize),
5133
- ...passThrough
5134
- };
5135
- }),
5136
- fallbackCacheGroup: {
5137
- chunks: getChunks(chunks),
5138
- ...fallbackCacheGroup
5139
- },
5140
- minSize: JsSplitChunkSizes.__to_binding(minSize),
5141
- minSizeReduction: JsSplitChunkSizes.__to_binding(minSizeReduction),
5142
- maxSize: JsSplitChunkSizes.__to_binding(maxSize),
5143
- maxAsyncSize: JsSplitChunkSizes.__to_binding(maxAsyncSize),
5144
- maxInitialSize: JsSplitChunkSizes.__to_binding(maxInitialSize),
5145
- ...passThrough
5146
- };
5147
- }(this.options, compiler);
5148
- if (void 0 === rawOptions) throw Error('rawOptions should not be undefined');
5149
- return createBuiltinPlugin(this.name, rawOptions);
5150
- }
5151
- }
5152
- let SubresourceIntegrityPlugin_require = createRequire(import.meta.url), SubresourceIntegrityPlugin_PLUGIN_NAME = 'SubresourceIntegrityPlugin', NATIVE_HTML_PLUGIN = 'HtmlRspackPlugin', HTTP_PROTOCOL_REGEX = /^https?:/, NativeSubresourceIntegrityPlugin = base_create(binding_namespaceObject.BuiltinPluginName.SubresourceIntegrityPlugin, function(options) {
5153
+ }), SourceMapDevToolPlugin = base_create(binding_namespaceObject.BuiltinPluginName.SourceMapDevToolPlugin, (options)=>options, 'compilation'), SubresourceIntegrityPlugin_require = createRequire(import.meta.url), SubresourceIntegrityPlugin_PLUGIN_NAME = 'SubresourceIntegrityPlugin', NATIVE_HTML_PLUGIN = 'HtmlRspackPlugin', HTTP_PROTOCOL_REGEX = /^https?:/, NativeSubresourceIntegrityPlugin = base_create(binding_namespaceObject.BuiltinPluginName.SubresourceIntegrityPlugin, function(options) {
5153
5154
  let htmlPlugin = 'Disabled';
5154
5155
  return options.htmlPlugin === NATIVE_HTML_PLUGIN ? htmlPlugin = 'Native' : 'string' == typeof options.htmlPlugin && (htmlPlugin = 'JavaScript'), {
5155
5156
  hashFuncNames: options.hashFuncNames,
@@ -6784,7 +6785,7 @@ You can also more options via the 'target' option: 'browserslist' / 'browserslis
6784
6785
  return output.wasmLoading && enabledWasmLoadingTypes.add(output.wasmLoading), output.workerWasmLoading && enabledWasmLoadingTypes.add(output.workerWasmLoading), forEachEntry((desc)=>{
6785
6786
  desc.wasmLoading && enabledWasmLoadingTypes.add(desc.wasmLoading);
6786
6787
  }), Array.from(enabledWasmLoadingTypes);
6787
- }), D(output, 'bundlerInfo', {}), 'object' == typeof output.bundlerInfo && (D(output.bundlerInfo, 'version', "2.0.0-beta.3"), D(output.bundlerInfo, 'bundler', 'rspack'), D(output.bundlerInfo, 'force', !output.library));
6788
+ }), D(output, 'bundlerInfo', {}), 'object' == typeof output.bundlerInfo && (D(output.bundlerInfo, 'version', "2.0.0-beta.4"), D(output.bundlerInfo, 'bundler', 'rspack'), D(output.bundlerInfo, 'force', !output.library));
6788
6789
  }, applyExternalsPresetsDefaults = (externalsPresets, { targetProperties, buildHttp, outputModule })=>{
6789
6790
  let isUniversal = (key)=>!!(outputModule && targetProperties && null === targetProperties[key]);
6790
6791
  D(externalsPresets, 'web', !buildHttp && targetProperties && (targetProperties.web || isUniversal('node'))), D(externalsPresets, 'node', targetProperties && (targetProperties.node || isUniversal('node'))), D(externalsPresets, 'electron', targetProperties && targetProperties.electron || isUniversal('electron')), D(externalsPresets, 'electronMain', targetProperties && !!targetProperties.electron && (targetProperties.electronMain || isUniversal('electronMain'))), D(externalsPresets, 'electronPreload', targetProperties && !!targetProperties.electron && (targetProperties.electronPreload || isUniversal('electronPreload'))), D(externalsPresets, 'electronRenderer', targetProperties && !!targetProperties.electron && (targetProperties.electronRenderer || isUniversal('electronRenderer'))), D(externalsPresets, 'nwjs', targetProperties && (targetProperties.nwjs || isUniversal('nwjs')));
@@ -8038,7 +8039,7 @@ class MultiStats {
8038
8039
  obj.children = this.stats.map((stat, idx)=>{
8039
8040
  let obj = stat.toJson(childOptions.children[idx]), compilationName = stat.compilation.name;
8040
8041
  return obj.name = compilationName && makePathsRelative(childOptions.context, compilationName, stat.compilation.compiler.root), obj;
8041
- }), childOptions.version && (obj.rspackVersion = "2.0.0-beta.3", obj.version = "5.75.0"), childOptions.hash && (obj.hash = obj.children.map((j)=>j.hash).join(''));
8042
+ }), childOptions.version && (obj.rspackVersion = "2.0.0-beta.4", obj.version = "5.75.0"), childOptions.hash && (obj.hash = obj.children.map((j)=>j.hash).join(''));
8042
8043
  let mapError = (j, obj)=>({
8043
8044
  ...obj,
8044
8045
  compilerPath: obj.compilerPath ? `${j.name}.${obj.compilerPath}` : j.name
@@ -9297,7 +9298,7 @@ let iterateConfig = (config, options, fn)=>{
9297
9298
  object.hash = context.getStatsCompilation(compilation).hash;
9298
9299
  },
9299
9300
  version: (object)=>{
9300
- object.version = "5.75.0", object.rspackVersion = "2.0.0-beta.3";
9301
+ object.version = "5.75.0", object.rspackVersion = "2.0.0-beta.4";
9301
9302
  },
9302
9303
  env: (object, _compilation, _context, { _env })=>{
9303
9304
  object.env = _env;
@@ -10559,18 +10560,21 @@ class RspackOptionsApply {
10559
10560
  moduleFilenameTemplate: options.output.devtoolModuleFilenameTemplate,
10560
10561
  namespace: options.output.devtoolNamespace
10561
10562
  }).apply(compiler);
10562
- if (new JavascriptModulesPlugin().apply(compiler), new URLPlugin().apply(compiler), new JsonModulesPlugin().apply(compiler), new AssetModulesPlugin().apply(compiler), options.experiments.asyncWebAssembly && new AsyncWebAssemblyModulesPlugin().apply(compiler), new CssModulesPlugin().apply(compiler), new lib_EntryOptionPlugin().apply(compiler), assertNotNill(options.context), compiler.hooks.entryOption.call(options.context, options.entry), new RuntimePlugin().apply(compiler), options.output.bundlerInfo && new BundlerInfoRspackPlugin(options.output.bundlerInfo).apply(compiler), new InferAsyncModulesPlugin().apply(compiler), new APIPlugin().apply(compiler), new DataUriPlugin().apply(compiler), new FileUriPlugin().apply(compiler), options.experiments.buildHttp && new HttpUriPlugin(options.experiments.buildHttp).apply(compiler), new EnsureChunkConditionsPlugin().apply(compiler), options.optimization.mergeDuplicateChunks && new MergeDuplicateChunksPlugin().apply(compiler), options.optimization.sideEffects && new SideEffectsFlagPlugin().apply(compiler), options.optimization.providedExports && new FlagDependencyExportsPlugin().apply(compiler), options.optimization.usedExports && new FlagDependencyUsagePlugin('global' === options.optimization.usedExports).apply(compiler), options.optimization.concatenateModules && new ModuleConcatenationPlugin().apply(compiler), options.optimization.inlineExports && new InlineExportsPlugin().apply(compiler), options.optimization.mangleExports && new MangleExportsPlugin('size' !== options.optimization.mangleExports).apply(compiler), options.output.enabledLibraryTypes && options.output.enabledLibraryTypes.length > 0) {
10563
+ new JavascriptModulesPlugin().apply(compiler), new URLPlugin().apply(compiler), new JsonModulesPlugin().apply(compiler), new AssetModulesPlugin().apply(compiler), options.experiments.asyncWebAssembly && new AsyncWebAssemblyModulesPlugin().apply(compiler), new CssModulesPlugin().apply(compiler), new lib_EntryOptionPlugin().apply(compiler), assertNotNill(options.context), compiler.hooks.entryOption.call(options.context, options.entry), new RuntimePlugin().apply(compiler), options.output.bundlerInfo && new BundlerInfoRspackPlugin(options.output.bundlerInfo).apply(compiler), new InferAsyncModulesPlugin().apply(compiler), new APIPlugin().apply(compiler), new DataUriPlugin().apply(compiler), new FileUriPlugin().apply(compiler), options.experiments.buildHttp && new HttpUriPlugin(options.experiments.buildHttp).apply(compiler), new EnsureChunkConditionsPlugin().apply(compiler), options.optimization.mergeDuplicateChunks && new MergeDuplicateChunksPlugin().apply(compiler), options.optimization.sideEffects && new SideEffectsFlagPlugin().apply(compiler), options.optimization.providedExports && new FlagDependencyExportsPlugin().apply(compiler), options.optimization.usedExports && new FlagDependencyUsagePlugin('global' === options.optimization.usedExports).apply(compiler), options.optimization.concatenateModules && new ModuleConcatenationPlugin().apply(compiler), options.optimization.inlineExports && new InlineExportsPlugin().apply(compiler), options.optimization.mangleExports && new MangleExportsPlugin('size' !== options.optimization.mangleExports).apply(compiler);
10564
+ let enableLibSplitChunks = !1;
10565
+ if (options.output.enabledLibraryTypes && options.output.enabledLibraryTypes.length > 0) {
10563
10566
  let modernModuleCount = 0;
10564
10567
  for (let type of options.output.enabledLibraryTypes)'modern-module' === type && modernModuleCount++;
10565
10568
  if (options.output.library?.preserveModules && 0 === modernModuleCount) throw Error('preserveModules only works for `modern-module` library type');
10566
10569
  if (modernModuleCount > 0) {
10567
10570
  if (modernModuleCount !== options.output.enabledLibraryTypes.length) throw Error('`modern-module` cannot used together with other library types');
10568
- new EsmLibraryPlugin({
10569
- preserveModules: options.output.library?.preserveModules
10571
+ enableLibSplitChunks = !0, new EsmLibraryPlugin({
10572
+ preserveModules: options.output.library?.preserveModules,
10573
+ splitChunks: options.optimization.splitChunks
10570
10574
  }).apply(compiler);
10571
10575
  } else for (let type of options.output.enabledLibraryTypes)new EnableLibraryPlugin(type).apply(compiler);
10572
10576
  }
10573
- options.optimization.splitChunks && new SplitChunksPlugin(options.optimization.splitChunks).apply(compiler), options.optimization.removeEmptyChunks && new RemoveEmptyChunksPlugin().apply(compiler), options.optimization.realContentHash && new RealContentHashPlugin().apply(compiler);
10577
+ !enableLibSplitChunks && options.optimization.splitChunks && new SplitChunksPlugin(options.optimization.splitChunks).apply(compiler), options.optimization.removeEmptyChunks && new RemoveEmptyChunksPlugin().apply(compiler), options.optimization.realContentHash && new RealContentHashPlugin().apply(compiler);
10574
10578
  let moduleIds = options.optimization.moduleIds;
10575
10579
  if (moduleIds) switch(moduleIds){
10576
10580
  case 'named':
@@ -10959,7 +10963,7 @@ class TraceHookPlugin {
10959
10963
  });
10960
10964
  }
10961
10965
  }
10962
- let CORE_VERSION = "2.0.0-beta.3", VFILES_BY_COMPILER = new WeakMap();
10966
+ let CORE_VERSION = "2.0.0-beta.4", VFILES_BY_COMPILER = new WeakMap();
10963
10967
  class VirtualModulesPlugin {
10964
10968
  #staticModules;
10965
10969
  #compiler;
@@ -13243,7 +13247,7 @@ async function transform(source, options) {
13243
13247
  let _options = JSON.stringify(options || {});
13244
13248
  return binding_default().transform(source, _options);
13245
13249
  }
13246
- let exports_rspackVersion = "2.0.0-beta.3", exports_version = "5.75.0", exports_WebpackError = Error, exports_config = {
13250
+ let exports_rspackVersion = "2.0.0-beta.4", exports_version = "5.75.0", exports_WebpackError = Error, exports_config = {
13247
13251
  getNormalizedRspackOptions: getNormalizedRspackOptions,
13248
13252
  applyRspackOptionsDefaults: applyRspackOptionsDefaults,
13249
13253
  getNormalizedWebpackOptions: getNormalizedRspackOptions,
@@ -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 { AsyncParallelHook, AsyncSeriesBailHook, SyncHook } from '../../compiled/@rspack/lite-tapable/dist/index.d.ts';
10
+ import { AsyncParallelHook, AsyncSeriesBailHook, SyncHook } from '../../compiled/@rspack/lite-tapable/dist';
11
11
  import type { WebpackError } from './WebpackError.js';
12
12
  export interface Etag {
13
13
  toString(): string;
@@ -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 type { Callback } from '../../compiled/@rspack/lite-tapable/dist/index.d.ts';
10
+ import type { Callback } from '../../compiled/@rspack/lite-tapable/dist';
11
11
  import WebpackError from './WebpackError.js';
12
12
  export declare class HookWebpackError extends WebpackError {
13
13
  hook: string;
package/dist/rspack.d.ts CHANGED
@@ -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 type { Callback } from '../compiled/@rspack/lite-tapable/dist/index.d.ts';
10
+ import type { Callback } from '../compiled/@rspack/lite-tapable/dist';
11
11
  import { Compiler } from './Compiler.js';
12
12
  import { type RspackOptions } from './config/index.js';
13
13
  import { MultiCompiler, type MultiRspackOptions } from './MultiCompiler.js';
@@ -8,7 +8,7 @@
8
8
  * https://github.com/webpack/webpack/blob/main/LICENSE
9
9
  */
10
10
  import type { JsStats, JsStatsCompilation, JsStatsError } from '@rspack/binding';
11
- import { HookMap, SyncBailHook, SyncWaterfallHook } from '../../compiled/@rspack/lite-tapable/dist/index.d.ts';
11
+ import { HookMap, SyncBailHook, SyncWaterfallHook } from '../../compiled/@rspack/lite-tapable/dist';
12
12
  import type { Compilation } from '../Compilation.js';
13
13
  import { type GroupConfig } from '../util/smartGrouping.js';
14
14
  export type KnownStatsFactoryContext = {
@@ -1,4 +1,4 @@
1
- import { HookMap, SyncBailHook, SyncWaterfallHook } from '../../compiled/@rspack/lite-tapable/dist/index.d.ts';
1
+ import { HookMap, SyncBailHook, SyncWaterfallHook } from '../../compiled/@rspack/lite-tapable/dist';
2
2
  import type { StatsAsset, StatsChunk, StatsChunkGroup, StatsCompilation, StatsModule, StatsModuleReason } from './statsFactoryUtils.js';
3
3
  type PrintedElement = {
4
4
  element: string;
@@ -1,5 +1,5 @@
1
1
  import type binding from '@rspack/binding';
2
- import type * as liteTapable from '../../compiled/@rspack/lite-tapable/dist/index.d.ts';
2
+ import type * as liteTapable from '../../compiled/@rspack/lite-tapable/dist';
3
3
  import type { Compiler } from '../Compiler.js';
4
4
  type CreateHookMapRegisterTaps = <H extends liteTapable.Hook<any, any, any>>(registerKind: binding.RegisterJsTapKind, getHookMap: () => liteTapable.HookMap<H>, createTap: (queried: liteTapable.QueriedHookMap<H>) => any) => (stages: number[]) => binding.JsTap[];
5
5
  type CreateHookRegisterTaps = <T, R, A>(registerKind: binding.RegisterJsTapKind, getHook: () => liteTapable.Hook<T, R, A>, createTap: (queried: liteTapable.QueriedHook<T, R, A>) => any) => (stages: number[]) => binding.JsTap[];
package/module.d.ts CHANGED
@@ -176,7 +176,10 @@ declare namespace Rspack {
176
176
  id: ModuleId;
177
177
  loaded: boolean;
178
178
  parents: NodeJS.Module['id'][] | null | undefined;
179
- children: NodeJS.Module['id'][];
179
+ // Keep `any[]` for compatibility:
180
+ // - Rspack runtime uses module ids
181
+ // - `@types/node` defines `children` as `Module[]`.
182
+ children: any[];
180
183
  hot?: Hot;
181
184
  }
182
185
 
@@ -210,7 +213,6 @@ declare namespace Rspack {
210
213
  interface Process {
211
214
  env: {
212
215
  [key: string]: any;
213
- NODE_ENV: 'development' | 'production' | (string & {});
214
216
  };
215
217
  }
216
218
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rspack/core",
3
- "version": "2.0.0-beta.3",
3
+ "version": "2.0.0-beta.4",
4
4
  "webpackVersion": "5.75.0",
5
5
  "license": "MIT",
6
6
  "description": "The fast Rust-based web bundler with webpack-compatible API",
@@ -58,7 +58,7 @@
58
58
  "webpack-sources": "3.3.4"
59
59
  },
60
60
  "dependencies": {
61
- "@rspack/binding": "2.0.0-beta.3"
61
+ "@rspack/binding": "2.0.0-beta.4"
62
62
  },
63
63
  "peerDependencies": {
64
64
  "@module-federation/runtime-tools": "^0.24.1 || ^2.0.0",