@rspack/browser 2.0.0-beta.3 → 2.0.0-beta.5

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.
@@ -1,13 +1,15 @@
1
1
  import type { Compiler } from '../Compiler';
2
- import type { RspackOptionsNormalized } from '../config';
2
+ import type { OptimizationSplitChunksOptions, RspackOptionsNormalized } from '../config';
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,4 +1,4 @@
1
- import { type BuiltinPlugin, BuiltinPluginName } from '../binding';
1
+ import { type BuiltinPlugin, BuiltinPluginName, type RawSplitChunksOptions } from '../binding';
2
2
  import type { Compiler } from '../Compiler';
3
3
  import type { OptimizationSplitChunksOptions } from '../config';
4
4
  import { RspackBuiltinPlugin } from './base';
@@ -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;
@@ -809,10 +809,10 @@ export type JavascriptParserOptions = {
809
809
  */
810
810
  dynamicImportFetchPriority?: 'low' | 'high' | 'auto';
811
811
  /**
812
- * Enable or disable evaluating import.meta.
813
- * @default true
812
+ * Enable or disable evaluating import.meta. Set to 'preserve-unknown' to preserve unknown properties for runtime evaluation.
813
+ * @default 'preserve-unknown'
814
814
  */
815
- importMeta?: boolean;
815
+ importMeta?: boolean | 'preserve-unknown';
816
816
  /**
817
817
  * Enable parsing of new URL() syntax.
818
818
  * @default true
@@ -846,6 +846,8 @@ export type JavascriptParserOptions = {
846
846
  importExportsPresence?: ExportsPresence;
847
847
  /** Warn or error for conflicting re-exports */
848
848
  reexportExportsPresence?: ExportsPresence;
849
+ /** Handle the this context correctly according to the spec for namespace objects. */
850
+ strictThisContextOnImports?: boolean;
849
851
  /** Provide custom syntax for Worker parsing, commonly used to support Worklet */
850
852
  worker?: string[] | boolean;
851
853
  /** Override the module to strict or non-strict. */
@@ -1435,7 +1437,8 @@ export type StatsOptions = {
1435
1437
  errorsCount?: boolean;
1436
1438
  /**
1437
1439
  * Enables or disables the use of colors in the output.
1438
- * @default false
1440
+ * When undefined, defaults to true if the environment supports color (TTY, FORCE_COLOR, or NO_COLOR unset), otherwise false.
1441
+ * @default environment-dependent (see above)
1439
1442
  */
1440
1443
  colors?: boolean | StatsColorOptions;
1441
1444
  /**
package/dist/index.js CHANGED
@@ -52740,10 +52740,95 @@ class EnableLibraryPlugin extends RspackBuiltinPlugin {
52740
52740
  const EnableWasmLoadingPlugin = base_create(external_rspack_wasi_browser_js_.BuiltinPluginName.EnableWasmLoadingPlugin, (type)=>type);
52741
52741
  const EnsureChunkConditionsPlugin = base_create(external_rspack_wasi_browser_js_.BuiltinPluginName.EnsureChunkConditionsPlugin, ()=>{});
52742
52742
  const RemoveDuplicateModulesPlugin = base_create(external_rspack_wasi_browser_js_.BuiltinPluginName.RemoveDuplicateModulesPlugin, ()=>({}));
52743
+ class JsSplitChunkSizes {
52744
+ static __to_binding(sizes) {
52745
+ if ('number' == typeof sizes) return sizes;
52746
+ if (sizes && 'object' == typeof sizes) {
52747
+ const chunkSizes = {
52748
+ sizes: sizes
52749
+ };
52750
+ return chunkSizes;
52751
+ }
52752
+ return sizes;
52753
+ }
52754
+ }
52755
+ class SplitChunksPlugin extends RspackBuiltinPlugin {
52756
+ options;
52757
+ name = external_rspack_wasi_browser_js_.BuiltinPluginName.SplitChunksPlugin;
52758
+ affectedHooks = 'thisCompilation';
52759
+ constructor(options){
52760
+ super(), this.options = options;
52761
+ }
52762
+ raw(compiler) {
52763
+ const rawOptions = toRawSplitChunksOptions(this.options, compiler);
52764
+ if (void 0 === rawOptions) throw new Error('rawOptions should not be undefined');
52765
+ return createBuiltinPlugin(this.name, rawOptions);
52766
+ }
52767
+ }
52768
+ function toRawSplitChunksOptions(sc, compiler) {
52769
+ if (!sc) return;
52770
+ function getName(name) {
52771
+ if ('function' == typeof name) return (ctx)=>{
52772
+ if (void 0 === ctx.module) return name(void 0);
52773
+ return name(ctx.module, getChunks(ctx.chunks), ctx.cacheGroupKey);
52774
+ };
52775
+ return name;
52776
+ }
52777
+ function getTest(test) {
52778
+ if ('function' == typeof test) return (ctx)=>{
52779
+ const info = {
52780
+ moduleGraph: compiler._lastCompilation.moduleGraph,
52781
+ chunkGraph: compiler._lastCompilation.chunkGraph
52782
+ };
52783
+ return test(ctx.module, info);
52784
+ };
52785
+ return test;
52786
+ }
52787
+ function getChunks(chunks) {
52788
+ if ('function' == typeof chunks) return (chunk)=>chunks(chunk);
52789
+ return chunks;
52790
+ }
52791
+ const { name, chunks, defaultSizeTypes, cacheGroups = {}, fallbackCacheGroup, minSize, minSizeReduction, maxSize, maxAsyncSize, maxInitialSize, ...passThrough } = sc;
52792
+ return {
52793
+ name: getName(name),
52794
+ chunks: getChunks(chunks),
52795
+ defaultSizeTypes: defaultSizeTypes || [
52796
+ "javascript",
52797
+ 'unknown'
52798
+ ],
52799
+ cacheGroups: Object.entries(cacheGroups).filter(([_key, group])=>false !== group).map(([key, group])=>{
52800
+ const { test, name, chunks, minSize, minSizeReduction, maxSize, maxAsyncSize, maxInitialSize, ...passThrough } = group;
52801
+ const rawGroup = {
52802
+ key,
52803
+ test: getTest(test),
52804
+ name: getName(name),
52805
+ chunks: getChunks(chunks),
52806
+ minSize: JsSplitChunkSizes.__to_binding(minSize),
52807
+ minSizeReduction: JsSplitChunkSizes.__to_binding(minSizeReduction),
52808
+ maxSize: JsSplitChunkSizes.__to_binding(maxSize),
52809
+ maxAsyncSize: JsSplitChunkSizes.__to_binding(maxAsyncSize),
52810
+ maxInitialSize: JsSplitChunkSizes.__to_binding(maxInitialSize),
52811
+ ...passThrough
52812
+ };
52813
+ return rawGroup;
52814
+ }),
52815
+ fallbackCacheGroup: {
52816
+ chunks: getChunks(chunks),
52817
+ ...fallbackCacheGroup
52818
+ },
52819
+ minSize: JsSplitChunkSizes.__to_binding(minSize),
52820
+ minSizeReduction: JsSplitChunkSizes.__to_binding(minSizeReduction),
52821
+ maxSize: JsSplitChunkSizes.__to_binding(maxSize),
52822
+ maxAsyncSize: JsSplitChunkSizes.__to_binding(maxAsyncSize),
52823
+ maxInitialSize: JsSplitChunkSizes.__to_binding(maxInitialSize),
52824
+ ...passThrough
52825
+ };
52826
+ }
52743
52827
  function applyLimits(options) {
52744
52828
  options.optimization.concatenateModules = false;
52745
52829
  options.optimization.removeEmptyChunks = false;
52746
52830
  options.output.chunkFormat = false;
52831
+ options.output.module = true;
52747
52832
  if (options.output.chunkLoading && 'import' !== options.output.chunkLoading) options.output.chunkLoading = 'import';
52748
52833
  if (void 0 === options.output.chunkLoading) options.output.chunkLoading = 'import';
52749
52834
  let { splitChunks } = options.optimization;
@@ -52762,7 +52847,7 @@ class EsmLibraryPlugin {
52762
52847
  static PLUGIN_NAME = 'EsmLibraryPlugin';
52763
52848
  options;
52764
52849
  constructor(options){
52765
- this.options = options;
52850
+ this.options = options ?? {};
52766
52851
  }
52767
52852
  apply(compiler) {
52768
52853
  applyLimits(compiler.options);
@@ -52772,7 +52857,8 @@ class EsmLibraryPlugin {
52772
52857
  compiler.__internal__registerBuiltinPlugin({
52773
52858
  name: external_rspack_wasi_browser_js_.BuiltinPluginName.EsmLibraryPlugin,
52774
52859
  options: {
52775
- preserveModules: this.options?.preserveModules
52860
+ preserveModules: this.options.preserveModules,
52861
+ splitChunks: toRawSplitChunksOptions(this.options.splitChunks ?? false, compiler)
52776
52862
  }
52777
52863
  });
52778
52864
  }
@@ -52977,6 +53063,13 @@ const _parseResourceWithoutFragment = (str)=>{
52977
53063
  };
52978
53064
  };
52979
53065
  const parseResourceWithoutFragment = makeCacheable(_parseResourceWithoutFragment);
53066
+ var supportsColor_process = __webpack_require__("../../node_modules/.pnpm/process@0.11.10/node_modules/process/browser.js");
53067
+ function isStatsColorSupported() {
53068
+ if (void 0 === supportsColor_process) return false;
53069
+ const env = supportsColor_process.env ?? {};
53070
+ const argv = supportsColor_process.argv ?? [];
53071
+ return !('NO_COLOR' in env || argv.includes('--no-color')) && ('FORCE_COLOR' in env || argv.includes('--color') || 'win32' === supportsColor_process.platform || supportsColor_process.stdout?.isTTY && 'dumb' !== env.TERM || 'CI' in env);
53072
+ }
52980
53073
  function encodeVersion(version) {
52981
53074
  const [major, minor = 0, patch = 0] = version.split('-')[0].split('.').map((v)=>parseInt(v, 10));
52982
53075
  if (Number.isNaN(major) || Number.isNaN(minor) || Number.isNaN(patch)) return null;
@@ -54942,11 +55035,12 @@ function getRawJavascriptParserOptions(parser) {
54942
55035
  dynamicImportPreload: parser.dynamicImportPreload?.toString(),
54943
55036
  dynamicImportPrefetch: parser.dynamicImportPrefetch?.toString(),
54944
55037
  dynamicImportFetchPriority: parser.dynamicImportFetchPriority,
54945
- importMeta: parser.importMeta,
55038
+ importMeta: 'boolean' == typeof parser.importMeta ? String(parser.importMeta) : parser.importMeta,
54946
55039
  url: parser.url?.toString(),
54947
55040
  exprContextCritical: parser.exprContextCritical,
54948
55041
  unknownContextCritical: parser.unknownContextCritical,
54949
55042
  wrappedContextCritical: parser.wrappedContextCritical,
55043
+ strictThisContextOnImports: parser.strictThisContextOnImports,
54950
55044
  wrappedContextRegExp: parser.wrappedContextRegExp,
54951
55045
  exportsPresence: false === parser.exportsPresence ? 'false' : parser.exportsPresence,
54952
55046
  importExportsPresence: false === parser.importExportsPresence ? 'false' : parser.importExportsPresence,
@@ -55096,8 +55190,9 @@ function getRawNode(node) {
55096
55190
  }
55097
55191
  function getRawStats(stats) {
55098
55192
  const statsOptions = normalizeStatsPreset(stats);
55193
+ const colors = void 0 === statsOptions.colors ? isStatsColorSupported() : Boolean(statsOptions.colors);
55099
55194
  return {
55100
- colors: Boolean(statsOptions.colors)
55195
+ colors
55101
55196
  };
55102
55197
  }
55103
55198
  class ExternalsPlugin extends RspackBuiltinPlugin {
@@ -55872,90 +55967,6 @@ const SizeLimitsPlugin = base_create(external_rspack_wasi_browser_js_.BuiltinPlu
55872
55967
  };
55873
55968
  });
55874
55969
  const SourceMapDevToolPlugin = base_create(external_rspack_wasi_browser_js_.BuiltinPluginName.SourceMapDevToolPlugin, (options)=>options, 'compilation');
55875
- class JsSplitChunkSizes {
55876
- static __to_binding(sizes) {
55877
- if ('number' == typeof sizes) return sizes;
55878
- if (sizes && 'object' == typeof sizes) {
55879
- const chunkSizes = {
55880
- sizes: sizes
55881
- };
55882
- return chunkSizes;
55883
- }
55884
- return sizes;
55885
- }
55886
- }
55887
- class SplitChunksPlugin extends RspackBuiltinPlugin {
55888
- options;
55889
- name = external_rspack_wasi_browser_js_.BuiltinPluginName.SplitChunksPlugin;
55890
- affectedHooks = 'thisCompilation';
55891
- constructor(options){
55892
- super(), this.options = options;
55893
- }
55894
- raw(compiler) {
55895
- const rawOptions = toRawSplitChunksOptions(this.options, compiler);
55896
- if (void 0 === rawOptions) throw new Error('rawOptions should not be undefined');
55897
- return createBuiltinPlugin(this.name, rawOptions);
55898
- }
55899
- }
55900
- function toRawSplitChunksOptions(sc, compiler) {
55901
- if (!sc) return;
55902
- function getName(name) {
55903
- if ('function' == typeof name) return (ctx)=>{
55904
- if (void 0 === ctx.module) return name(void 0);
55905
- return name(ctx.module, getChunks(ctx.chunks), ctx.cacheGroupKey);
55906
- };
55907
- return name;
55908
- }
55909
- function getTest(test) {
55910
- if ('function' == typeof test) return (ctx)=>{
55911
- const info = {
55912
- moduleGraph: compiler._lastCompilation.moduleGraph,
55913
- chunkGraph: compiler._lastCompilation.chunkGraph
55914
- };
55915
- return test(ctx.module, info);
55916
- };
55917
- return test;
55918
- }
55919
- function getChunks(chunks) {
55920
- if ('function' == typeof chunks) return (chunk)=>chunks(chunk);
55921
- return chunks;
55922
- }
55923
- const { name, chunks, defaultSizeTypes, cacheGroups = {}, fallbackCacheGroup, minSize, minSizeReduction, maxSize, maxAsyncSize, maxInitialSize, ...passThrough } = sc;
55924
- return {
55925
- name: getName(name),
55926
- chunks: getChunks(chunks),
55927
- defaultSizeTypes: defaultSizeTypes || [
55928
- "javascript",
55929
- 'unknown'
55930
- ],
55931
- cacheGroups: Object.entries(cacheGroups).filter(([_key, group])=>false !== group).map(([key, group])=>{
55932
- const { test, name, chunks, minSize, minSizeReduction, maxSize, maxAsyncSize, maxInitialSize, ...passThrough } = group;
55933
- const rawGroup = {
55934
- key,
55935
- test: getTest(test),
55936
- name: getName(name),
55937
- chunks: getChunks(chunks),
55938
- minSize: JsSplitChunkSizes.__to_binding(minSize),
55939
- minSizeReduction: JsSplitChunkSizes.__to_binding(minSizeReduction),
55940
- maxSize: JsSplitChunkSizes.__to_binding(maxSize),
55941
- maxAsyncSize: JsSplitChunkSizes.__to_binding(maxAsyncSize),
55942
- maxInitialSize: JsSplitChunkSizes.__to_binding(maxInitialSize),
55943
- ...passThrough
55944
- };
55945
- return rawGroup;
55946
- }),
55947
- fallbackCacheGroup: {
55948
- chunks: getChunks(chunks),
55949
- ...fallbackCacheGroup
55950
- },
55951
- minSize: JsSplitChunkSizes.__to_binding(minSize),
55952
- minSizeReduction: JsSplitChunkSizes.__to_binding(minSizeReduction),
55953
- maxSize: JsSplitChunkSizes.__to_binding(maxSize),
55954
- maxAsyncSize: JsSplitChunkSizes.__to_binding(maxAsyncSize),
55955
- maxInitialSize: JsSplitChunkSizes.__to_binding(maxInitialSize),
55956
- ...passThrough
55957
- };
55958
- }
55959
55970
  var SubresourceIntegrityPlugin_Buffer = __webpack_require__("./src/browser/buffer.ts")["Buffer"];
55960
55971
  const SubresourceIntegrityPlugin_PLUGIN_NAME = 'SubresourceIntegrityPlugin';
55961
55972
  const NATIVE_HTML_PLUGIN = 'HtmlRspackPlugin';
@@ -56028,15 +56039,14 @@ class SubresourceIntegrityPlugin extends NativeSubresourceIntegrityPlugin {
56028
56039
  }
56029
56040
  let src = '';
56030
56041
  if (isUrlSrc) {
56031
- if (!publicPath) return;
56042
+ const isLocalPublicPath = !publicPath || '/' === publicPath || './' === publicPath;
56043
+ if (isLocalPublicPath) return;
56032
56044
  const protocolRelativePublicPath = publicPath.replace(HTTP_PROTOCOL_REGEX, '');
56033
56045
  const protocolRelativeTagSrc = tagSrc.replace(HTTP_PROTOCOL_REGEX, '');
56034
56046
  if (!protocolRelativeTagSrc.startsWith(protocolRelativePublicPath)) return;
56035
- {
56036
- const tagSrcWithScheme = `http:${protocolRelativeTagSrc}`;
56037
- const publicPathWithScheme = protocolRelativePublicPath.startsWith('//') ? `http:${protocolRelativePublicPath}` : protocolRelativePublicPath;
56038
- src = (0, path_browserify.relative)(publicPathWithScheme, decodeURIComponent(tagSrcWithScheme));
56039
- }
56047
+ const tagSrcWithScheme = `http:${protocolRelativeTagSrc}`;
56048
+ const publicPathWithScheme = protocolRelativePublicPath.startsWith('//') ? `http:${protocolRelativePublicPath}` : protocolRelativePublicPath;
56049
+ src = (0, path_browserify.relative)(publicPathWithScheme, decodeURIComponent(tagSrcWithScheme));
56040
56050
  } else src = (0, path_browserify.relative)(publicPath, decodeURIComponent(tagSrc));
56041
56051
  tag.attributes.integrity = this.getIntegrityChecksumForAsset(src) || computeIntegrity(this.options.hashFuncNames, (0, fs_0.readFileSync)((0, path_browserify.join)(outputPath, src)));
56042
56052
  tag.attributes.crossorigin = crossOriginLoading || 'anonymous';
@@ -57535,7 +57545,8 @@ const applyRspackOptionsDefaults = (options)=>{
57535
57545
  targetProperties,
57536
57546
  mode: options.mode,
57537
57547
  uniqueName: options.output.uniqueName,
57538
- deferImport: options.experiments.deferImport
57548
+ deferImport: options.experiments.deferImport,
57549
+ outputModule: options.output.module
57539
57550
  });
57540
57551
  applyOutputDefaults(options, {
57541
57552
  context: options.context,
@@ -57621,7 +57632,7 @@ const applyIncrementalDefaults = (options)=>{
57621
57632
  }
57622
57633
  };
57623
57634
  const applySnapshotDefaults = (_snapshot, _env)=>{};
57624
- const applyJavascriptParserOptionsDefaults = (parserOptions, { deferImport })=>{
57635
+ const applyJavascriptParserOptionsDefaults = (parserOptions, { deferImport, outputModule })=>{
57625
57636
  D(parserOptions, 'dynamicImportMode', 'lazy');
57626
57637
  D(parserOptions, 'dynamicImportPrefetch', false);
57627
57638
  D(parserOptions, 'dynamicImportPreload', false);
@@ -57629,6 +57640,7 @@ const applyJavascriptParserOptionsDefaults = (parserOptions, { deferImport })=>{
57629
57640
  D(parserOptions, 'exprContextCritical', true);
57630
57641
  D(parserOptions, 'unknownContextCritical', true);
57631
57642
  D(parserOptions, 'wrappedContextCritical', false);
57643
+ D(parserOptions, 'strictThisContextOnImports', false);
57632
57644
  D(parserOptions, 'wrappedContextRegExp', /.*/);
57633
57645
  D(parserOptions, 'exportsPresence', 'error');
57634
57646
  D(parserOptions, 'requireAsExpression', true);
@@ -57640,7 +57652,7 @@ const applyJavascriptParserOptionsDefaults = (parserOptions, { deferImport })=>{
57640
57652
  D(parserOptions, 'worker', [
57641
57653
  '...'
57642
57654
  ]);
57643
- D(parserOptions, 'importMeta', true);
57655
+ D(parserOptions, 'importMeta', outputModule ? 'preserve-unknown' : true);
57644
57656
  D(parserOptions, 'typeReexportsPresence', 'no-tolerant');
57645
57657
  D(parserOptions, 'jsx', false);
57646
57658
  D(parserOptions, 'deferImport', deferImport);
@@ -57652,7 +57664,7 @@ const applyCssGeneratorOptionsDefaults = (generatorOptions, { targetProperties }
57652
57664
  const applyJsonGeneratorOptionsDefaults = (generatorOptions)=>{
57653
57665
  D(generatorOptions, 'JSONParse', true);
57654
57666
  };
57655
- const applyModuleDefaults = (module, { asyncWebAssembly, targetProperties, mode, uniqueName, deferImport })=>{
57667
+ const applyModuleDefaults = (module, { asyncWebAssembly, targetProperties, mode, uniqueName, deferImport, outputModule })=>{
57656
57668
  assertNotNill(module.parser);
57657
57669
  assertNotNill(module.generator);
57658
57670
  F(module.parser, "asset", ()=>({}));
@@ -57662,7 +57674,8 @@ const applyModuleDefaults = (module, { asyncWebAssembly, targetProperties, mode,
57662
57674
  F(module.parser, "javascript", ()=>({}));
57663
57675
  assertNotNill(module.parser.javascript);
57664
57676
  applyJavascriptParserOptionsDefaults(module.parser.javascript, {
57665
- deferImport
57677
+ deferImport,
57678
+ outputModule
57666
57679
  });
57667
57680
  F(module.parser, "json", ()=>({}));
57668
57681
  assertNotNill(module.parser["json"]);
@@ -58022,7 +58035,7 @@ const applyOutputDefaults = (options, { context, targetProperties: tp, isAffecte
58022
58035
  });
58023
58036
  D(output, 'bundlerInfo', {});
58024
58037
  if ('object' == typeof output.bundlerInfo) {
58025
- D(output.bundlerInfo, 'version', "2.0.0-beta.3");
58038
+ D(output.bundlerInfo, 'version', "2.0.0-beta.5");
58026
58039
  D(output.bundlerInfo, 'bundler', 'rspack');
58027
58040
  D(output.bundlerInfo, 'force', !output.library);
58028
58041
  }
@@ -59684,7 +59697,7 @@ class MultiStats {
59684
59697
  return obj;
59685
59698
  });
59686
59699
  if (childOptions.version) {
59687
- obj.rspackVersion = "2.0.0-beta.3";
59700
+ obj.rspackVersion = "2.0.0-beta.5";
59688
59701
  obj.version = "5.75.0";
59689
59702
  }
59690
59703
  if (childOptions.hash) obj.hash = obj.children.map((j)=>j.hash).join('');
@@ -61370,7 +61383,7 @@ const SIMPLE_EXTRACTORS = {
61370
61383
  },
61371
61384
  version: (object)=>{
61372
61385
  object.version = "5.75.0";
61373
- object.rspackVersion = "2.0.0-beta.3";
61386
+ object.rspackVersion = "2.0.0-beta.5";
61374
61387
  },
61375
61388
  env: (object, _compilation, _context, { _env })=>{
61376
61389
  object.env = _env;
@@ -62013,7 +62026,7 @@ const DEFAULTS = {
62013
62026
  chunksSort: ()=>false,
62014
62027
  assetsSort: ()=>'!size',
62015
62028
  outputPath: OFF_FOR_TO_STRING,
62016
- colors: ()=>false
62029
+ colors: ()=>isStatsColorSupported()
62017
62030
  };
62018
62031
  const normalizeFilter = (item)=>{
62019
62032
  if ('string' == typeof item) {
@@ -62953,18 +62966,21 @@ class RspackOptionsApply {
62953
62966
  if (options.optimization.concatenateModules) new ModuleConcatenationPlugin().apply(compiler);
62954
62967
  if (options.optimization.inlineExports) new InlineExportsPlugin().apply(compiler);
62955
62968
  if (options.optimization.mangleExports) new MangleExportsPlugin('size' !== options.optimization.mangleExports).apply(compiler);
62969
+ let enableLibSplitChunks = false;
62956
62970
  if (options.output.enabledLibraryTypes && options.output.enabledLibraryTypes.length > 0) {
62957
62971
  let modernModuleCount = 0;
62958
62972
  for (const type of options.output.enabledLibraryTypes)if ('modern-module' === type) modernModuleCount++;
62959
62973
  if (options.output.library?.preserveModules && 0 === modernModuleCount) throw new Error('preserveModules only works for `modern-module` library type');
62960
62974
  if (modernModuleCount > 0) {
62961
62975
  if (modernModuleCount !== options.output.enabledLibraryTypes.length) throw new Error('`modern-module` cannot used together with other library types');
62976
+ enableLibSplitChunks = true;
62962
62977
  new EsmLibraryPlugin({
62963
- preserveModules: options.output.library?.preserveModules
62978
+ preserveModules: options.output.library?.preserveModules,
62979
+ splitChunks: options.optimization.splitChunks
62964
62980
  }).apply(compiler);
62965
62981
  } else for (const type of options.output.enabledLibraryTypes)new EnableLibraryPlugin(type).apply(compiler);
62966
62982
  }
62967
- if (options.optimization.splitChunks) new SplitChunksPlugin(options.optimization.splitChunks).apply(compiler);
62983
+ if (!enableLibSplitChunks && options.optimization.splitChunks) new SplitChunksPlugin(options.optimization.splitChunks).apply(compiler);
62968
62984
  if (options.optimization.removeEmptyChunks) new RemoveEmptyChunksPlugin().apply(compiler);
62969
62985
  if (options.optimization.realContentHash) new RealContentHashPlugin().apply(compiler);
62970
62986
  const moduleIds = options.optimization.moduleIds;
@@ -65418,7 +65434,7 @@ class CollectSharedEntryPlugin extends RspackBuiltinPlugin {
65418
65434
  compiler.hooks.thisCompilation.tap('Collect shared entry', (compilation)=>{
65419
65435
  compilation.hooks.processAssets.tap({
65420
65436
  name: 'CollectSharedEntry',
65421
- stage: compiler.webpack.Compilation.PROCESS_ASSETS_STAGE_OPTIMIZE_INLINE
65437
+ stage: compiler.rspack.Compilation.PROCESS_ASSETS_STAGE_OPTIMIZE_INLINE
65422
65438
  }, ()=>{
65423
65439
  compilation.getAssets().forEach((asset)=>{
65424
65440
  if (asset.name === SHARE_ENTRY_ASSET) this._collectedEntries = JSON.parse(asset.source.source().toString());
@@ -65577,7 +65593,7 @@ class VirtualEntryPlugin {
65577
65593
  compiler.hooks.thisCompilation.tap('RemoveVirtualEntryAsset', (compilation)=>{
65578
65594
  compilation.hooks.processAssets.tap({
65579
65595
  name: 'RemoveVirtualEntryAsset',
65580
- stage: compiler.webpack.Compilation.PROCESS_ASSETS_STAGE_OPTIMIZE
65596
+ stage: compiler.rspack.Compilation.PROCESS_ASSETS_STAGE_OPTIMIZE
65581
65597
  }, ()=>{
65582
65598
  try {
65583
65599
  const chunk = compilation.namedChunks.get(VIRTUAL_ENTRY_NAME);
@@ -65661,7 +65677,7 @@ class IndependentSharedPlugin {
65661
65677
  }
65662
65678
  });
65663
65679
  });
65664
- compilation.updateAsset(filename, new compiler.webpack.sources.RawSource(JSON.stringify(statsContent)));
65680
+ compilation.updateAsset(filename, new compiler.rspack.sources.RawSource(JSON.stringify(statsContent)));
65665
65681
  };
65666
65682
  injectBuildAssetsIntoStatsOrManifest(statsFileName);
65667
65683
  injectBuildAssetsIntoStatsOrManifest(manifestFileName);
@@ -66161,7 +66177,7 @@ function transformSync(source, options) {
66161
66177
  const _options = JSON.stringify(options || {});
66162
66178
  return external_rspack_wasi_browser_js_["default"].transformSync(source, _options);
66163
66179
  }
66164
- const exports_rspackVersion = "2.0.0-beta.3";
66180
+ const exports_rspackVersion = "2.0.0-beta.5";
66165
66181
  const exports_version = "5.75.0";
66166
66182
  const exports_WebpackError = Error;
66167
66183
  const exports_config = {
@@ -1099,6 +1099,18 @@ export interface JsRsdoctorChunkModules {
1099
1099
  modules: Array<number>
1100
1100
  }
1101
1101
 
1102
+ export interface JsRsdoctorConnection {
1103
+ ukey: number
1104
+ dependencyId: string
1105
+ module: number
1106
+ originModule?: number
1107
+ resolvedModule: number
1108
+ dependencyType: string
1109
+ userRequest: string
1110
+ loc?: string
1111
+ active: boolean
1112
+ }
1113
+
1102
1114
  export interface JsRsdoctorDependency {
1103
1115
  ukey: number
1104
1116
  kind: string
@@ -1124,7 +1136,6 @@ export interface JsRsdoctorExportInfo {
1124
1136
  from?: number
1125
1137
  variable?: number
1126
1138
  identifier?: JsRsdoctorStatement
1127
- sideEffects: Array<number>
1128
1139
  }
1129
1140
 
1130
1141
  export interface JsRsdoctorJsonModuleSize {
@@ -1146,6 +1157,7 @@ export interface JsRsdoctorModule {
1146
1157
  chunks: Array<number>
1147
1158
  issuerPath: Array<number>
1148
1159
  bailoutReason: Array<string>
1160
+ sideEffectsLocations: Array<JsRsdoctorSideEffectLocation>
1149
1161
  }
1150
1162
 
1151
1163
  export interface JsRsdoctorModuleGraph {
@@ -1195,6 +1207,13 @@ export interface JsRsdoctorSideEffect {
1195
1207
  variable?: number
1196
1208
  }
1197
1209
 
1210
+ export interface JsRsdoctorSideEffectLocation {
1211
+ location: string
1212
+ nodeType: string
1213
+ module: number
1214
+ request: string
1215
+ }
1216
+
1198
1217
  export interface JsRsdoctorSourceMapFeatures {
1199
1218
  cheap?: boolean
1200
1219
  module?: boolean
@@ -2186,6 +2205,7 @@ export interface RawEnvironment {
2186
2205
 
2187
2206
  export interface RawEsmLibraryPlugin {
2188
2207
  preserveModules?: string
2208
+ splitChunks?: RawSplitChunksOptions
2189
2209
  }
2190
2210
 
2191
2211
  export interface RawEvalDevToolModulePluginOptions {
@@ -2381,13 +2401,14 @@ export interface RawJavascriptParserOptions {
2381
2401
  exprContextCritical?: boolean
2382
2402
  unknownContextCritical?: boolean
2383
2403
  wrappedContextCritical?: boolean
2404
+ strictThisContextOnImports?: boolean
2384
2405
  wrappedContextRegExp?: RegExp
2385
2406
  exportsPresence?: string
2386
2407
  importExportsPresence?: string
2387
2408
  reexportExportsPresence?: string
2388
2409
  worker?: Array<string>
2389
2410
  overrideStrict?: string
2390
- importMeta?: boolean
2411
+ importMeta?: string
2391
2412
  /**
2392
2413
  * This option is experimental in Rspack only and subject to change or be removed anytime.
2393
2414
  * @experimental
Binary file
@@ -0,0 +1,6 @@
1
+ /**
2
+ * Whether the current environment supports color output (TTY, FORCE_COLOR, NO_COLOR, etc.).
3
+ * Used as the default for stats.colors when not explicitly set.
4
+ * @see https://github.com/web-infra-dev/rspack/issues/9353
5
+ */
6
+ export declare function isStatsColorSupported(): boolean;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rspack/browser",
3
- "version": "2.0.0-beta.3",
3
+ "version": "2.0.0-beta.5",
4
4
  "webpackVersion": "5.75.0",
5
5
  "license": "MIT",
6
6
  "description": "Rspack for running in the browser. This is still in early stage and may not follow the semver.",