@rspack/core 2.0.0-beta.4 → 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.
@@ -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
@@ -2864,6 +2864,11 @@ let unsupported = (name, issue)=>{
2864
2864
  query: match[2] ? match[2].replace(/\u200b(.)/g, '$1') : ''
2865
2865
  };
2866
2866
  });
2867
+ function isStatsColorSupported() {
2868
+ if ("u" < typeof process) return !1;
2869
+ let env = process.env ?? {}, argv = process.argv ?? [];
2870
+ return !('NO_COLOR' in env || argv.includes('--no-color')) && ('FORCE_COLOR' in env || argv.includes('--color') || 'win32' === process.platform || process.stdout?.isTTY && 'dumb' !== env.TERM || 'CI' in env);
2871
+ }
2867
2872
  function encodeVersion(version) {
2868
2873
  let [major, minor = 0, patch = 0] = version.split('-')[0].split('.').map((v)=>parseInt(v, 10));
2869
2874
  return Number.isNaN(major) || Number.isNaN(minor) || Number.isNaN(patch) ? null : major << 16 | minor << 8 | patch;
@@ -4418,11 +4423,12 @@ function getRawJavascriptParserOptions(parser) {
4418
4423
  dynamicImportPreload: parser.dynamicImportPreload?.toString(),
4419
4424
  dynamicImportPrefetch: parser.dynamicImportPrefetch?.toString(),
4420
4425
  dynamicImportFetchPriority: parser.dynamicImportFetchPriority,
4421
- importMeta: parser.importMeta,
4426
+ importMeta: 'boolean' == typeof parser.importMeta ? String(parser.importMeta) : parser.importMeta,
4422
4427
  url: parser.url?.toString(),
4423
4428
  exprContextCritical: parser.exprContextCritical,
4424
4429
  unknownContextCritical: parser.unknownContextCritical,
4425
4430
  wrappedContextCritical: parser.wrappedContextCritical,
4431
+ strictThisContextOnImports: parser.strictThisContextOnImports,
4426
4432
  wrappedContextRegExp: parser.wrappedContextRegExp,
4427
4433
  exportsPresence: !1 === parser.exportsPresence ? 'false' : parser.exportsPresence,
4428
4434
  importExportsPresence: !1 === parser.importExportsPresence ? 'false' : parser.importExportsPresence,
@@ -5220,13 +5226,11 @@ class SubresourceIntegrityPlugin extends NativeSubresourceIntegrityPlugin {
5220
5226
  }
5221
5227
  let src = '';
5222
5228
  if (isUrlSrc) {
5223
- if (!publicPath) return;
5229
+ if (!publicPath || '/' === publicPath || './' === publicPath) return;
5224
5230
  let protocolRelativePublicPath = publicPath.replace(HTTP_PROTOCOL_REGEX, ''), protocolRelativeTagSrc = tagSrc.replace(HTTP_PROTOCOL_REGEX, '');
5225
5231
  if (!protocolRelativeTagSrc.startsWith(protocolRelativePublicPath)) return;
5226
- {
5227
- let tagSrcWithScheme = `http:${protocolRelativeTagSrc}`;
5228
- src = relative(protocolRelativePublicPath.startsWith('//') ? `http:${protocolRelativePublicPath}` : protocolRelativePublicPath, decodeURIComponent(tagSrcWithScheme));
5229
- }
5232
+ let tagSrcWithScheme = `http:${protocolRelativeTagSrc}`;
5233
+ src = relative(protocolRelativePublicPath.startsWith('//') ? `http:${protocolRelativePublicPath}` : protocolRelativePublicPath, decodeURIComponent(tagSrcWithScheme));
5230
5234
  } else src = relative(publicPath, decodeURIComponent(tagSrc));
5231
5235
  tag.attributes.integrity = this.getIntegrityChecksumForAsset(src) || function(hashFuncNames, source) {
5232
5236
  let { createHash } = SubresourceIntegrityPlugin_require('node:crypto');
@@ -6471,7 +6475,8 @@ You can also more options via the 'target' option: 'browserslist' / 'browserslis
6471
6475
  targetProperties,
6472
6476
  mode: options.mode,
6473
6477
  uniqueName: options.output.uniqueName,
6474
- deferImport: options.experiments.deferImport
6478
+ deferImport: options.experiments.deferImport,
6479
+ outputModule: options.output.module
6475
6480
  }), applyOutputDefaults(options, {
6476
6481
  context: options.context,
6477
6482
  targetProperties,
@@ -6511,13 +6516,14 @@ You can also more options via the 'target' option: 'browserslist' / 'browserslis
6511
6516
  D(options, 'incremental', {}), 'object' == typeof options.incremental && (D(options.incremental, 'silent', !0), D(options.incremental, 'buildModuleGraph', !0), D(options.incremental, 'finishModules', !0), D(options.incremental, 'optimizeDependencies', !0), D(options.incremental, 'buildChunkGraph', !0), D(options.incremental, 'optimizeChunkModules', !0), D(options.incremental, 'moduleIds', !0), D(options.incremental, 'chunkIds', !0), D(options.incremental, 'modulesHashes', !0), D(options.incremental, 'modulesCodegen', !0), D(options.incremental, 'modulesRuntimeRequirements', !0), D(options.incremental, 'chunksRuntimeRequirements', !0), D(options.incremental, 'chunksHashes', !0), D(options.incremental, 'chunkAsset', !0), D(options.incremental, 'emitAssets', !0));
6512
6517
  }, applySnapshotDefaults = (_snapshot, _env)=>{}, applyCssGeneratorOptionsDefaults = (generatorOptions, { targetProperties })=>{
6513
6518
  D(generatorOptions, 'exportsOnly', !targetProperties || !1 === targetProperties.document), D(generatorOptions, 'esModule', !0);
6514
- }, applyModuleDefaults = (module, { asyncWebAssembly, targetProperties, mode, uniqueName, deferImport })=>{
6515
- assertNotNill(module.parser), assertNotNill(module.generator), F(module.parser, "asset", ()=>({})), assertNotNill(module.parser.asset), F(module.parser.asset, 'dataUrlCondition', ()=>({})), 'object' == typeof module.parser.asset.dataUrlCondition && D(module.parser.asset.dataUrlCondition, 'maxSize', 8096), F(module.parser, "javascript", ()=>({})), assertNotNill(module.parser.javascript), ((parserOptions, { deferImport })=>{
6516
- D(parserOptions, 'dynamicImportMode', 'lazy'), D(parserOptions, 'dynamicImportPrefetch', !1), D(parserOptions, 'dynamicImportPreload', !1), D(parserOptions, 'url', !0), D(parserOptions, 'exprContextCritical', !0), D(parserOptions, 'unknownContextCritical', !0), D(parserOptions, 'wrappedContextCritical', !1), D(parserOptions, 'wrappedContextRegExp', /.*/), D(parserOptions, 'exportsPresence', 'error'), D(parserOptions, 'requireAsExpression', !0), D(parserOptions, 'requireAlias', !1), D(parserOptions, 'requireDynamic', !0), D(parserOptions, 'requireResolve', !0), D(parserOptions, 'commonjs', !0), D(parserOptions, 'importDynamic', !0), D(parserOptions, 'worker', [
6519
+ }, applyModuleDefaults = (module, { asyncWebAssembly, targetProperties, mode, uniqueName, deferImport, outputModule })=>{
6520
+ assertNotNill(module.parser), assertNotNill(module.generator), F(module.parser, "asset", ()=>({})), assertNotNill(module.parser.asset), F(module.parser.asset, 'dataUrlCondition', ()=>({})), 'object' == typeof module.parser.asset.dataUrlCondition && D(module.parser.asset.dataUrlCondition, 'maxSize', 8096), F(module.parser, "javascript", ()=>({})), assertNotNill(module.parser.javascript), ((parserOptions, { deferImport, outputModule })=>{
6521
+ D(parserOptions, 'dynamicImportMode', 'lazy'), D(parserOptions, 'dynamicImportPrefetch', !1), D(parserOptions, 'dynamicImportPreload', !1), D(parserOptions, 'url', !0), D(parserOptions, 'exprContextCritical', !0), D(parserOptions, 'unknownContextCritical', !0), D(parserOptions, 'wrappedContextCritical', !1), D(parserOptions, 'strictThisContextOnImports', !1), D(parserOptions, 'wrappedContextRegExp', /.*/), D(parserOptions, 'exportsPresence', 'error'), D(parserOptions, 'requireAsExpression', !0), D(parserOptions, 'requireAlias', !1), D(parserOptions, 'requireDynamic', !0), D(parserOptions, 'requireResolve', !0), D(parserOptions, 'commonjs', !0), D(parserOptions, 'importDynamic', !0), D(parserOptions, 'worker', [
6517
6522
  '...'
6518
- ]), D(parserOptions, 'importMeta', !0), D(parserOptions, 'typeReexportsPresence', 'no-tolerant'), D(parserOptions, 'jsx', !1), D(parserOptions, 'deferImport', deferImport);
6523
+ ]), D(parserOptions, 'importMeta', !outputModule || 'preserve-unknown'), D(parserOptions, 'typeReexportsPresence', 'no-tolerant'), D(parserOptions, 'jsx', !1), D(parserOptions, 'deferImport', deferImport);
6519
6524
  })(module.parser.javascript, {
6520
- deferImport
6525
+ deferImport,
6526
+ outputModule
6521
6527
  }), F(module.parser, "json", ()=>({})), assertNotNill(module.parser.json), D(module.parser.json, 'exportsDepth', 'development' === mode ? 1 : Number.MAX_SAFE_INTEGER), F(module.generator, 'json', ()=>({})), assertNotNill(module.generator.json), D(module.generator.json, 'JSONParse', !0), F(module.parser, 'css', ()=>({})), assertNotNill(module.parser.css), D(module.parser.css, 'namedExports', !0), D(module.parser.css, 'url', !0), F(module.parser, 'css/auto', ()=>({})), assertNotNill(module.parser['css/auto']), D(module.parser['css/auto'], 'namedExports', !0), D(module.parser['css/auto'], 'url', !0), F(module.parser, 'css/module', ()=>({})), assertNotNill(module.parser['css/module']), D(module.parser['css/module'], 'namedExports', !0), D(module.parser['css/module'], 'url', !0), F(module.generator, 'css', ()=>({})), assertNotNill(module.generator.css), applyCssGeneratorOptionsDefaults(module.generator.css, {
6522
6528
  targetProperties
6523
6529
  }), F(module.generator, 'css/auto', ()=>({})), assertNotNill(module.generator['css/auto']), applyCssGeneratorOptionsDefaults(module.generator['css/auto'], {
@@ -6785,7 +6791,7 @@ You can also more options via the 'target' option: 'browserslist' / 'browserslis
6785
6791
  return output.wasmLoading && enabledWasmLoadingTypes.add(output.wasmLoading), output.workerWasmLoading && enabledWasmLoadingTypes.add(output.workerWasmLoading), forEachEntry((desc)=>{
6786
6792
  desc.wasmLoading && enabledWasmLoadingTypes.add(desc.wasmLoading);
6787
6793
  }), Array.from(enabledWasmLoadingTypes);
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));
6794
+ }), D(output, 'bundlerInfo', {}), 'object' == typeof output.bundlerInfo && (D(output.bundlerInfo, 'version', "2.0.0-beta.5"), D(output.bundlerInfo, 'bundler', 'rspack'), D(output.bundlerInfo, 'force', !output.library));
6789
6795
  }, applyExternalsPresetsDefaults = (externalsPresets, { targetProperties, buildHttp, outputModule })=>{
6790
6796
  let isUniversal = (key)=>!!(outputModule && targetProperties && null === targetProperties[key]);
6791
6797
  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')));
@@ -8039,7 +8045,7 @@ class MultiStats {
8039
8045
  obj.children = this.stats.map((stat, idx)=>{
8040
8046
  let obj = stat.toJson(childOptions.children[idx]), compilationName = stat.compilation.name;
8041
8047
  return obj.name = compilationName && makePathsRelative(childOptions.context, compilationName, stat.compilation.compiler.root), obj;
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(''));
8048
+ }), childOptions.version && (obj.rspackVersion = "2.0.0-beta.5", obj.version = "5.75.0"), childOptions.hash && (obj.hash = obj.children.map((j)=>j.hash).join(''));
8043
8049
  let mapError = (j, obj)=>({
8044
8050
  ...obj,
8045
8051
  compilerPath: obj.compilerPath ? `${j.name}.${obj.compilerPath}` : j.name
@@ -9298,7 +9304,7 @@ let iterateConfig = (config, options, fn)=>{
9298
9304
  object.hash = context.getStatsCompilation(compilation).hash;
9299
9305
  },
9300
9306
  version: (object)=>{
9301
- object.version = "5.75.0", object.rspackVersion = "2.0.0-beta.4";
9307
+ object.version = "5.75.0", object.rspackVersion = "2.0.0-beta.5";
9302
9308
  },
9303
9309
  env: (object, _compilation, _context, { _env })=>{
9304
9310
  object.env = _env;
@@ -9770,7 +9776,7 @@ let applyDefaults = (options, defaults)=>{
9770
9776
  chunksSort: ()=>!1,
9771
9777
  assetsSort: ()=>'!size',
9772
9778
  outputPath: OFF_FOR_TO_STRING,
9773
- colors: ()=>!1
9779
+ colors: ()=>isStatsColorSupported()
9774
9780
  }, normalizeFilter = (item)=>{
9775
9781
  if ('string' == typeof item) {
9776
9782
  let regExp = RegExp(`[\\\\/]${item.replace(/[-[\]{}()*+?.\\^$|]/g, '\\$&')}([\\\\/]|$|!|\\?)`);
@@ -10963,7 +10969,7 @@ class TraceHookPlugin {
10963
10969
  });
10964
10970
  }
10965
10971
  }
10966
- let CORE_VERSION = "2.0.0-beta.4", VFILES_BY_COMPILER = new WeakMap();
10972
+ let CORE_VERSION = "2.0.0-beta.5", VFILES_BY_COMPILER = new WeakMap();
10967
10973
  class VirtualModulesPlugin {
10968
10974
  #staticModules;
10969
10975
  #compiler;
@@ -11505,7 +11511,7 @@ class Compiler {
11505
11511
  }
11506
11512
  #getInstance(callback) {
11507
11513
  var output;
11508
- let coreVersion, expectedCoreVersion, mode, experiments, error = CORE_VERSION === binding_default().EXPECTED_RSPACK_CORE_VERSION || CORE_VERSION.includes('canary') ? null : Error((coreVersion = CORE_VERSION, expectedCoreVersion = binding_default().EXPECTED_RSPACK_CORE_VERSION, process.env.RSPACK_BINDING ? `Unmatched version @rspack/core@${coreVersion} and binding version.
11514
+ let coreVersion, expectedCoreVersion, statsOptions, mode, experiments, error = CORE_VERSION === binding_default().EXPECTED_RSPACK_CORE_VERSION || CORE_VERSION.includes('canary') ? null : Error((coreVersion = CORE_VERSION, expectedCoreVersion = binding_default().EXPECTED_RSPACK_CORE_VERSION, process.env.RSPACK_BINDING ? `Unmatched version @rspack/core@${coreVersion} and binding version.
11509
11515
 
11510
11516
  Help:
11511
11517
  Looks like you are using a custom binding (via environment variable 'RSPACK_BINDING=${process.env.RSPACK_BINDING}').
@@ -11576,7 +11582,7 @@ Help:
11576
11582
  }),
11577
11583
  optimization: options.optimization,
11578
11584
  stats: {
11579
- colors: !!function(options) {
11585
+ colors: void 0 === (statsOptions = function(options) {
11580
11586
  if ('boolean' == typeof options || 'string' == typeof options) return presetToOptions(options);
11581
11587
  if (!options) return {};
11582
11588
  let obj = {
@@ -11584,7 +11590,7 @@ Help:
11584
11590
  ...options
11585
11591
  };
11586
11592
  return delete obj.preset, obj;
11587
- }(options.stats).colors
11593
+ }(options.stats)).colors ? isStatsColorSupported() : !!statsOptions.colors
11588
11594
  },
11589
11595
  cache: options.cache || !1,
11590
11596
  experiments,
@@ -12747,7 +12753,7 @@ class CollectSharedEntryPlugin extends RspackBuiltinPlugin {
12747
12753
  super.apply(compiler), compiler.hooks.thisCompilation.tap('Collect shared entry', (compilation)=>{
12748
12754
  compilation.hooks.processAssets.tap({
12749
12755
  name: 'CollectSharedEntry',
12750
- stage: compiler.webpack.Compilation.PROCESS_ASSETS_STAGE_OPTIMIZE_INLINE
12756
+ stage: compiler.rspack.Compilation.PROCESS_ASSETS_STAGE_OPTIMIZE_INLINE
12751
12757
  }, ()=>{
12752
12758
  compilation.getAssets().forEach((asset)=>{
12753
12759
  asset.name === SHARE_ENTRY_ASSET && (this._collectedEntries = JSON.parse(asset.source.source().toString())), compilation.deleteAsset(asset.name);
@@ -12868,7 +12874,7 @@ class VirtualEntryPlugin {
12868
12874
  }).apply(compiler), compiler.hooks.thisCompilation.tap('RemoveVirtualEntryAsset', (compilation)=>{
12869
12875
  compilation.hooks.processAssets.tap({
12870
12876
  name: 'RemoveVirtualEntryAsset',
12871
- stage: compiler.webpack.Compilation.PROCESS_ASSETS_STAGE_OPTIMIZE
12877
+ stage: compiler.rspack.Compilation.PROCESS_ASSETS_STAGE_OPTIMIZE
12872
12878
  }, ()=>{
12873
12879
  try {
12874
12880
  let chunk = compilation.namedChunks.get(VIRTUAL_ENTRY_NAME);
@@ -12928,7 +12934,7 @@ class IndependentSharedPlugin {
12928
12934
  targetShared && item.forEach(([entry, version, globalName])=>{
12929
12935
  version === targetShared.version && (targetShared.fallback = entry, targetShared.fallbackName = globalName);
12930
12936
  });
12931
- }), compilation.updateAsset(filename, new compiler.webpack.sources.RawSource(JSON.stringify(statsContent)));
12937
+ }), compilation.updateAsset(filename, new compiler.rspack.sources.RawSource(JSON.stringify(statsContent)));
12932
12938
  };
12933
12939
  injectBuildAssetsIntoStatsOrManifest(statsFileName), injectBuildAssetsIntoStatsOrManifest(manifestFileName);
12934
12940
  });
@@ -13148,7 +13154,7 @@ function getDefaultEntryRuntime(paths, options, compiler, treeShakingShareFallba
13148
13154
  `const __module_federation_share_strategy__ = ${JSON.stringify(options.shareStrategy ?? 'version-first')}`,
13149
13155
  `const __module_federation_share_fallbacks__ = ${JSON.stringify(treeShakingShareFallbacks)}`,
13150
13156
  `const __module_federation_library_type__ = ${JSON.stringify(libraryType)}`,
13151
- compiler.webpack.Template.getFunctionContent(ModuleFederationPlugin_require('./moduleFederationDefaultRuntime.js').default)
13157
+ compiler.rspack.Template.getFunctionContent(ModuleFederationPlugin_require('./moduleFederationDefaultRuntime.js').default)
13152
13158
  ].join(';');
13153
13159
  return `@module-federation/runtime/rspack.js!=!data:text/javascript,${encodeURIComponent(content)}`;
13154
13160
  }
@@ -13247,7 +13253,7 @@ async function transform(source, options) {
13247
13253
  let _options = JSON.stringify(options || {});
13248
13254
  return binding_default().transform(source, _options);
13249
13255
  }
13250
- let exports_rspackVersion = "2.0.0-beta.4", exports_version = "5.75.0", exports_WebpackError = Error, exports_config = {
13256
+ let exports_rspackVersion = "2.0.0-beta.5", exports_version = "5.75.0", exports_WebpackError = Error, exports_config = {
13251
13257
  getNormalizedRspackOptions: getNormalizedRspackOptions,
13252
13258
  applyRspackOptionsDefaults: applyRspackOptionsDefaults,
13253
13259
  getNormalizedWebpackOptions: getNormalizedRspackOptions,
@@ -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/core",
3
- "version": "2.0.0-beta.4",
3
+ "version": "2.0.0-beta.5",
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.4"
61
+ "@rspack/binding": "2.0.0-beta.5"
62
62
  },
63
63
  "peerDependencies": {
64
64
  "@module-federation/runtime-tools": "^0.24.1 || ^2.0.0",