From 0aebe887e9a1a979329f2fb18252b36f2eca80f6 Mon Sep 17 00:00:00 2001 From: LingyuCoder Date: Wed, 7 Jan 2026 15:13:41 +0800 Subject: [PATCH 1/2] feat: remove rspackFuture and move bundlerInfo to output --- crates/node_binding/napi-binding.d.ts | 5 -- crates/rspack/src/builder/mod.rs | 10 +-- .../snapshots/defaults__default_options.snap | 1 - .../src/raw_options/raw_experiments/mod.rs | 4 - .../raw_experiments/raw_rspack_future.rs | 13 ---- .../src/options/experiments/mod.rs | 5 -- .../rspack-test-tools/src/case/builtin.ts | 8 +- packages/rspack-test-tools/src/case/cache.ts | 8 +- packages/rspack-test-tools/src/case/config.ts | 8 +- .../rspack-test-tools/src/case/defaults.ts | 3 +- .../rspack-test-tools/src/case/diagnostic.ts | 8 +- packages/rspack-test-tools/src/case/error.ts | 10 +-- .../rspack-test-tools/src/case/esm-output.ts | 8 +- packages/rspack-test-tools/src/case/hash.ts | 8 +- packages/rspack-test-tools/src/case/hook.ts | 8 +- packages/rspack-test-tools/src/case/hot.ts | 8 +- packages/rspack-test-tools/src/case/normal.ts | 8 +- .../rspack-test-tools/src/case/stats-api.ts | 6 +- .../src/case/stats-output.ts | 18 ++--- packages/rspack-test-tools/src/case/watch.ts | 7 +- packages/rspack/etc/core.api.md | 24 +++--- .../scripts/check-documentation-coverage.ts | 1 - packages/rspack/src/config/defaults.ts | 33 +++----- packages/rspack/src/config/normalization.ts | 5 +- packages/rspack/src/config/types.ts | 38 ++++----- packages/rspack/src/rspackOptionsApply.ts | 6 +- .../sri/runtime-requirement/rspack.config.js | 9 +-- .../unique-id/all/rspack.config.js | 10 +-- .../unique-id/array/rspack.config.js | 10 +-- .../unique-id/auto/rspack.config.js | 7 -- .../unique-id/issue-11126/rspack.config.js | 14 ++-- .../configCases/version/all/rspack.config.js | 10 +-- .../version/array/rspack.config.js | 10 +-- .../configCases/version/auto/rspack.config.js | 9 +-- .../rspack-test/defaultsCases/default/base.js | 12 ++- .../defaultsCases/library/library.js | 72 ++++++++--------- .../defaultsCases/library/name-placeholder.js | 74 +++++++++--------- .../library/name-root-placeholder.js | 78 +++++++++---------- .../defaultsCases/library/placeholder.js | 72 ++++++++--------- .../defaultsCases/library/root-placeholder.js | 76 +++++++++--------- .../rspack-test/statsAPICases/bundler-info.js | 12 ++- website/components/DeprecationTable.tsx | 22 +----- .../en/api/runtime-api/module-variables.mdx | 6 +- website/docs/en/config/experiments.mdx | 43 ---------- website/docs/en/config/output.mdx | 37 +++++++++ website/docs/en/misc/planning/future.mdx | 4 - .../zh/api/runtime-api/module-variables.mdx | 6 +- website/docs/zh/config/experiments.mdx | 44 ----------- website/docs/zh/config/output.mdx | 37 +++++++++ website/docs/zh/misc/planning/future.mdx | 4 - website/project-words.txt | 3 - 51 files changed, 395 insertions(+), 547 deletions(-) delete mode 100644 crates/rspack_binding_api/src/raw_options/raw_experiments/raw_rspack_future.rs diff --git a/crates/node_binding/napi-binding.d.ts b/crates/node_binding/napi-binding.d.ts index 5a42f71f69d1..7d040ce5c1a1 100644 --- a/crates/node_binding/napi-binding.d.ts +++ b/crates/node_binding/napi-binding.d.ts @@ -2132,7 +2132,6 @@ export interface RawExperimentCacheOptionsPersistent { export interface RawExperiments { topLevelAwait: boolean incremental?: false | { [key: string]: boolean } -rspackFuture?: RawRspackFuture cache: boolean | { type: "persistent" } & RawExperimentCacheOptionsPersistent | { type: "memory" } useInputFileSystem?: false | Array css?: boolean @@ -2781,10 +2780,6 @@ export interface RawRslibPluginOptions { forceNodeShims?: boolean } -export interface RawRspackFuture { - -} - export interface RawRstestPluginOptions { injectModulePathName: boolean importMetaPathName: boolean diff --git a/crates/rspack/src/builder/mod.rs b/crates/rspack/src/builder/mod.rs index 6203d7f9efb7..32f53870454b 100644 --- a/crates/rspack/src/builder/mod.rs +++ b/crates/rspack/src/builder/mod.rs @@ -49,8 +49,8 @@ use rspack_core::{ MangleExportsOption, Mode, ModuleNoParseRules, ModuleOptions, ModuleRule, ModuleRuleEffect, ModuleType, NodeDirnameOption, NodeFilenameOption, NodeGlobalOption, NodeOption, Optimization, OutputOptions, ParseOption, ParserOptions, ParserOptionsMap, PathInfo, PublicPath, Resolve, - RspackFuture, RuleSetCondition, RuleSetLogicalConditions, SideEffectOption, StatsOptions, - TrustedTypes, UnsafeCachePredicate, UsedExportsOption, WasmLoading, WasmLoadingType, + RuleSetCondition, RuleSetLogicalConditions, SideEffectOption, StatsOptions, TrustedTypes, + UnsafeCachePredicate, UsedExportsOption, WasmLoading, WasmLoadingType, incremental::{IncrementalOptions, IncrementalPasses}, }; use rspack_error::{Error, Result}; @@ -3686,8 +3686,6 @@ pub struct ExperimentsBuilder { incremental: Option, /// Whether to enable top level await. top_level_await: Option, - /// Rspack future. - rspack_future: Option, /// Cache options. cache: Option, /// Whether to enable output module. @@ -3706,7 +3704,6 @@ impl From for ExperimentsBuilder { ExperimentsBuilder { incremental: Some(value.incremental), top_level_await: Some(value.top_level_await), - rspack_future: Some(value.rspack_future), cache: Some(value.cache), output_module: None, future_defaults: None, @@ -3721,7 +3718,6 @@ impl From<&mut ExperimentsBuilder> for ExperimentsBuilder { ExperimentsBuilder { incremental: value.incremental.take(), top_level_await: value.top_level_await.take(), - rspack_future: value.rspack_future.take(), cache: value.cache.take(), output_module: value.output_module.take(), future_defaults: value.future_defaults.take(), @@ -3796,7 +3792,6 @@ impl ExperimentsBuilder { ExperimentCacheOptions::Disabled } }); - let rspack_future = d!(self.rspack_future.take(), RspackFuture {}); // Builder specific let future_defaults = w!(self.future_defaults, false); @@ -3807,7 +3802,6 @@ impl ExperimentsBuilder { Ok(Experiments { incremental, top_level_await, - rspack_future, cache, css: d!(self.css, false), lazy_barrel: true, diff --git a/crates/rspack/tests/snapshots/defaults__default_options.snap b/crates/rspack/tests/snapshots/defaults__default_options.snap index 86ca9041ff72..0bb4b26724f5 100644 --- a/crates/rspack/tests/snapshots/defaults__default_options.snap +++ b/crates/rspack/tests/snapshots/defaults__default_options.snap @@ -1513,7 +1513,6 @@ CompilerOptions { ), }, top_level_await: true, - rspack_future: RspackFuture, cache: Disabled, css: false, lazy_barrel: true, diff --git a/crates/rspack_binding_api/src/raw_options/raw_experiments/mod.rs b/crates/rspack_binding_api/src/raw_options/raw_experiments/mod.rs index 06ba98c38d0d..c961bbd2b51a 100644 --- a/crates/rspack_binding_api/src/raw_options/raw_experiments/mod.rs +++ b/crates/rspack_binding_api/src/raw_options/raw_experiments/mod.rs @@ -1,11 +1,9 @@ mod raw_cache; mod raw_incremental; -mod raw_rspack_future; use napi_derive::napi; use raw_cache::{RawExperimentCacheOptions, normalize_raw_experiment_cache_options}; use raw_incremental::RawIncremental; -use raw_rspack_future::RawRspackFuture; use rspack_core::{Experiments, incremental::IncrementalOptions}; use rspack_regex::RspackRegex; @@ -17,7 +15,6 @@ pub struct RawExperiments { pub top_level_await: bool, #[napi(ts_type = "false | { [key: string]: boolean }")] pub incremental: Option>, - pub rspack_future: Option, #[napi( ts_type = r#"boolean | { type: "persistent" } & RawExperimentCacheOptionsPersistent | { type: "memory" }"# )] @@ -40,7 +37,6 @@ impl From for Experiments { None => IncrementalOptions::empty_passes(), }, top_level_await: value.top_level_await, - rspack_future: value.rspack_future.unwrap_or_default().into(), cache: normalize_raw_experiment_cache_options(value.cache), css: value.css.unwrap_or(false), lazy_barrel: value.lazy_barrel, diff --git a/crates/rspack_binding_api/src/raw_options/raw_experiments/raw_rspack_future.rs b/crates/rspack_binding_api/src/raw_options/raw_experiments/raw_rspack_future.rs deleted file mode 100644 index 2b2027c1d27b..000000000000 --- a/crates/rspack_binding_api/src/raw_options/raw_experiments/raw_rspack_future.rs +++ /dev/null @@ -1,13 +0,0 @@ -use napi_derive::napi; -use rspack_core::RspackFuture; - -#[allow(clippy::empty_structs_with_brackets)] -#[derive(Debug, Default)] -#[napi(object)] -pub struct RawRspackFuture {} - -impl From for RspackFuture { - fn from(_value: RawRspackFuture) -> Self { - Self {} - } -} diff --git a/crates/rspack_core/src/options/experiments/mod.rs b/crates/rspack_core/src/options/experiments/mod.rs index 60d18c7796a0..fa3fa0d65d24 100644 --- a/crates/rspack_core/src/options/experiments/mod.rs +++ b/crates/rspack_core/src/options/experiments/mod.rs @@ -11,13 +11,8 @@ use crate::incremental::IncrementalOptions; pub struct Experiments { pub incremental: IncrementalOptions, pub top_level_await: bool, - pub rspack_future: RspackFuture, pub cache: ExperimentCacheOptions, pub css: bool, pub lazy_barrel: bool, pub defer_import: bool, } - -#[allow(clippy::empty_structs_with_brackets)] -#[derive(Debug)] -pub struct RspackFuture {} diff --git a/packages/rspack-test-tools/src/case/builtin.ts b/packages/rspack-test-tools/src/case/builtin.ts index c45e1ecd442b..bf5405886271 100644 --- a/packages/rspack-test-tools/src/case/builtin.ts +++ b/packages/rspack-test-tools/src/case/builtin.ts @@ -76,6 +76,9 @@ export function defaultOptions(context: ITestContext): RspackOptions { webassemblyModuleFilename: '[hash].module.wasm', workerChunkLoading: 'import-scripts', workerWasmLoading: 'fetch', + bundlerInfo: { + force: false, + }, }, module: { rules: [ @@ -144,11 +147,6 @@ export function defaultOptions(context: ITestContext): RspackOptions { experiments: { css: true, futureDefaults: true, - rspackFuture: { - bundlerInfo: { - force: false, - }, - }, }, devtool: false, context: context.getSource(), diff --git a/packages/rspack-test-tools/src/case/cache.ts b/packages/rspack-test-tools/src/case/cache.ts index 64f964a0edbc..fe0539b3a922 100644 --- a/packages/rspack-test-tools/src/case/cache.ts +++ b/packages/rspack-test-tools/src/case/cache.ts @@ -122,6 +122,9 @@ async function generateOptions( chunkFilename: '[name].chunk.[fullhash].js', publicPath: 'https://test.cases/path/', library: { type: 'commonjs2' }, + bundlerInfo: { + force: false, + }, }, optimization: { moduleIds: 'named', @@ -130,11 +133,6 @@ async function generateOptions( target, experiments: { css: true, - rspackFuture: { - bundlerInfo: { - force: false, - }, - }, }, } as RspackOptions; diff --git a/packages/rspack-test-tools/src/case/config.ts b/packages/rspack-test-tools/src/case/config.ts index ea124d10203c..62d79326a65d 100644 --- a/packages/rspack-test-tools/src/case/config.ts +++ b/packages/rspack-test-tools/src/case/config.ts @@ -91,17 +91,15 @@ export function defaultOptions( cache: false, output: { path: context.getDist(), + bundlerInfo: { + force: false, + }, }, optimization: { minimize: false, }, experiments: { css: true, - rspackFuture: { - bundlerInfo: { - force: false, - }, - }, }, }; } diff --git a/packages/rspack-test-tools/src/case/defaults.ts b/packages/rspack-test-tools/src/case/defaults.ts index 7ca318209fd5..0100f2b93935 100644 --- a/packages/rspack-test-tools/src/case/defaults.ts +++ b/packages/rspack-test-tools/src/case/defaults.ts @@ -42,8 +42,7 @@ export function getRspackDefaultConfig( const normalizedConfig = getNormalizedWebpackOptions(config); applyWebpackOptionsDefaults(normalizedConfig); // make snapshot stable - (normalizedConfig as any).experiments.rspackFuture.bundlerInfo.version = - '$version$'; + (normalizedConfig as any).output.bundlerInfo.version = '$version$'; process.chdir(CURRENT_CWD); return normalizedConfig; } diff --git a/packages/rspack-test-tools/src/case/diagnostic.ts b/packages/rspack-test-tools/src/case/diagnostic.ts index 21b6113f1fa1..57a7347d6a8f 100644 --- a/packages/rspack-test-tools/src/case/diagnostic.ts +++ b/packages/rspack-test-tools/src/case/diagnostic.ts @@ -86,14 +86,12 @@ function defaultOptions(context: ITestContext): RspackOptions { }, output: { path: context.getDist(), + bundlerInfo: { + force: false, + }, }, experiments: { css: true, - rspackFuture: { - bundlerInfo: { - force: false, - }, - }, }, } as RspackOptions; } diff --git a/packages/rspack-test-tools/src/case/error.ts b/packages/rspack-test-tools/src/case/error.ts index 6f8ed8a79e0f..15927cfe3a49 100644 --- a/packages/rspack-test-tools/src/case/error.ts +++ b/packages/rspack-test-tools/src/case/error.ts @@ -85,13 +85,13 @@ function options( moduleIds: 'named', chunkIds: 'named', }, + otuput: { + bundlerInfo: { + force: false, + }, + }, experiments: { css: true, - rspackFuture: { - bundlerInfo: { - force: false, - }, - }, }, } as RspackOptions; if (typeof custom === 'function') { diff --git a/packages/rspack-test-tools/src/case/esm-output.ts b/packages/rspack-test-tools/src/case/esm-output.ts index 15f4ccd8862d..4dfa5d22d11d 100644 --- a/packages/rspack-test-tools/src/case/esm-output.ts +++ b/packages/rspack-test-tools/src/case/esm-output.ts @@ -113,6 +113,9 @@ const defaultOptions = ( filename: '[name].mjs', pathinfo: true, module: true, + bundlerInfo: { + force: false, + }, }, bail: true, optimization: { @@ -128,11 +131,6 @@ const defaultOptions = ( plugins: [new rspack.experiments.EsmLibraryPlugin()], experiments: { css: true, - rspackFuture: { - bundlerInfo: { - force: false, - }, - }, outputModule: true, }, }); diff --git a/packages/rspack-test-tools/src/case/hash.ts b/packages/rspack-test-tools/src/case/hash.ts index fb9cc2c37049..4c6451303022 100644 --- a/packages/rspack-test-tools/src/case/hash.ts +++ b/packages/rspack-test-tools/src/case/hash.ts @@ -65,14 +65,12 @@ function defaultOptions(index: number, context: ITestContext): RspackOptions { context: context.getSource(), output: { path: context.getDist(), + bundlerInfo: { + force: false, + }, }, experiments: { css: true, - rspackFuture: { - bundlerInfo: { - force: false, - }, - }, }, }; } diff --git a/packages/rspack-test-tools/src/case/hook.ts b/packages/rspack-test-tools/src/case/hook.ts index 613280d32648..9b44f7c34f4d 100644 --- a/packages/rspack-test-tools/src/case/hook.ts +++ b/packages/rspack-test-tools/src/case/hook.ts @@ -264,17 +264,15 @@ function defaultOptions( entry: './hook', output: { path: context.getDist(), + bundlerInfo: { + force: false, + }, }, optimization: { minimize: false, }, experiments: { css: true, - rspackFuture: { - bundlerInfo: { - force: false, - }, - }, }, } as RspackOptions; if (custom) { diff --git a/packages/rspack-test-tools/src/case/hot.ts b/packages/rspack-test-tools/src/case/hot.ts index 2f57d4a5b6bf..91bb55745e93 100644 --- a/packages/rspack-test-tools/src/case/hot.ts +++ b/packages/rspack-test-tools/src/case/hot.ts @@ -138,6 +138,9 @@ function defaultOptions(context: ITestContext, target: TTarget) { chunkFilename: '[name].chunk.[fullhash].js', publicPath: 'https://test.cases/path/', library: { type: 'commonjs2' }, + bundlerInfo: { + force: false, + }, }, optimization: { moduleIds: 'named', @@ -147,11 +150,6 @@ function defaultOptions(context: ITestContext, target: TTarget) { css: true, // test incremental: "safe" here, we test default incremental in Incremental-*.test.js incremental: 'safe', - rspackFuture: { - bundlerInfo: { - force: false, - }, - }, }, } as RspackOptions; diff --git a/packages/rspack-test-tools/src/case/normal.ts b/packages/rspack-test-tools/src/case/normal.ts index c85a604a003b..7a038d3e5b5b 100644 --- a/packages/rspack-test-tools/src/case/normal.ts +++ b/packages/rspack-test-tools/src/case/normal.ts @@ -170,6 +170,9 @@ function defaultOptions( pathinfo: 'verbose', path: context.getDist(), filename: compilerOptions?.module ? 'bundle.mjs' : 'bundle.js', + bundlerInfo: { + force: false, + }, }, resolve: { modules: ['web_modules', 'node_modules'], @@ -221,11 +224,6 @@ function defaultOptions( }), experiments: { css: false, - rspackFuture: { - bundlerInfo: { - force: false, - }, - }, asyncWebAssembly: true, topLevelAwait: true, // CHANGE: rspack does not support `backCompat` yet. diff --git a/packages/rspack-test-tools/src/case/stats-api.ts b/packages/rspack-test-tools/src/case/stats-api.ts index 407b20a80c54..21f838eb0257 100644 --- a/packages/rspack-test-tools/src/case/stats-api.ts +++ b/packages/rspack-test-tools/src/case/stats-api.ts @@ -74,9 +74,9 @@ function options( const res = (custom?.(context) || {}) as RspackOptions; res.experiments ??= {}; res.experiments!.css ??= true; - res.experiments!.rspackFuture ??= {}; - res.experiments!.rspackFuture!.bundlerInfo ??= {}; - res.experiments!.rspackFuture!.bundlerInfo!.force ??= false; + res.output ??= {}; + res.output!.bundlerInfo ??= {}; + res.output!.bundlerInfo!.force ??= false; if (!global.printLogger) { res.infrastructureLogging = { level: 'error', diff --git a/packages/rspack-test-tools/src/case/stats-output.ts b/packages/rspack-test-tools/src/case/stats-output.ts index 7fb75eb637c0..6c863816fc6f 100644 --- a/packages/rspack-test-tools/src/case/stats-output.ts +++ b/packages/rspack-test-tools/src/case/stats-output.ts @@ -72,13 +72,13 @@ function defaultOptions(index: number, context: ITestContext): RspackOptions { fs.existsSync(path.join(context.getSource(), 'webpack.config.js')) ) { return { + output: { + bundlerInfo: { + force: false, + }, + }, experiments: { css: true, - rspackFuture: { - bundlerInfo: { - force: false, - }, - }, }, } as RspackOptions; } @@ -89,17 +89,15 @@ function defaultOptions(index: number, context: ITestContext): RspackOptions { output: { filename: 'bundle.js', path: context.getDist(), + bundlerInfo: { + force: false, + }, }, optimization: { minimize: false, }, experiments: { css: true, - rspackFuture: { - bundlerInfo: { - force: false, - }, - }, }, } as RspackOptions; } diff --git a/packages/rspack-test-tools/src/case/watch.ts b/packages/rspack-test-tools/src/case/watch.ts index d4e2f32ef521..071149ae4fec 100644 --- a/packages/rspack-test-tools/src/case/watch.ts +++ b/packages/rspack-test-tools/src/case/watch.ts @@ -365,10 +365,9 @@ function overrideOptions( (options as RspackOptions).experiments!.nativeWatcher ??= true; } - (options as RspackOptions).experiments!.rspackFuture ??= {}; - (options as RspackOptions).experiments!.rspackFuture!.bundlerInfo ??= {}; - (options as RspackOptions).experiments!.rspackFuture!.bundlerInfo!.force ??= - false; + (options as RspackOptions).output ??= {}; + (options as RspackOptions).output!.bundlerInfo ??= {}; + (options as RspackOptions).output!.bundlerInfo!.force ??= false; // test incremental: "safe" here, we test default incremental in Incremental-*.test.js (options as RspackOptions).experiments!.incremental ??= 'safe'; diff --git a/packages/rspack/etc/core.api.md b/packages/rspack/etc/core.api.md index 7e25d28c9b1b..f5660ef9ec45 100644 --- a/packages/rspack/etc/core.api.md +++ b/packages/rspack/etc/core.api.md @@ -521,6 +521,13 @@ type BufferEncodingOption = 'buffer' | { encoding: 'buffer'; }; +// @public +export type BundlerInfoOptions = { + version?: string; + bundler?: string; + force?: boolean | ('version' | 'uniqueId')[]; +}; + // @public (undocumented) type ByPass = (req: Request_2, res: Response_2, proxyConfig: ProxyConfigArrayItem) => any; @@ -2443,7 +2450,6 @@ export type Experiments = { layers?: boolean; incremental?: IncrementalPresets | Incremental; futureDefaults?: boolean; - rspackFuture?: RspackFutureOptions; buildHttp?: HttpUriOptions; parallelLoader?: boolean; useInputFileSystem?: UseInputFileSystem; @@ -2532,8 +2538,6 @@ export interface ExperimentsNormalized { // (undocumented) parallelLoader?: boolean; // (undocumented) - rspackFuture?: RspackFutureOptions; - // (undocumented) topLevelAwait?: boolean; // (undocumented) typeReexportsPresence?: boolean; @@ -5619,6 +5623,7 @@ export type Output = { charset?: boolean; environment?: Environment; compareBeforeEmit?: boolean; + bundlerInfo?: BundlerInfoOptions; }; // @public (undocumented) @@ -5667,6 +5672,8 @@ export interface OutputNormalized { // (undocumented) asyncChunks?: boolean; // (undocumented) + bundlerInfo?: BundlerInfoOptions; + // (undocumented) charset?: boolean; // (undocumented) chunkFilename?: ChunkFilename; @@ -6902,7 +6909,7 @@ declare namespace rspackExports { OptimizationSplitChunksOptions, Optimization, ExperimentCacheOptions, - RspackFutureOptions, + BundlerInfoOptions, LazyCompilationOptions, Incremental, IncrementalPresets, @@ -6923,15 +6930,6 @@ declare namespace rspackExports { } } -// @public -export type RspackFutureOptions = { - bundlerInfo?: { - version?: string; - bundler?: string; - force?: boolean | ('version' | 'uniqueId')[]; - }; -}; - // @public (undocumented) export type RspackOptions = { name?: Name; diff --git a/packages/rspack/scripts/check-documentation-coverage.ts b/packages/rspack/scripts/check-documentation-coverage.ts index 79c6afad8721..cabaa7ea2665 100644 --- a/packages/rspack/scripts/check-documentation-coverage.ts +++ b/packages/rspack/scripts/check-documentation-coverage.ts @@ -230,7 +230,6 @@ function checkConfigsDocumentationCoverage() { // "resolveLoader", // "module.parser", // "module.generator", - // "experiments.rspackFuture", // "experiments.incremental", // "output.library.amd", // "output.library.commonjs", diff --git a/packages/rspack/src/config/defaults.ts b/packages/rspack/src/config/defaults.ts index 64de108acf86..897a65628459 100644 --- a/packages/rspack/src/config/defaults.ts +++ b/packages/rspack/src/config/defaults.ts @@ -46,7 +46,6 @@ import type { Optimization, Performance, ResolveOptions, - RspackFutureOptions, RuleSetRules, SnapshotOptions, } from './types'; @@ -132,11 +131,6 @@ export const applyRspackOptionsDefaults = ( outputModule: options.experiments.outputModule, entry: options.entry, }); - // bundlerInfo is affected by outputDefaults so must be executed after outputDefaults - applybundlerInfoDefaults( - options.experiments.rspackFuture, - options.output.library, - ); applyExternalsPresetsDefaults(options.externalsPresets, { targetProperties, @@ -264,9 +258,6 @@ const applyExperimentsDefaults = ( D(experiments.incremental, 'chunksRender', true); D(experiments.incremental, 'emitAssets', true); } - // IGNORE(experiments.rspackFuture): Rspack specific configuration - D(experiments, 'rspackFuture', {}); - // rspackFuture.bundlerInfo default value is applied after applyDefaults // IGNORE(experiments.parallelLoader): Rspack specific configuration for parallel loader execution D(experiments, 'parallelLoader', false); @@ -288,21 +279,6 @@ const applyExperimentsDefaults = ( D(experiments, 'lazyBarrel', true); }; -const applybundlerInfoDefaults = ( - rspackFuture?: RspackFutureOptions, - library?: Library, -) => { - if (typeof rspackFuture === 'object') { - D(rspackFuture, 'bundlerInfo', {}); - if (typeof rspackFuture.bundlerInfo === 'object') { - D(rspackFuture.bundlerInfo, 'version', RSPACK_VERSION); - D(rspackFuture.bundlerInfo, 'bundler', 'rspack'); - // don't inject for library mode - D(rspackFuture.bundlerInfo, 'force', !library); - } - } -}; - const applySnapshotDefaults = ( _snapshot: SnapshotOptions, _env: { production: boolean }, @@ -925,6 +901,15 @@ const applyOutputDefaults = ( }); return Array.from(enabledWasmLoadingTypes); }); + + // IGNORE(output.bundlerInfo): rspack specific + D(output, 'bundlerInfo', {}); + if (typeof output.bundlerInfo === 'object') { + D(output.bundlerInfo, 'version', RSPACK_VERSION); + D(output.bundlerInfo, 'bundler', 'rspack'); + // don't inject for library mode + D(output.bundlerInfo, 'force', !output.library); + } }; const applyExternalsPresetsDefaults = ( diff --git a/packages/rspack/src/config/normalization.ts b/packages/rspack/src/config/normalization.ts index ba0ff22b7c44..e3cad95ab798 100644 --- a/packages/rspack/src/config/normalization.ts +++ b/packages/rspack/src/config/normalization.ts @@ -17,6 +17,7 @@ import type { Amd, AssetModuleFilename, Bail, + BundlerInfoOptions, CacheOptions, ChunkFilename, ChunkLoading, @@ -74,7 +75,6 @@ import type { Profile, PublicPath, Resolve, - RspackFutureOptions, RspackOptions, RuleSetRules, ScriptType, @@ -255,6 +255,7 @@ export const getNormalizedRspackOptions = ( charset: output.charset, environment: cloneObject(output.environment), compareBeforeEmit: output.compareBeforeEmit, + bundlerInfo: output.bundlerInfo, }; }), resolve: nestedConfig(config.resolve, (resolve) => ({ @@ -652,6 +653,7 @@ export interface OutputNormalized { charset?: boolean; chunkLoadTimeout?: number; compareBeforeEmit?: boolean; + bundlerInfo?: BundlerInfoOptions; } export interface ModuleOptionsNormalized { @@ -701,7 +703,6 @@ export interface ExperimentsNormalized { layers?: boolean; incremental?: false | Incremental; futureDefaults?: boolean; - rspackFuture?: RspackFutureOptions; buildHttp?: HttpUriPluginOptions; parallelLoader?: boolean; useInputFileSystem?: false | RegExp[]; diff --git a/packages/rspack/src/config/types.ts b/packages/rspack/src/config/types.ts index 6c7c79826ca5..c6a82b63a988 100644 --- a/packages/rspack/src/config/types.ts +++ b/packages/rspack/src/config/types.ts @@ -712,6 +712,11 @@ export type Output = { * Check if to be emitted file already exists and have the same content before writing to output filesystem. */ compareBeforeEmit?: boolean; + + /** + * Information about the bundler. + */ + bundlerInfo?: BundlerInfoOptions; }; //#endregion @@ -2598,26 +2603,21 @@ export type ExperimentCacheOptions = }; /** - * Options for future Rspack features. + * Information about the bundler. */ -export type RspackFutureOptions = { +export type BundlerInfoOptions = { /** - * Information about the bundler. + * Version of the bundler. */ - bundlerInfo?: { - /** - * Version of the bundler. - */ - version?: string; - /** - * Name of the bundler. - */ - bundler?: string; - /** - * Force specific features. - */ - force?: boolean | ('version' | 'uniqueId')[]; - }; + version?: string; + /** + * Name of the bundler. + */ + bundler?: string; + /** + * Force specific features. + */ + force?: boolean | ('version' | 'uniqueId')[]; }; /** @@ -2821,10 +2821,6 @@ export type Experiments = { * @default false */ futureDefaults?: boolean; - /** - * Enable future Rspack features default options. - */ - rspackFuture?: RspackFutureOptions; /** * Enable loading of modules via HTTP/HTTPS requests. * @default false diff --git a/packages/rspack/src/rspackOptionsApply.ts b/packages/rspack/src/rspackOptionsApply.ts index 737b5bc0e51d..55f31ea8e17b 100644 --- a/packages/rspack/src/rspackOptionsApply.ts +++ b/packages/rspack/src/rspackOptionsApply.ts @@ -242,10 +242,8 @@ export class RspackOptionsApply { new RuntimePlugin().apply(compiler); - if (options.experiments.rspackFuture!.bundlerInfo) { - new BundlerInfoRspackPlugin( - options.experiments.rspackFuture!.bundlerInfo, - ).apply(compiler); + if (options.output.bundlerInfo) { + new BundlerInfoRspackPlugin(options.output.bundlerInfo).apply(compiler); } new InferAsyncModulesPlugin().apply(compiler); diff --git a/tests/rspack-test/configCases/sri/runtime-requirement/rspack.config.js b/tests/rspack-test/configCases/sri/runtime-requirement/rspack.config.js index 17412cb6c197..e57cf49c50c6 100644 --- a/tests/rspack-test/configCases/sri/runtime-requirement/rspack.config.js +++ b/tests/rspack-test/configCases/sri/runtime-requirement/rspack.config.js @@ -7,14 +7,7 @@ module.exports = { main: "./index.js" }, output: { - crossOriginLoading: "anonymous" + crossOriginLoading: "anonymous", }, plugins: [new SubresourceIntegrityPlugin()], - experiments: { - rspackFuture: { - bundlerInfo: { - force: false - } - } - } }; diff --git a/tests/rspack-test/configCases/unique-id/all/rspack.config.js b/tests/rspack-test/configCases/unique-id/all/rspack.config.js index 475f5095f91c..c5896e7a831e 100644 --- a/tests/rspack-test/configCases/unique-id/all/rspack.config.js +++ b/tests/rspack-test/configCases/unique-id/all/rspack.config.js @@ -1,10 +1,8 @@ /** @type {import("@rspack/core").Configuration} */ module.exports = { - experiments: { - rspackFuture: { - bundlerInfo: { - force: true - } + output: { + bundlerInfo: { + force: true } - } + }, }; diff --git a/tests/rspack-test/configCases/unique-id/array/rspack.config.js b/tests/rspack-test/configCases/unique-id/array/rspack.config.js index 6756dc9cc08d..02c94a0910e2 100644 --- a/tests/rspack-test/configCases/unique-id/array/rspack.config.js +++ b/tests/rspack-test/configCases/unique-id/array/rspack.config.js @@ -1,10 +1,8 @@ /** @type {import("@rspack/core").Configuration} */ module.exports = { - experiments: { - rspackFuture: { - bundlerInfo: { - force: ["uniqueId"] - } + output: { + bundlerInfo: { + force: ["uniqueId"] } - } + }, }; diff --git a/tests/rspack-test/configCases/unique-id/auto/rspack.config.js b/tests/rspack-test/configCases/unique-id/auto/rspack.config.js index 2e4410dffd38..b9ea673a817c 100644 --- a/tests/rspack-test/configCases/unique-id/auto/rspack.config.js +++ b/tests/rspack-test/configCases/unique-id/auto/rspack.config.js @@ -1,10 +1,3 @@ /** @type {import("@rspack/core").Configuration} */ module.exports = { - experiments: { - rspackFuture: { - bundlerInfo: { - force: false - } - } - } }; diff --git a/tests/rspack-test/configCases/unique-id/issue-11126/rspack.config.js b/tests/rspack-test/configCases/unique-id/issue-11126/rspack.config.js index 9f9dd0c74864..66b9d0376bc7 100644 --- a/tests/rspack-test/configCases/unique-id/issue-11126/rspack.config.js +++ b/tests/rspack-test/configCases/unique-id/issue-11126/rspack.config.js @@ -1,20 +1,18 @@ /** @type {import("@rspack/core").Configuration} */ module.exports = { + output: { + bundlerInfo: { + force: true + } + }, plugins: [ compiler => { compiler.hooks.compilation.tap("test", compilation => { compilation.hooks.additionalTreeRuntimeRequirements.tap( "test", - (_, set) => {} + (_, set) => { } ); }); } ], - experiments: { - rspackFuture: { - bundlerInfo: { - force: true - } - } - } }; diff --git a/tests/rspack-test/configCases/version/all/rspack.config.js b/tests/rspack-test/configCases/version/all/rspack.config.js index 475f5095f91c..c5896e7a831e 100644 --- a/tests/rspack-test/configCases/version/all/rspack.config.js +++ b/tests/rspack-test/configCases/version/all/rspack.config.js @@ -1,10 +1,8 @@ /** @type {import("@rspack/core").Configuration} */ module.exports = { - experiments: { - rspackFuture: { - bundlerInfo: { - force: true - } + output: { + bundlerInfo: { + force: true } - } + }, }; diff --git a/tests/rspack-test/configCases/version/array/rspack.config.js b/tests/rspack-test/configCases/version/array/rspack.config.js index 2566c78c9292..6673af180272 100644 --- a/tests/rspack-test/configCases/version/array/rspack.config.js +++ b/tests/rspack-test/configCases/version/array/rspack.config.js @@ -1,10 +1,8 @@ /** @type {import("@rspack/core").Configuration} */ module.exports = { - experiments: { - rspackFuture: { - bundlerInfo: { - force: ["version"] - } + output: { + bundlerInfo: { + force: ["version"] } - } + }, }; diff --git a/tests/rspack-test/configCases/version/auto/rspack.config.js b/tests/rspack-test/configCases/version/auto/rspack.config.js index 2e4410dffd38..3565fa0d4ba5 100644 --- a/tests/rspack-test/configCases/version/auto/rspack.config.js +++ b/tests/rspack-test/configCases/version/auto/rspack.config.js @@ -1,10 +1,5 @@ /** @type {import("@rspack/core").Configuration} */ module.exports = { - experiments: { - rspackFuture: { - bundlerInfo: { - force: false - } - } - } + output: { + }, }; diff --git a/tests/rspack-test/defaultsCases/default/base.js b/tests/rspack-test/defaultsCases/default/base.js index 9072b2e54a78..94a36fa8ee48 100644 --- a/tests/rspack-test/defaultsCases/default/base.js +++ b/tests/rspack-test/defaultsCases/default/base.js @@ -49,13 +49,6 @@ module.exports = { lazyBarrel: true, lazyCompilation: false, parallelLoader: false, - rspackFuture: Object { - bundlerInfo: Object { - bundler: rspack, - force: true, - version: $version$, - }, - }, topLevelAwait: true, typeReexportsPresence: false, useInputFileSystem: false, @@ -303,6 +296,11 @@ module.exports = { output: Object { assetModuleFilename: [hash][ext][query], asyncChunks: true, + bundlerInfo: Object { + bundler: rspack, + force: true, + version: $version$, + }, charset: false, chunkFilename: [name].js, chunkFormat: array-push, diff --git a/tests/rspack-test/defaultsCases/library/library.js b/tests/rspack-test/defaultsCases/library/library.js index e1a13f217d52..ea6f47893f18 100644 --- a/tests/rspack-test/defaultsCases/library/library.js +++ b/tests/rspack-test/defaultsCases/library/library.js @@ -4,41 +4,41 @@ module.exports = { options: () => ({ output: { library: ["myLib", "awesome"] } }), diff: e => e.toMatchInlineSnapshot(` - - Expected - + Received + - Expected + + Received - @@ ... @@ - - "force": true, - + "force": false, - @@ ... @@ - - "chunkLoadingGlobal": "webpackChunk_rspack_tests", - + "chunkLoadingGlobal": "webpackChunkmyLib_awesome", - @@ ... @@ - - "devtoolNamespace": "@rspack/tests", - + "devtoolNamespace": "myLib.awesome", - @@ ... @@ - - "enabledLibraryTypes": Array [], - + "enabledLibraryTypes": Array [ - + "var", - + ], - @@ ... @@ - - "hotUpdateGlobal": "webpackHotUpdate_rspack_tests", - + "hotUpdateGlobal": "webpackHotUpdatemyLib_awesome", - @@ ... @@ - - "library": undefined, - + "library": Object { - + "amdContainer": undefined, - + "auxiliaryComment": undefined, - + "export": undefined, - + "name": Array [ - + "myLib", - + "awesome", - + ], - + "type": "var", - + "umdNamedDefine": undefined, - + }, - @@ ... @@ - - "uniqueName": "@rspack/tests", - + "uniqueName": "myLib.awesome", - `) + @@ ... @@ + - "force": true, + + "force": false, + @@ ... @@ + - "chunkLoadingGlobal": "webpackChunk_rspack_tests", + + "chunkLoadingGlobal": "webpackChunkmyLib_awesome", + @@ ... @@ + - "devtoolNamespace": "@rspack/tests", + + "devtoolNamespace": "myLib.awesome", + @@ ... @@ + - "enabledLibraryTypes": Array [], + + "enabledLibraryTypes": Array [ + + "var", + + ], + @@ ... @@ + - "hotUpdateGlobal": "webpackHotUpdate_rspack_tests", + + "hotUpdateGlobal": "webpackHotUpdatemyLib_awesome", + @@ ... @@ + - "library": undefined, + + "library": Object { + + "amdContainer": undefined, + + "auxiliaryComment": undefined, + + "export": undefined, + + "name": Array [ + + "myLib", + + "awesome", + + ], + + "type": "var", + + "umdNamedDefine": undefined, + + }, + @@ ... @@ + - "uniqueName": "@rspack/tests", + + "uniqueName": "myLib.awesome", + `) }; diff --git a/tests/rspack-test/defaultsCases/library/name-placeholder.js b/tests/rspack-test/defaultsCases/library/name-placeholder.js index c3b41d6b2109..71f52974a895 100644 --- a/tests/rspack-test/defaultsCases/library/name-placeholder.js +++ b/tests/rspack-test/defaultsCases/library/name-placeholder.js @@ -11,42 +11,42 @@ module.exports = { }), diff: e => e.toMatchInlineSnapshot(` - - Expected - + Received + - Expected + + Received - @@ ... @@ - - "force": true, - + "force": false, - @@ ... @@ - - "chunkLoadingGlobal": "webpackChunk_rspack_tests", - + "chunkLoadingGlobal": "webpackChunkmyLib_lib", - @@ ... @@ - - "devtoolNamespace": "@rspack/tests", - + "devtoolNamespace": "myLib.lib", - @@ ... @@ - - "enabledLibraryTypes": Array [], - + "enabledLibraryTypes": Array [ - + "var", - + ], - @@ ... @@ - - "hotUpdateGlobal": "webpackHotUpdate_rspack_tests", - + "hotUpdateGlobal": "webpackHotUpdatemyLib_lib", - @@ ... @@ - - "library": undefined, - + "library": Object { - + "amdContainer": undefined, - + "auxiliaryComment": undefined, - + "export": undefined, - + "name": Array [ - + "my[name]Lib", - + "[name]", - + "lib", - + ], - + "type": "var", - + "umdNamedDefine": undefined, - + }, - @@ ... @@ - - "uniqueName": "@rspack/tests", - + "uniqueName": "myLib.lib", - `) + @@ ... @@ + - "force": true, + + "force": false, + @@ ... @@ + - "chunkLoadingGlobal": "webpackChunk_rspack_tests", + + "chunkLoadingGlobal": "webpackChunkmyLib_lib", + @@ ... @@ + - "devtoolNamespace": "@rspack/tests", + + "devtoolNamespace": "myLib.lib", + @@ ... @@ + - "enabledLibraryTypes": Array [], + + "enabledLibraryTypes": Array [ + + "var", + + ], + @@ ... @@ + - "hotUpdateGlobal": "webpackHotUpdate_rspack_tests", + + "hotUpdateGlobal": "webpackHotUpdatemyLib_lib", + @@ ... @@ + - "library": undefined, + + "library": Object { + + "amdContainer": undefined, + + "auxiliaryComment": undefined, + + "export": undefined, + + "name": Array [ + + "my[name]Lib", + + "[name]", + + "lib", + + ], + + "type": "var", + + "umdNamedDefine": undefined, + + }, + @@ ... @@ + - "uniqueName": "@rspack/tests", + + "uniqueName": "myLib.lib", + `) }; diff --git a/tests/rspack-test/defaultsCases/library/name-root-placeholder.js b/tests/rspack-test/defaultsCases/library/name-root-placeholder.js index 168d80446cd1..514a028d2dbe 100644 --- a/tests/rspack-test/defaultsCases/library/name-root-placeholder.js +++ b/tests/rspack-test/defaultsCases/library/name-root-placeholder.js @@ -13,44 +13,44 @@ module.exports = { }), diff: e => e.toMatchInlineSnapshot(` - - Expected - + Received + - Expected + + Received - @@ ... @@ - - "force": true, - + "force": false, - @@ ... @@ - - "chunkLoadingGlobal": "webpackChunk_rspack_tests", - + "chunkLoadingGlobal": "webpackChunk_name_my_name_Lib_name_", - @@ ... @@ - - "devtoolNamespace": "@rspack/tests", - + "devtoolNamespace": "[name].my[name]Lib.[name]", - @@ ... @@ - - "enabledLibraryTypes": Array [], - + "enabledLibraryTypes": Array [ - + "var", - + ], - @@ ... @@ - - "hotUpdateGlobal": "webpackHotUpdate_rspack_tests", - + "hotUpdateGlobal": "webpackHotUpdate_name_my_name_Lib_name_", - @@ ... @@ - - "library": undefined, - + "library": Object { - + "amdContainer": undefined, - + "auxiliaryComment": undefined, - + "export": undefined, - + "name": Object { - + "root": Array [ - + "[\\\\name\\\\]", - + "my[\\\\name\\\\]Lib[name]", - + "[\\\\name\\\\]", - + ], - + }, - + "type": "var", - + "umdNamedDefine": undefined, - + }, - @@ ... @@ - - "uniqueName": "@rspack/tests", - + "uniqueName": "[name].my[name]Lib.[name]", - `) + @@ ... @@ + - "force": true, + + "force": false, + @@ ... @@ + - "chunkLoadingGlobal": "webpackChunk_rspack_tests", + + "chunkLoadingGlobal": "webpackChunk_name_my_name_Lib_name_", + @@ ... @@ + - "devtoolNamespace": "@rspack/tests", + + "devtoolNamespace": "[name].my[name]Lib.[name]", + @@ ... @@ + - "enabledLibraryTypes": Array [], + + "enabledLibraryTypes": Array [ + + "var", + + ], + @@ ... @@ + - "hotUpdateGlobal": "webpackHotUpdate_rspack_tests", + + "hotUpdateGlobal": "webpackHotUpdate_name_my_name_Lib_name_", + @@ ... @@ + - "library": undefined, + + "library": Object { + + "amdContainer": undefined, + + "auxiliaryComment": undefined, + + "export": undefined, + + "name": Object { + + "root": Array [ + + "[\\\\name\\\\]", + + "my[\\\\name\\\\]Lib[name]", + + "[\\\\name\\\\]", + + ], + + }, + + "type": "var", + + "umdNamedDefine": undefined, + + }, + @@ ... @@ + - "uniqueName": "@rspack/tests", + + "uniqueName": "[name].my[name]Lib.[name]", + `) }; diff --git a/tests/rspack-test/defaultsCases/library/placeholder.js b/tests/rspack-test/defaultsCases/library/placeholder.js index 7864e452684f..3a8a7fae8078 100644 --- a/tests/rspack-test/defaultsCases/library/placeholder.js +++ b/tests/rspack-test/defaultsCases/library/placeholder.js @@ -8,41 +8,41 @@ module.exports = { }), diff: e => e.toMatchInlineSnapshot(` - - Expected - + Received + - Expected + + Received - @@ ... @@ - - "force": true, - + "force": false, - @@ ... @@ - - "chunkLoadingGlobal": "webpackChunk_rspack_tests", - + "chunkLoadingGlobal": "webpackChunkmyLib", - @@ ... @@ - - "devtoolNamespace": "@rspack/tests", - + "devtoolNamespace": "myLib", - @@ ... @@ - - "enabledLibraryTypes": Array [], - + "enabledLibraryTypes": Array [ - + "var", - + ], - @@ ... @@ - - "hotUpdateGlobal": "webpackHotUpdate_rspack_tests", - + "hotUpdateGlobal": "webpackHotUpdatemyLib", - @@ ... @@ - - "library": undefined, - + "library": Object { - + "amdContainer": undefined, - + "auxiliaryComment": undefined, - + "export": undefined, - + "name": Array [ - + "myLib", - + "[name]", - + ], - + "type": "var", - + "umdNamedDefine": undefined, - + }, - @@ ... @@ - - "uniqueName": "@rspack/tests", - + "uniqueName": "myLib", - `) + @@ ... @@ + - "force": true, + + "force": false, + @@ ... @@ + - "chunkLoadingGlobal": "webpackChunk_rspack_tests", + + "chunkLoadingGlobal": "webpackChunkmyLib", + @@ ... @@ + - "devtoolNamespace": "@rspack/tests", + + "devtoolNamespace": "myLib", + @@ ... @@ + - "enabledLibraryTypes": Array [], + + "enabledLibraryTypes": Array [ + + "var", + + ], + @@ ... @@ + - "hotUpdateGlobal": "webpackHotUpdate_rspack_tests", + + "hotUpdateGlobal": "webpackHotUpdatemyLib", + @@ ... @@ + - "library": undefined, + + "library": Object { + + "amdContainer": undefined, + + "auxiliaryComment": undefined, + + "export": undefined, + + "name": Array [ + + "myLib", + + "[name]", + + ], + + "type": "var", + + "umdNamedDefine": undefined, + + }, + @@ ... @@ + - "uniqueName": "@rspack/tests", + + "uniqueName": "myLib", + `) }; diff --git a/tests/rspack-test/defaultsCases/library/root-placeholder.js b/tests/rspack-test/defaultsCases/library/root-placeholder.js index 9a2ca2be6836..77c17681da30 100644 --- a/tests/rspack-test/defaultsCases/library/root-placeholder.js +++ b/tests/rspack-test/defaultsCases/library/root-placeholder.js @@ -13,43 +13,43 @@ module.exports = { }), diff: e => e.toMatchInlineSnapshot(` - - Expected - + Received + - Expected + + Received - @@ ... @@ - - "force": true, - + "force": false, - @@ ... @@ - - "chunkLoadingGlobal": "webpackChunk_rspack_tests", - + "chunkLoadingGlobal": "webpackChunkmyLib", - @@ ... @@ - - "devtoolNamespace": "@rspack/tests", - + "devtoolNamespace": "myLib", - @@ ... @@ - - "enabledLibraryTypes": Array [], - + "enabledLibraryTypes": Array [ - + "var", - + ], - @@ ... @@ - - "hotUpdateGlobal": "webpackHotUpdate_rspack_tests", - + "hotUpdateGlobal": "webpackHotUpdatemyLib", - @@ ... @@ - - "library": undefined, - + "library": Object { - + "amdContainer": undefined, - + "auxiliaryComment": undefined, - + "export": undefined, - + "name": Object { - + "root": Array [ - + "[name]", - + "myLib", - + ], - + }, - + "type": "var", - + "umdNamedDefine": undefined, - + }, - @@ ... @@ - - "uniqueName": "@rspack/tests", - + "uniqueName": "myLib", - `) + @@ ... @@ + - "force": true, + + "force": false, + @@ ... @@ + - "chunkLoadingGlobal": "webpackChunk_rspack_tests", + + "chunkLoadingGlobal": "webpackChunkmyLib", + @@ ... @@ + - "devtoolNamespace": "@rspack/tests", + + "devtoolNamespace": "myLib", + @@ ... @@ + - "enabledLibraryTypes": Array [], + + "enabledLibraryTypes": Array [ + + "var", + + ], + @@ ... @@ + - "hotUpdateGlobal": "webpackHotUpdate_rspack_tests", + + "hotUpdateGlobal": "webpackHotUpdatemyLib", + @@ ... @@ + - "library": undefined, + + "library": Object { + + "amdContainer": undefined, + + "auxiliaryComment": undefined, + + "export": undefined, + + "name": Object { + + "root": Array [ + + "[name]", + + "myLib", + + ], + + }, + + "type": "var", + + "umdNamedDefine": undefined, + + }, + @@ ... @@ + - "uniqueName": "@rspack/tests", + + "uniqueName": "myLib", + `) }; diff --git a/tests/rspack-test/statsAPICases/bundler-info.js b/tests/rspack-test/statsAPICases/bundler-info.js index 9813fe4a0b13..75a04c8d5091 100644 --- a/tests/rspack-test/statsAPICases/bundler-info.js +++ b/tests/rspack-test/statsAPICases/bundler-info.js @@ -4,14 +4,12 @@ module.exports = { options(context) { return { context: context.getSource(), - entry: "./fixtures/index", - experiments: { - rspackFuture: { - bundlerInfo: { - force: true - } + output: { + bundlerInfo: { + force: true } - } + }, + entry: "./fixtures/index", }; }, async check(stats) { diff --git a/website/components/DeprecationTable.tsx b/website/components/DeprecationTable.tsx index 1f4aaa6ca3b0..388e7373ad85 100644 --- a/website/components/DeprecationTable.tsx +++ b/website/components/DeprecationTable.tsx @@ -61,16 +61,8 @@ function DeprecationTable() { description: ( <> The default behavior is changed to the latest one. Turning - off this new behavior is still an option, check out - - experiments.rspackFuture - - for the way to do it , but you should migrate to the new behavior - as soon as possible. + off this new behavior is still an option, but you should migrate + to the new behavior as soon as possible. ), }, @@ -109,15 +101,7 @@ function DeprecationTable() { description: ( <> 默认行为 已更新{' '} - 至新行为。但你仍旧可以关闭这个行为,具体请参考: - - experiments.rspackFuture - - 。请尽快迁移至新行为,以免功能不可用。 + 至新行为。但你仍旧可以关闭这个行为。请尽快迁移至新行为,以免功能不可用。 ), }, diff --git a/website/docs/en/api/runtime-api/module-variables.mdx b/website/docs/en/api/runtime-api/module-variables.mdx index 576f48e23b59..a13c7e922504 100644 --- a/website/docs/en/api/runtime-api/module-variables.mdx +++ b/website/docs/en/api/runtime-api/module-variables.mdx @@ -671,7 +671,7 @@ Context from System.js when `output.libraryTarget="system"` Current Rspack version, default to version in `@rspack/core/package.json`, can -be modified through experiments.rspackFuture.bundlerInfo.version. +be modified through output.bundlerInfo.version. ```js title=Source @@ -693,8 +693,8 @@ __webpack_require__.rv = '0.7.4'; The ID of the current bundler, the value is `bundler={bundler}@{version}`: -- `bundler`: Default to `"rspack"` and can be modified through [experiments.rspackFuture.bundlerInfo.bundler](/config/experiments#rspackfuturebundlerinfo). -- `version`: Default to version in `@rspack/core/package.json` and can be modified through [experiments.rspackFuture.bundlerInfo.version](/config/experiments#rspackfuturebundlerinfo). +- `bundler`: Default to `"rspack"` and can be modified through [output.bundlerInfo.bundler](/config/output#outputbundlerinfo). +- `version`: Default to version in `@rspack/core/package.json` and can be modified through [output.bundlerInfo.version](/config/output#outputbundlerinfo). ```js title=Source diff --git a/website/docs/en/config/experiments.mdx b/website/docs/en/config/experiments.mdx index 06c9e0ff6781..6e42a7b89d94 100644 --- a/website/docs/en/config/experiments.mdx +++ b/website/docs/en/config/experiments.mdx @@ -181,49 +181,6 @@ export default { }; ``` -## experiments.rspackFuture - -- **Type:** `object` - -- **Default:** See options down below for details - -Used to control whether to enable Rspack future default options, check out the details [here](https://github.com/web-infra-dev/rspack/pull/4107). - -### rspackFuture.bundlerInfo - - - -- **Type**: - - ```ts - type BundlerInfo = { - version?: string, - bundler?: string, - force?: ('version' | 'uniqueId')[] | boolean; - }; - ``` - -Used to inject the currently used Rspack information into the generated asset: - -- `version`: Used to specify the Rspack version, defaults to the `version` field in `@rspack/core/package.json`. -- `bundler`: Used to specify the name of the packaging tool, defaults to `rspack`. -- `force`: Whether to force the injection of Rspack information, which will be added to chunk as a runtime module, and defaults to `true` to force injection. An array can be used to select the items to be forced injected. - -#### Disable default injection - -The default injection can be disabled by setting `force` to `false`. Then injection will only occur when `__rspack_version__` and `__rspack_unique_id__` are detected in the code: - -- [`__rspack_version__`](/api/runtime-api/module-variables#__rspack_version__): Inject version information. -- [`__rspack_unique_id__`](/api/runtime-api/module-variables#__rspack_unique_id__): Inject the unique ID of the bundler. - -```js title="rspack.config.mjs" -export default { - experiments: { - rspackFuture: { bundlerInfo: { force: false } }, - }, -}; -``` - ## experiments.cache diff --git a/website/docs/en/config/output.mdx b/website/docs/en/config/output.mdx index afa3dd66a86d..839a5a538c33 100644 --- a/website/docs/en/config/output.mdx +++ b/website/docs/en/config/output.mdx @@ -46,6 +46,43 @@ export default { }; ``` +### output.bundlerInfo + + + +> In versions 1.x, you can use `experiments.rspackFuture.bundlerInfo` instead. + +- **Type**: + + ```ts + type BundlerInfo = { + version?: string, + bundler?: string, + force?: ('version' | 'uniqueId')[] | boolean; + }; + ``` + +Used to inject the currently used Rspack information into the generated asset: + +- `version`: Used to specify the Rspack version, defaults to the `version` field in `@rspack/core/package.json`. +- `bundler`: Used to specify the name of the packaging tool, defaults to `rspack`. +- `force`: Whether to force the injection of Rspack information, which will be added to chunk as a runtime module, and defaults to `true` to force injection. An array can be used to select the items to be forced injected. + +#### Disable default injection + +The default injection can be disabled by setting `force` to `false`. Then injection will only occur when `__rspack_version__` and `__rspack_unique_id__` are detected in the code: + +- [`__rspack_version__`](/api/runtime-api/module-variables#__rspack_version__): Inject version information. +- [`__rspack_unique_id__`](/api/runtime-api/module-variables#__rspack_unique_id__): Inject the unique ID of the bundler. + +```js title="rspack.config.mjs" +export default { + output: { + bundlerInfo: { force: false }, + }, +}; +``` + ## output.charset - **Type:** `boolean` diff --git a/website/docs/en/misc/planning/future.mdx b/website/docs/en/misc/planning/future.mdx index 1086fc7f60eb..ec0b679e9c07 100644 --- a/website/docs/en/misc/planning/future.mdx +++ b/website/docs/en/misc/planning/future.mdx @@ -8,10 +8,6 @@ During the 0.y.z phase, Rspack may include breaking changes only when upgrading After reaching version 1.0.0, we will adhere to [semver](https://semver.org/) for version management. -## Future default behavior (Rspack future) - -Rspack provides some experimental features in [experiments.rspackFuture](/config/experiments#experimentsrspackfuture). These features will become the default behavior in the future, but they are currently not default and need to be explicitly enabled in the configuration file. - ## Deprecation diff --git a/website/docs/zh/api/runtime-api/module-variables.mdx b/website/docs/zh/api/runtime-api/module-variables.mdx index cb6fc0a28586..b02cd55f8431 100644 --- a/website/docs/zh/api/runtime-api/module-variables.mdx +++ b/website/docs/zh/api/runtime-api/module-variables.mdx @@ -663,7 +663,7 @@ __webpack_get_script_filename__ = (chunkId) => { 当前使用的 Rspack 版本,默认从 `@rspack/core/package.json` 读取。可以通过 -`experiments.rspackFuture.bundlerInfo.version` 修改。 +`output.bundlerInfo.version` 修改。 ```js title=源码 @@ -685,8 +685,8 @@ __webpack_require__.rv = '0.7.4'; 当前打包工具的 ID,值为 `{bundler}@{version}`。其中: -- `bundler`:默认为 `"rspack"` 可以通过 [experiments.rspackFuture.bundlerInfo.bundler](/config/experiments#rspackfuturebundlerinfo) 修改。 -- `version`:默认从 `@rspack/core/package.json` 读取,可以通过 [experiments.rspackFuture.bundlerInfo.version](/config/experiments#rspackfuturebundlerinfo) 修改。 +- `bundler`:默认为 `"rspack"` 可以通过 [output.bundlerInfo.bundler](/config/output#outputbundlerinfo) 修改。 +- `version`:默认从 `@rspack/core/package.json` 读取,可以通过 [output.bundlerInfo.version](/config/output#outputbundlerinfo) 修改。 ```js title=源码 diff --git a/website/docs/zh/config/experiments.mdx b/website/docs/zh/config/experiments.mdx index 546dca81eb69..eb6117b254ad 100644 --- a/website/docs/zh/config/experiments.mdx +++ b/website/docs/zh/config/experiments.mdx @@ -182,50 +182,6 @@ export default { }; ``` -## experiments.rspackFuture - -- **类型:** `object` -- **默认值:** 参考下方各项配置 - -用于控制是否开启 Rspack 未来的默认行为,详情请参考[这里](https://github.com/web-infra-dev/rspack/pull/4107)。 - -### rspackFuture.bundlerInfo - - - -- **类型:** - - ```ts - type BundlerInfo = { - version?: string, - bundler?: string, - force?: ('version' | 'uniqueId')[] | boolean; - }; - ``` - -用于在生成产物中注入当前使用的 Rspack 信息。其中: - -- `version`:用于指定 Rspack 版本,默认读取 `@rspack/core/package.json` 中的 `version` 字段。 -- `bundler`:用于指定打包工具名称,默认为 `rspack` -- `force`:是否强制注入 Rspack 信息,会以运行时模块的形式加入到产物中,默认为 `true` 即强制注入,可通过数组选择强制注入的项目。 - -#### 关闭默认注入 - -可通过将 `force` 设定为 `false` 来关闭默认注入,此时仅在检测到代码中使用了 `__rspack_version__` 和 `__rspack_unique_id__` 时才会注入: - -- [`__rspack_version__`](/api/runtime-api/module-variables#__rspack_version__):注入版本信息 -- [`__rspack_unique_id__`](/api/runtime-api/module-variables#__rspack_unique_id__):注入打包工具唯一ID - -```js title="rspack.config.mjs" -export default { - experiments: { - rspackFuture: { - bundlerInfo: { force: false }, - }, - }, -}; -``` - ## experiments.cache diff --git a/website/docs/zh/config/output.mdx b/website/docs/zh/config/output.mdx index 10f55aedaaba..9cb8edfbdf57 100644 --- a/website/docs/zh/config/output.mdx +++ b/website/docs/zh/config/output.mdx @@ -46,6 +46,43 @@ export default { }; ``` +### output.bundlerInfo + + + +> 在 1.x 版本中,你可以使用 `experiments.rspackFuture.bundlerInfo`。 + +- **类型:** + + ```ts + type BundlerInfo = { + version?: string, + bundler?: string, + force?: ('version' | 'uniqueId')[] | boolean; + }; + ``` + +用于在生成产物中注入当前使用的 Rspack 信息。其中: + +- `version`:用于指定 Rspack 版本,默认读取 `@rspack/core/package.json` 中的 `version` 字段。 +- `bundler`:用于指定打包工具名称,默认为 `rspack` +- `force`:是否强制注入 Rspack 信息,会以运行时模块的形式加入到产物中,默认为 `true` 即强制注入,可通过数组选择强制注入的项目。 + +#### 关闭默认注入 + +可通过将 `force` 设定为 `false` 来关闭默认注入,此时仅在检测到代码中使用了 `__rspack_version__` 和 `__rspack_unique_id__` 时才会注入: + +- [`__rspack_version__`](/api/runtime-api/module-variables#__rspack_version__):注入版本信息 +- [`__rspack_unique_id__`](/api/runtime-api/module-variables#__rspack_unique_id__):注入打包工具唯一ID + +```js title="rspack.config.mjs" +export default { + output: { + bundlerInfo: { force: false }, + }, +}; +``` + ## output.charset - **类型:** `boolean` diff --git a/website/docs/zh/misc/planning/future.mdx b/website/docs/zh/misc/planning/future.mdx index bba2132796a0..ec2ee9e54a78 100644 --- a/website/docs/zh/misc/planning/future.mdx +++ b/website/docs/zh/misc/planning/future.mdx @@ -8,10 +8,6 @@ Rspack 在 0.y.z 的阶段仅可能会在 minor(y)版本升级的时候包 在达到 1.0.0 版本后,我们将会遵循 [semver](https://semver.org/) 进行版本管理。 -## 未来默认行为 (Rspack future) - -Rspack 在 [experiments.rspackFuture](/config/experiments#experimentsrspackfuture) 中提供了一些实验性的功能,这些功能在未来会成为默认行为,但是目前还不是默认行为,需要在配置文件中显式开启。 - ## 功能废弃 (deprecation) diff --git a/website/project-words.txt b/website/project-words.txt index e960b0f7a6fa..d68a17abc94f 100644 --- a/website/project-words.txt +++ b/website/project-words.txt @@ -48,9 +48,6 @@ esbuild etags evanw experimentscss -experimentsrspackfuture -experimentsrspackfuturedisableapplyentrylazily -experimentsrspackfuturenewresolver externalstypecommonjs faga295 fargs From 09f1473a33477ec81de46f694ddd43423b7fa0e3 Mon Sep 17 00:00:00 2001 From: LingyuCoder Date: Wed, 7 Jan 2026 15:18:26 +0800 Subject: [PATCH 2/2] feat: remove rspackFuture and move bundlerInfo to output --- website/components/DeprecationTable.tsx | 1 - 1 file changed, 1 deletion(-) diff --git a/website/components/DeprecationTable.tsx b/website/components/DeprecationTable.tsx index 388e7373ad85..e75b09f711b4 100644 --- a/website/components/DeprecationTable.tsx +++ b/website/components/DeprecationTable.tsx @@ -1,7 +1,6 @@ import { Table } from '@builtIns/Table'; import { useLocation } from '@hooks/useLocation'; import { useLang } from '@rspress/core/runtime'; -import { Link } from '@rspress/core/theme'; import semver from 'semver'; function useDeprecatedVersion() {