diff --git a/crates/node_binding/napi-binding.d.ts b/crates/node_binding/napi-binding.d.ts index cfdba6bd31c2..0d06f682ea55 100644 --- a/crates/node_binding/napi-binding.d.ts +++ b/crates/node_binding/napi-binding.d.ts @@ -1397,7 +1397,6 @@ export interface JsStatsModuleCommonAttributes { failed?: boolean errors?: number warnings?: number - profile?: JsStatsModuleProfile chunks?: Array assets?: Array reasons?: Array @@ -2598,7 +2597,6 @@ export interface RawOptions { cache: RawCacheOptions experiments: RawExperiments node?: RawNodeOption - profile: boolean amd?: string bail: boolean __references: Record diff --git a/crates/rspack/src/builder/mod.rs b/crates/rspack/src/builder/mod.rs index b0f4ee725a03..4f1df6fc4c22 100644 --- a/crates/rspack/src/builder/mod.rs +++ b/crates/rspack/src/builder/mod.rs @@ -236,14 +236,6 @@ impl CompilerBuilder { self } - /// Set whether to enable profiling. - /// - /// See [`CompilerOptionsBuilder::profile`] for more details. - pub fn profile(&mut self, profile: bool) -> &mut Self { - self.options_builder.profile(profile); - self - } - /// Set options for module configuration. /// /// Both are accepted: @@ -584,8 +576,6 @@ pub struct CompilerOptionsBuilder { resolve_loader: Option, /// The type of externals. devtool: Option, - /// The type of externals. - profile: Option, /// Whether to fail on the first error. bail: Option, /// Performance optimization options. @@ -619,7 +609,6 @@ impl From<&mut CompilerOptionsBuilder> for CompilerOptionsBuilder { resolve: value.resolve.take(), resolve_loader: value.resolve_loader.take(), devtool: value.devtool.take(), - profile: value.profile.take(), bail: value.bail.take(), experiments: value.experiments.take(), module: value.module.take(), @@ -723,12 +712,6 @@ impl CompilerOptionsBuilder { self } - /// Set whether to enable profiling. - pub fn profile(&mut self, profile: bool) -> &mut Self { - self.profile = Some(profile); - self - } - /// Set options for module configuration. /// /// Both are accepted: @@ -938,7 +921,6 @@ impl CompilerOptionsBuilder { } }); - let profile = d!(self.profile.take(), false); let bail = d!(self.bail.take(), false); let cache = d!(self.cache.take(), { if development { @@ -1271,7 +1253,6 @@ impl CompilerOptionsBuilder { experiments, node, optimization, - profile, amd, bail, __references: Default::default(), diff --git a/crates/rspack/tests/snapshots/defaults__default_options.snap b/crates/rspack/tests/snapshots/defaults__default_options.snap index 3ee3742c54a4..3abecb15a796 100644 --- a/crates/rspack/tests/snapshots/defaults__default_options.snap +++ b/crates/rspack/tests/snapshots/defaults__default_options.snap @@ -1536,7 +1536,6 @@ CompilerOptions { avoid_entry_iife: false, real_content_hash: false, }, - profile: false, amd: None, bail: false, __references: {}, diff --git a/crates/rspack_binding_api/src/raw_options/mod.rs b/crates/rspack_binding_api/src/raw_options/mod.rs index 6d81f7bd253a..43795d024a7d 100644 --- a/crates/rspack_binding_api/src/raw_options/mod.rs +++ b/crates/rspack_binding_api/src/raw_options/mod.rs @@ -57,7 +57,6 @@ pub struct RawOptions { pub cache: RawCacheOptions, pub experiments: RawExperiments, pub node: Option, - pub profile: bool, pub amd: Option, pub bail: bool, #[napi(js_name = "__references", ts_type = "Record")] @@ -131,7 +130,6 @@ impl TryFrom for CompilerOptions { cache, optimization, node, - profile: value.profile, amd: value.amd, bail: value.bail, __references: value.__references, diff --git a/crates/rspack_binding_api/src/stats.rs b/crates/rspack_binding_api/src/stats.rs index bb92987856af..848d6aa594f7 100644 --- a/crates/rspack_binding_api/src/stats.rs +++ b/crates/rspack_binding_api/src/stats.rs @@ -487,7 +487,6 @@ pub struct JsStatsModuleCommonAttributes<'a> { pub failed: Option, pub errors: Option, pub warnings: Option, - pub profile: Option, // ids pub chunks: Option>, @@ -630,7 +629,6 @@ impl<'a> TryFrom> for JsStatsModule<'a> { reasons, assets: stats.assets, source, - profile: stats.profile.map(|p| p.into()), orphan: stats.orphan, provided_exports: stats.provided_exports.map(AtomVecWrapper::new), optimization_bailout: stats.optimization_bailout.map(StringSliceWrapper::new), diff --git a/crates/rspack_core/src/compilation/build_module_graph/graph_updater/repair/add.rs b/crates/rspack_core/src/compilation/build_module_graph/graph_updater/repair/add.rs index 8b35ed3ef96f..81aae07e3232 100644 --- a/crates/rspack_core/src/compilation/build_module_graph/graph_updater/repair/add.rs +++ b/crates/rspack_core/src/compilation/build_module_graph/graph_updater/repair/add.rs @@ -2,7 +2,7 @@ use rspack_error::Result; use super::{TaskContext, build::BuildTask, lazy::ProcessUnlazyDependenciesTask}; use crate::{ - BoxDependency, BoxModule, ModuleIdentifier, ModuleProfile, + BoxDependency, BoxModule, ModuleIdentifier, compilation::build_module_graph::ForwardedIdSet, module_graph::{ModuleGraph, ModuleGraphModule}, utils::task_loop::{Task, TaskResult, TaskType}, @@ -14,7 +14,6 @@ pub struct AddTask { pub module: BoxModule, pub module_graph_module: Box, pub dependencies: Vec, - pub current_profile: Option, pub from_unlazy: bool, } @@ -116,7 +115,6 @@ impl Task for AddTask { compiler_id: context.compiler_id, compilation_id: context.compilation_id, module: self.module, - current_profile: self.current_profile, resolver_factory: context.resolver_factory.clone(), compiler_options: context.compiler_options.clone(), plugin_driver: context.plugin_driver.clone(), diff --git a/crates/rspack_core/src/compilation/build_module_graph/graph_updater/repair/build.rs b/crates/rspack_core/src/compilation/build_module_graph/graph_updater/repair/build.rs index d8371912467b..e02a74ffedbf 100644 --- a/crates/rspack_core/src/compilation/build_module_graph/graph_updater/repair/build.rs +++ b/crates/rspack_core/src/compilation/build_module_graph/graph_updater/repair/build.rs @@ -8,7 +8,7 @@ use super::{ }; use crate::{ AsyncDependenciesBlock, BoxDependency, BoxModule, BuildContext, BuildResult, CompilationId, - CompilerId, CompilerOptions, DependencyParents, ModuleProfile, ResolverFactory, RuntimeTemplate, + CompilerId, CompilerOptions, DependencyParents, ResolverFactory, RuntimeTemplate, SharedPluginDriver, compilation::build_module_graph::{ForwardedIdSet, HasLazyDependencies, LazyDependencies}, utils::{ @@ -22,7 +22,6 @@ pub struct BuildTask { pub compiler_id: CompilerId, pub compilation_id: CompilationId, pub module: BoxModule, - pub current_profile: Option, pub resolver_factory: Arc, pub compiler_options: Arc, pub runtime_template: Arc, @@ -44,14 +43,10 @@ impl Task for BuildTask { resolver_factory, plugin_driver, runtime_template, - mut current_profile, mut module, fs, forwarded_ids, } = *self; - if let Some(current_profile) = &mut current_profile { - current_profile.mark_building_start(); - } plugin_driver .compilation_hooks @@ -74,16 +69,11 @@ impl Task for BuildTask { ) .await; - if let Some(current_profile) = &mut current_profile { - current_profile.mark_building_end(); - } - result.map::>>, _>(|build_result| { vec![Box::new(BuildResultTask { module, build_result: Box::new(build_result), plugin_driver, - current_profile, forwarded_ids, })] }) @@ -95,7 +85,6 @@ struct BuildResultTask { pub module: BoxModule, pub build_result: Box, pub plugin_driver: SharedPluginDriver, - pub current_profile: Option, pub forwarded_ids: ForwardedIdSet, } @@ -108,7 +97,6 @@ impl Task for BuildResultTask { let BuildResultTask { mut module, build_result, - current_profile, plugin_driver, mut forwarded_ids, } = *self; @@ -199,9 +187,6 @@ impl Task for BuildResultTask { { let mgm = module_graph.module_graph_module_by_identifier_mut(&module.identifier()); mgm.all_dependencies = all_dependencies.clone(); - if let Some(current_profile) = current_profile { - mgm.set_profile(current_profile); - } } let module_identifier = module.identifier(); diff --git a/crates/rspack_core/src/compilation/build_module_graph/graph_updater/repair/factorize.rs b/crates/rspack_core/src/compilation/build_module_graph/graph_updater/repair/factorize.rs index 4f5861334e73..23059b1afca1 100644 --- a/crates/rspack_core/src/compilation/build_module_graph/graph_updater/repair/factorize.rs +++ b/crates/rspack_core/src/compilation/build_module_graph/graph_updater/repair/factorize.rs @@ -7,7 +7,7 @@ use super::{TaskContext, add::AddTask}; use crate::{ BoxDependency, CompilationId, CompilerId, CompilerOptions, Context, ExportsInfoData, FactorizeInfo, ModuleFactory, ModuleFactoryCreateData, ModuleFactoryResult, ModuleIdentifier, - ModuleLayer, ModuleProfile, Resolve, ResolverFactory, + ModuleLayer, Resolve, ResolverFactory, module_graph::ModuleGraphModule, utils::{ ResourceId, @@ -28,7 +28,6 @@ pub struct FactorizeTask { pub dependencies: Vec, pub resolve_options: Option>, pub options: Arc, - pub current_profile: Option, pub resolver_factory: Arc, pub from_unlazy: bool, } @@ -39,9 +38,6 @@ impl Task for FactorizeTask { TaskType::Background } async fn background_run(mut self: Box) -> TaskResult { - if let Some(current_profile) = &mut self.current_profile { - current_profile.mark_factory_start(); - } let dependency = &self.dependencies[0]; let context = if let Some(context) = dependency.get_context() @@ -113,10 +109,6 @@ impl Task for FactorizeTask { } }; - if let Some(current_profile) = &mut self.current_profile { - current_profile.mark_factory_end(); - } - let factorize_info = if let Some(unsafe_cache_predicate) = &self.options.module.unsafe_cache && let Some(result) = &factory_result && let Some(module) = &result.module @@ -151,7 +143,6 @@ impl Task for FactorizeTask { original_module_identifier: self.original_module_identifier, factory_result, dependencies: create_data.dependencies, - current_profile: self.current_profile, exports_info_related: exports_info, factorize_info, from_unlazy: self.from_unlazy, @@ -166,7 +157,6 @@ pub struct FactorizeResultTask { /// Result will be available if [crate::ModuleFactory::create] returns `Ok`. pub factory_result: Option, pub dependencies: Vec, - pub current_profile: Option, pub exports_info_related: ExportsInfoData, pub factorize_info: FactorizeInfo, pub from_unlazy: bool, @@ -182,7 +172,6 @@ impl Task for FactorizeResultTask { original_module_identifier, factory_result, mut dependencies, - current_profile, exports_info_related, mut factorize_info, from_unlazy, @@ -253,7 +242,6 @@ impl Task for FactorizeResultTask { module, module_graph_module: Box::new(mgm), dependencies, - current_profile, from_unlazy, })]) } diff --git a/crates/rspack_core/src/compilation/build_module_graph/graph_updater/repair/mod.rs b/crates/rspack_core/src/compilation/build_module_graph/graph_updater/repair/mod.rs index d740bce43000..cab28f99140e 100644 --- a/crates/rspack_core/src/compilation/build_module_graph/graph_updater/repair/mod.rs +++ b/crates/rspack_core/src/compilation/build_module_graph/graph_updater/repair/mod.rs @@ -11,7 +11,7 @@ use rustc_hash::{FxHashMap as HashMap, FxHashSet as HashSet}; use self::context::TaskContext; use super::BuildModuleGraphArtifact; use crate::{ - BuildDependency, Compilation, ModuleProfile, + BuildDependency, Compilation, utils::task_loop::{Task, run_task_loop}, }; @@ -43,7 +43,6 @@ pub async fn repair( .into_iter() .map(|dep_id| { let dependency = module_graph.dependency_by_id(&dep_id); - let current_profile = compilation.options.profile.then(ModuleProfile::default); Box::new(factorize::FactorizeTask { compiler_id: compilation.compiler_id(), compilation_id: compilation.id(), @@ -56,7 +55,6 @@ pub async fn repair( dependencies: vec![dependency.clone()], resolve_options: None, options: compilation.options.clone(), - current_profile, resolver_factory: compilation.resolver_factory.clone(), from_unlazy: false, }) as Box> diff --git a/crates/rspack_core/src/compilation/build_module_graph/graph_updater/repair/process_dependencies.rs b/crates/rspack_core/src/compilation/build_module_graph/graph_updater/repair/process_dependencies.rs index 8e8a787cfea9..bd9c2cf59321 100644 --- a/crates/rspack_core/src/compilation/build_module_graph/graph_updater/repair/process_dependencies.rs +++ b/crates/rspack_core/src/compilation/build_module_graph/graph_updater/repair/process_dependencies.rs @@ -4,7 +4,7 @@ use rustc_hash::FxHashMap as HashMap; use super::{TaskContext, factorize::FactorizeTask}; use crate::{ - ContextDependency, DependencyId, Module, ModuleIdentifier, ModuleProfile, + ContextDependency, DependencyId, Module, ModuleIdentifier, utils::task_loop::{Task, TaskResult, TaskType}, }; @@ -76,10 +76,6 @@ impl Task for ProcessDependenciesTask { let mut res: Vec>> = vec![]; for dependencies in sorted_dependencies.into_values() { - let current_profile = context - .compiler_options - .profile - .then(ModuleProfile::default); let original_module_source = module_graph .module_by_identifier(&original_module_identifier) .and_then(|m| m.as_normal_module()) @@ -112,7 +108,6 @@ impl Task for ProcessDependenciesTask { dependencies, resolve_options: module.get_resolve_options(), options: context.compiler_options.clone(), - current_profile, resolver_factory: context.resolver_factory.clone(), from_unlazy, })); diff --git a/crates/rspack_core/src/compilation/build_module_graph/module_executor/entry.rs b/crates/rspack_core/src/compilation/build_module_graph/module_executor/entry.rs index ed3664ad67aa..2be5ace530bd 100644 --- a/crates/rspack_core/src/compilation/build_module_graph/module_executor/entry.rs +++ b/crates/rspack_core/src/compilation/build_module_graph/module_executor/entry.rs @@ -7,7 +7,7 @@ use super::{ overwrite::overwrite_tasks, }; use crate::{ - Context, Dependency, LoaderImportDependency, ModuleProfile, + Context, Dependency, LoaderImportDependency, utils::task_loop::{Task, TaskResult, TaskType}, }; @@ -74,10 +74,6 @@ impl Task for EntryTask { dependencies: vec![dep], resolve_options: None, options: origin_context.compiler_options.clone(), - current_profile: origin_context - .compiler_options - .profile - .then(ModuleProfile::default), resolver_factory: origin_context.resolver_factory.clone(), from_unlazy: false, })])); diff --git a/crates/rspack_core/src/lib.rs b/crates/rspack_core/src/lib.rs index aa5176640041..cb122636485c 100644 --- a/crates/rspack_core/src/lib.rs +++ b/crates/rspack_core/src/lib.rs @@ -22,10 +22,8 @@ pub use dependencies_block::{ mod fake_namespace_object; pub use fake_namespace_object::*; mod runtime_template; -pub use runtime_template::*; -mod module_profile; -pub use module_profile::*; use rspack_collections::Database; +pub use runtime_template::*; pub mod external_module; pub use external_module::*; mod logger; diff --git a/crates/rspack_core/src/module_graph/module.rs b/crates/rspack_core/src/module_graph/module.rs index 54b25a6b1892..ab558e8c14c3 100644 --- a/crates/rspack_core/src/module_graph/module.rs +++ b/crates/rspack_core/src/module_graph/module.rs @@ -1,7 +1,7 @@ use rspack_cacheable::{cacheable, with::Skip}; use rustc_hash::FxHashSet as HashSet; -use crate::{DependencyId, ExportsInfo, ModuleIdentifier, ModuleIssuer, ModuleProfile}; +use crate::{DependencyId, ExportsInfo, ModuleIdentifier, ModuleIssuer}; #[cacheable] #[derive(Debug, Clone)] @@ -22,7 +22,6 @@ pub struct ModuleGraphModule { pub(crate) pre_order_index: Option, pub post_order_index: Option, pub exports: ExportsInfo, - pub profile: Option, pub depth: Option, pub optimization_bailout: Vec, } @@ -39,7 +38,6 @@ impl ModuleGraphModule { pre_order_index: None, post_order_index: None, exports: exports_info, - profile: None, depth: None, optimization_bailout: vec![], } @@ -69,14 +67,6 @@ impl ModuleGraphModule { &self.outgoing_connections } - pub fn set_profile(&mut self, profile: ModuleProfile) { - self.profile = Some(profile); - } - - pub fn profile(&self) -> Option<&ModuleProfile> { - self.profile.as_ref() - } - pub fn set_issuer_if_unset(&mut self, issuer: Option) { if matches!(self.issuer, ModuleIssuer::Unset) { self.issuer = ModuleIssuer::from_identifier(issuer); diff --git a/crates/rspack_core/src/module_profile.rs b/crates/rspack_core/src/module_profile.rs deleted file mode 100644 index 46ff39ae2714..000000000000 --- a/crates/rspack_core/src/module_profile.rs +++ /dev/null @@ -1,92 +0,0 @@ -use std::time::Instant; - -use rspack_cacheable::{ - cacheable, - with::{Custom, CustomConverter}, -}; - -#[cacheable(with=Custom)] -#[derive(Debug, Default, Clone)] -enum ProfileState { - #[default] - Pending, - Started(Instant), - // u64 is enough to store the time consumption - Finish(u64), -} - -impl CustomConverter for ProfileState { - type Target = Option; - fn serialize(&self, _ctx: &dyn std::any::Any) -> Result { - Ok(self.duration()) - } - fn deserialize( - data: Self::Target, - _ctx: &dyn std::any::Any, - ) -> Result { - if let Some(time) = data { - Ok(ProfileState::Finish(time)) - } else { - Ok(ProfileState::default()) - } - } -} - -impl ProfileState { - fn start(&mut self) { - *self = Self::Started(Instant::now()) - } - - fn end(&mut self) { - match self { - Self::Started(i) => { - let time = Instant::now().duration_since(*i); - *self = Self::Finish(time.as_millis() as u64) - } - _ => panic!("Unable to end an unstarted profiler"), - } - } - - fn duration(&self) -> Option { - match self { - Self::Finish(time) => Some(*time), - _ => None, - } - } -} - -// https://github.com/webpack/webpack/blob/4809421990a20dfefa06e6445191e65001e75f88/lib/ModuleProfile.js -// NOTE: Rspack has different cache design, remove cache related profiles - -#[cacheable] -#[derive(Debug, Default, Clone)] -pub struct ModuleProfile { - factory: ProfileState, - building: ProfileState, -} - -impl ModuleProfile { - pub fn mark_factory_start(&mut self) { - self.factory.start(); - } - - pub fn mark_factory_end(&mut self) { - self.factory.end(); - } - - pub fn mark_building_start(&mut self) { - self.building.start(); - } - - pub fn mark_building_end(&mut self) { - self.building.end(); - } - - pub fn factory_duration(&self) -> Option { - self.factory.duration() - } - - pub fn building_duration(&self) -> Option { - self.building.duration() - } -} diff --git a/crates/rspack_core/src/options/compiler_options.rs b/crates/rspack_core/src/options/compiler_options.rs index ad38971c55b6..65a3f466192f 100644 --- a/crates/rspack_core/src/options/compiler_options.rs +++ b/crates/rspack_core/src/options/compiler_options.rs @@ -17,7 +17,6 @@ pub struct CompilerOptions { pub experiments: Experiments, pub node: Option, pub optimization: Optimization, - pub profile: bool, pub amd: Option, pub bail: bool, pub __references: References, diff --git a/crates/rspack_core/src/stats/mod.rs b/crates/rspack_core/src/stats/mod.rs index d8742fd7557a..db967faaee75 100644 --- a/crates/rspack_core/src/stats/mod.rs +++ b/crates/rspack_core/src/stats/mod.rs @@ -811,7 +811,6 @@ impl Stats<'_> { assets: None, modules: None, source: None, - profile: None, orphan: None, provided_exports: None, used_exports: None, @@ -878,15 +877,6 @@ impl Stats<'_> { .filter(|d| d.module_identifier.is_some_and(|id| id == identifier)) .count() as u32; - let profile = if let Some(p) = mgm.profile() - && let Some(factory) = p.factory_duration() - && let Some(building) = p.building_duration() - { - Some(StatsModuleProfile { factory, building }) - } else { - None - }; - stats.identifier = Some(identifier); stats.name = Some(module.readable_identifier(&self.compilation.options.context)); stats.name_for_condition = module.name_for_condition().map(|n| n.to_string()); @@ -902,8 +892,6 @@ impl Stats<'_> { stats.failed = Some(errors > 0); stats.errors = Some(errors); stats.warnings = Some(warnings); - - stats.profile = profile; } if options.ids { @@ -1149,7 +1137,6 @@ impl Stats<'_> { assets: None, modules: None, source: None, - profile: None, orphan: None, provided_exports: None, used_exports: None, @@ -1265,7 +1252,6 @@ impl Stats<'_> { assets: None, modules: None, source: None, - profile: None, orphan: None, provided_exports: None, used_exports: None, diff --git a/crates/rspack_core/src/stats/struct.rs b/crates/rspack_core/src/stats/struct.rs index 57d377cd1c3f..fce718c90f4e 100644 --- a/crates/rspack_core/src/stats/struct.rs +++ b/crates/rspack_core/src/stats/struct.rs @@ -170,7 +170,6 @@ pub struct StatsModule<'a> { pub assets: Option>, pub modules: Option>>, pub source: Option<&'a BoxSource>, - pub profile: Option, pub orphan: Option, pub provided_exports: Option>, pub used_exports: Option, diff --git a/packages/rspack-cli/src/cli.ts b/packages/rspack-cli/src/cli.ts index fe04d008d8c7..7372d407ab01 100644 --- a/packages/rspack-cli/src/cli.ts +++ b/packages/rspack-cli/src/cli.ts @@ -151,9 +151,6 @@ export class RspackCLI { }, }); } - if (options.profile) { - item.profile = true; - } if (process.env.RSPACK_PROFILE) { const { applyProfile } = await import('./utils/profile.js'); await applyProfile( diff --git a/packages/rspack-cli/src/utils/options.ts b/packages/rspack-cli/src/utils/options.ts index 97f842f32885..00bea49a7473 100644 --- a/packages/rspack-cli/src/utils/options.ts +++ b/packages/rspack-cli/src/utils/options.ts @@ -101,7 +101,6 @@ export const commonOptionsForBuildAndServe = (command: Command): Command => { }) .option('-m, --mode ', 'mode') .option('-o, --output-path ', 'output path dir') - .option('--profile', 'capture timing information for each module') .option('-w, --watch', 'watch'); }; @@ -111,7 +110,6 @@ export type CommonOptionsForBuildAndServe = CommonOptions & { entry?: string[]; mode?: string; outputPath?: string; - profile?: boolean; watch?: boolean; }; diff --git a/packages/rspack/etc/core.api.md b/packages/rspack/etc/core.api.md index 7e45ded5df24..ea0472d6bac9 100644 --- a/packages/rspack/etc/core.api.md +++ b/packages/rspack/etc/core.api.md @@ -4201,7 +4201,6 @@ type KnownStatsModule = { failed?: boolean; errors?: number; warnings?: number; - profile?: StatsProfile; reasons?: StatsModuleReason[]; usedExports?: boolean | string[] | null; providedExports?: string[] | null; @@ -4265,13 +4264,6 @@ type KnownStatsPrinterContext = { chunkGroupKind?: string; }; -// @public (undocumented) -type KnownStatsProfile = { - total: number; - resolving: number; - building: number; -}; - // @public (undocumented) interface LabeledStatement extends Node_4, HasSpan { // (undocumented) @@ -5919,9 +5911,6 @@ interface PrivateProperty extends ClassPropertyBase { type: "PrivateProperty"; } -// @public -export type Profile = boolean; - // @public (undocumented) type Program = Module_2 | Script; @@ -6914,7 +6903,6 @@ declare namespace rspackExports { DevServer, DevServerMiddleware, IgnoreWarnings, - Profile, Amd, Bail, Performance_2 as Performance, @@ -6953,7 +6941,6 @@ export type RspackOptions = { plugins?: Plugins; devServer?: DevServer; module?: ModuleOptions; - profile?: Profile; amd?: Amd; bail?: Bail; performance?: Performance_2; @@ -7019,8 +7006,6 @@ export interface RspackOptionsNormalized { // (undocumented) plugins: Plugins; // (undocumented) - profile?: Profile; - // (undocumented) resolve: Resolve; // (undocumented) resolveLoader: Resolve; @@ -7739,9 +7724,6 @@ class StatsPrinter { // @public (undocumented) type StatsPrinterContext = KnownStatsPrinterContext & Record; -// @public (undocumented) -type StatsProfile = KnownStatsProfile & Record; - // @public export type StatsValue = boolean | StatsOptions | StatsPresets; diff --git a/packages/rspack/src/config/adapter.ts b/packages/rspack/src/config/adapter.ts index eb4f3f08d8c7..f389698845ff 100644 --- a/packages/rspack/src/config/adapter.ts +++ b/packages/rspack/src/config/adapter.ts @@ -104,7 +104,6 @@ export const getRawOptions = ( }, experiments, node: getRawNode(options.node), - profile: options.profile!, amd: options.amd ? JSON.stringify(options.amd || {}) : undefined, bail: options.bail!, __references: {}, diff --git a/packages/rspack/src/config/defaults.ts b/packages/rspack/src/config/defaults.ts index 74cc1919e58b..9f73f2cd85be 100644 --- a/packages/rspack/src/config/defaults.ts +++ b/packages/rspack/src/config/defaults.ts @@ -82,7 +82,6 @@ export const applyRspackOptionsDefaults = ( F(options, 'devtool', () => (development ? 'eval' : false)); D(options, 'watch', false); - D(options, 'profile', false); // IGNORE(lazyCompilation): Unlike webpack where lazyCompilation is configured under experiments, Rspack exposes this option at the configuration root level. D(options, 'lazyCompilation', false); // IGNORE(bail): bail is default to false in webpack, but it's set in `Compilation` diff --git a/packages/rspack/src/config/normalization.ts b/packages/rspack/src/config/normalization.ts index 0361f655dfc7..21e5d0b5f520 100644 --- a/packages/rspack/src/config/normalization.ts +++ b/packages/rspack/src/config/normalization.ts @@ -72,7 +72,6 @@ import type { Path, Performance, Plugins, - Profile, PublicPath, Resolve, RspackOptions, @@ -427,7 +426,6 @@ export const getNormalizedRspackOptions = ( watch: config.watch, watchOptions: cloneObject(config.watchOptions), devServer: config.devServer, - profile: config.profile, amd: config.amd, bail: config.bail, lazyCompilation: optionalNestedConfig(config.lazyCompilation, (options) => @@ -760,7 +758,6 @@ export interface RspackOptionsNormalized { devServer?: DevServer; ignoreWarnings?: IgnoreWarningsNormalized; performance?: Performance; - profile?: Profile; amd?: Amd; bail?: Bail; } diff --git a/packages/rspack/src/config/types.ts b/packages/rspack/src/config/types.ts index 350db71421be..85daed273e00 100644 --- a/packages/rspack/src/config/types.ts +++ b/packages/rspack/src/config/types.ts @@ -2934,13 +2934,6 @@ export type IgnoreWarnings = ( )[]; //#endregion -//#region Profile -/** - * Capture a "profile" of the application, including statistics and hints, which can then be dissected using the Analyze tool. - * */ -export type Profile = boolean; -//#endregion - //#region amd /** * Set the value of `require.amd` and `define.amd`. Or disable AMD support. @@ -3107,10 +3100,6 @@ export type RspackOptions = { * Options for module configuration. */ module?: ModuleOptions; - /** - * Whether to capture a profile of the application. - */ - profile?: Profile; /** * Set the value of `require.amd` or `define.amd`. * Setting `amd` to false will disable rspack's AMD support. diff --git a/packages/rspack/src/stats/DefaultStatsFactoryPlugin.ts b/packages/rspack/src/stats/DefaultStatsFactoryPlugin.ts index fe2e027b2ce7..ac7c03a672d8 100644 --- a/packages/rspack/src/stats/DefaultStatsFactoryPlugin.ts +++ b/packages/rspack/src/stats/DefaultStatsFactoryPlugin.ts @@ -51,7 +51,6 @@ import type { StatsError, StatsModuleReason, StatsModuleTraceItem, - StatsProfile, } from './statsFactoryUtils'; import { assetGroup, @@ -1279,10 +1278,6 @@ const SIMPLE_EXTRACTORS: SimpleExtractors = { object.failed = commonAttributes.failed; object.errors = commonAttributes.errors; object.warnings = commonAttributes.warnings; - const profile = commonAttributes.profile; - if (profile) { - object.profile = factory.create(`${type}.profile`, profile, context); - } }, ids: (object, module) => { const { commonAttributes } = module; @@ -1354,24 +1349,11 @@ const SIMPLE_EXTRACTORS: SimpleExtractors = { } }, }, - profile: { - _: (object, profile) => { - const factory = profile.factory; - const building = profile.building; - const statsProfile: StatsProfile = { - total: factory + building, - resolving: factory, - building, - }; - Object.assign(object, statsProfile); - }, - }, moduleIssuer: { _: (object, module, _context, _options, _factory) => { if (module.moduleDescriptor) { object.identifier = module.moduleDescriptor.identifier; object.name = module.moduleDescriptor.name; - // - profile } }, ids: (object, module) => { diff --git a/packages/rspack/src/stats/DefaultStatsPrinterPlugin.ts b/packages/rspack/src/stats/DefaultStatsPrinterPlugin.ts index 60847684b982..6e45f0940e15 100644 --- a/packages/rspack/src/stats/DefaultStatsPrinterPlugin.ts +++ b/packages/rspack/src/stats/DefaultStatsPrinterPlugin.ts @@ -429,9 +429,7 @@ const SIMPLE_PRINTERS: Record< }, 'module.optimizationBailout[]': (optimizationBailout, { yellow }) => yellow(optimizationBailout), - 'module.issuerPath': (_issuerPath, { module }) => - module.profile ? undefined : '', - 'module.profile': (_profile) => undefined, + 'module.issuerPath': (_issuerPath) => '', 'module.filteredModules': (filteredModules, { module: { modules } }) => filteredModules > 0 ? `${moreCount(modules, filteredModules)} nested ${plural( @@ -459,7 +457,6 @@ const SIMPLE_PRINTERS: Record< 'module.separator!': () => '\n', 'moduleIssuer.id': (id, { formatModuleId }) => formatModuleId(id), - 'moduleIssuer.profile.total': (value, { formatTime }) => formatTime(value), 'moduleReason.type': (type) => type, 'moduleReason.userRequest': (userRequest, { cyan }) => @@ -484,22 +481,6 @@ const SIMPLE_PRINTERS: Record< )}` : undefined, - 'module.profile.total': (value, { formatTime }) => formatTime(value), - 'module.profile.resolving': (value, { formatTime }) => - `resolving: ${formatTime(value)}`, - 'module.profile.restoring': (value, { formatTime }) => - `restoring: ${formatTime(value)}`, - 'module.profile.integration': (value, { formatTime }) => - `integration: ${formatTime(value)}`, - 'module.profile.building': (value, { formatTime }) => - `building: ${formatTime(value)}`, - 'module.profile.storing': (value, { formatTime }) => - `storing: ${formatTime(value)}`, - 'module.profile.additionalResolving': (value, { formatTime }) => - value ? `additional resolving: ${formatTime(value)}` : undefined, - 'module.profile.additionalIntegration': (value, { formatTime }) => - value ? `additional integration: ${formatTime(value)}` : undefined, - 'chunkGroup.kind!': (_, { chunkGroupKind }) => chunkGroupKind, 'chunkGroup.separator!': () => '\n', 'chunkGroup.name': (name, { bold }) => bold(name), @@ -821,7 +802,6 @@ const PREFERRED_ORDERS: Record = { 'reasons', 'filteredReasons', 'issuerPath', - 'profile', 'modules', 'filteredModules', ], @@ -837,17 +817,6 @@ const PREFERRED_ORDERS: Record = { 'children', 'filteredChildren', ], - 'module.profile': [ - 'total', - 'separator!', - 'resolving', - 'restoring', - 'integration', - 'building', - 'storing', - 'additionalResolving', - 'additionalIntegration', - ], chunk: [ 'id', 'runtime', @@ -946,48 +915,6 @@ const joinOneLine = (items: any[]) => .filter(Boolean) .join(' '); -const joinInBrackets = (items: any[]) => { - const res = []; - let mode = 0; - for (const item of items) { - if (item.element === 'separator!') { - switch (mode) { - case 0: - case 1: - mode += 2; - break; - case 4: - res.push(')'); - mode = 3; - break; - } - } - if (!item.content) continue; - switch (mode) { - case 0: - mode = 1; - break; - case 1: - res.push(' '); - break; - case 2: - res.push('('); - mode = 4; - break; - case 3: - res.push(' ('); - mode = 4; - break; - case 4: - res.push(', '); - break; - } - res.push(item.content); - } - if (mode === 4) res.push(')'); - return res.join(''); -}; - const indent = (str: string, prefix: string, noPrefixInFirstLine?: boolean) => { const rem = str.replace(/\n([^\n])/g, `\n${prefix}$1`); if (noPrefixInFirstLine) return rem; @@ -1103,7 +1030,6 @@ const SIMPLE_ELEMENT_JOINERS: Record< case 'optimizationBailout': case 'reasons': case 'issuerPath': - case 'profile': case 'children': case 'modules': if (item.content) { @@ -1178,7 +1104,6 @@ const SIMPLE_ELEMENT_JOINERS: Record< ' ', ); }, - 'module.profile': joinInBrackets, moduleIssuer: joinOneLine, chunkOrigin: (items) => `> ${joinOneLine(items)}`, 'errors[].error': joinError(true), diff --git a/packages/rspack/src/stats/statsFactoryUtils.ts b/packages/rspack/src/stats/statsFactoryUtils.ts index e0ef4d22132c..009e472ebc0c 100644 --- a/packages/rspack/src/stats/statsFactoryUtils.ts +++ b/packages/rspack/src/stats/statsFactoryUtils.ts @@ -125,7 +125,6 @@ export type KnownStatsModule = { failed?: boolean; errors?: number; warnings?: number; - profile?: StatsProfile; reasons?: StatsModuleReason[]; usedExports?: boolean | string[] | null; providedExports?: string[] | null; @@ -136,8 +135,6 @@ export type KnownStatsModule = { source?: string | Buffer; }; -export type StatsProfile = KnownStatsProfile & Record; - export type KnownStatsProfile = { total: number; resolving: number; @@ -150,7 +147,6 @@ export type KnownStatsModuleIssuer = { identifier?: string; name?: string; id?: string | number | null; - // profile?: StatsProfile; }; export type StatsModuleIssuer = KnownStatsModuleIssuer & Record; @@ -348,7 +344,6 @@ export type SimpleExtractors = { binding.JsStatsModuleIssuer, StatsModuleIssuer >; - profile: ExtractorsByOption; moduleReason: ExtractorsByOption< binding.JsStatsModuleReason, StatsModuleReason diff --git a/tests/rspack-test/defaultsCases/default/base.js b/tests/rspack-test/defaultsCases/default/base.js index 1dc95586b44f..e658599a8885 100644 --- a/tests/rspack-test/defaultsCases/default/base.js +++ b/tests/rspack-test/defaultsCases/default/base.js @@ -368,7 +368,6 @@ module.exports = { }, performance: false, plugins: Array [], - profile: false, resolve: Object { aliasFields: Array [], byDependency: Object { diff --git a/tests/rspack-test/statsAPICases/profile.js b/tests/rspack-test/statsAPICases/profile.js index 115e62f97b42..9c902aa7074a 100644 --- a/tests/rspack-test/statsAPICases/profile.js +++ b/tests/rspack-test/statsAPICases/profile.js @@ -12,14 +12,10 @@ module.exports = { expect( stats?.toString({ all: false, modules: true }).replace(/\d+ ms/g, "X ms") ).toMatchInlineSnapshot(` - ./fixtures/abc.js 83 bytes [built] [code generated] - X ms (resolving: X ms, building: X ms) - ./fixtures/a.js 55 bytes [built] [code generated] - X ms (resolving: X ms, building: X ms) - ./fixtures/b.js 94 bytes [built] [code generated] - X ms (resolving: X ms, building: X ms) - ./fixtures/c.js 72 bytes [built] [code generated] - X ms (resolving: X ms, building: X ms) - `); + ./fixtures/abc.js 83 bytes [built] [code generated] + ./fixtures/a.js 55 bytes [built] [code generated] + ./fixtures/b.js 94 bytes [built] [code generated] + ./fixtures/c.js 72 bytes [built] [code generated] + `); } }; diff --git a/tests/rspack-test/statsOutputCases/chunks-development/__snapshots__/stats.txt b/tests/rspack-test/statsOutputCases/chunks-development/__snapshots__/stats.txt index 4de023373175..09b8361b599b 100644 --- a/tests/rspack-test/statsOutputCases/chunks-development/__snapshots__/stats.txt +++ b/tests/rspack-test/statsOutputCases/chunks-development/__snapshots__/stats.txt @@ -5,14 +5,11 @@ chunk (runtime: main) bundle.js (main) xx bytes (javascript) xx bytes (runtime) ./.|sync xx bytes [dependent] [built] [code generated] commonjs require context . ./index.js 2:1-16 commonjs require context . ./index.js 3:1-16 - xx ms (resolving: xx ms, building: xx ms) ./a.js xx bytes [dependent] [built] [code generated] cjs self exports reference self ./a.js cjs require ./a ./index.js 1:9-13 - xx ms (resolving: xx ms, building: xx ms) ./index.js xx bytes [built] [code generated] [2 warnings] entry ./index - xx ms (resolving: xx ms, building: xx ms) WARNING in ./index.js 2:1-16 ⚠ Critical dependency: the request of a dependency is an expression diff --git a/tests/rspack-test/statsOutputCases/chunks/__snapshots__/stats.txt b/tests/rspack-test/statsOutputCases/chunks/__snapshots__/stats.txt index 4de023373175..09b8361b599b 100644 --- a/tests/rspack-test/statsOutputCases/chunks/__snapshots__/stats.txt +++ b/tests/rspack-test/statsOutputCases/chunks/__snapshots__/stats.txt @@ -5,14 +5,11 @@ chunk (runtime: main) bundle.js (main) xx bytes (javascript) xx bytes (runtime) ./.|sync xx bytes [dependent] [built] [code generated] commonjs require context . ./index.js 2:1-16 commonjs require context . ./index.js 3:1-16 - xx ms (resolving: xx ms, building: xx ms) ./a.js xx bytes [dependent] [built] [code generated] cjs self exports reference self ./a.js cjs require ./a ./index.js 1:9-13 - xx ms (resolving: xx ms, building: xx ms) ./index.js xx bytes [built] [code generated] [2 warnings] entry ./index - xx ms (resolving: xx ms, building: xx ms) WARNING in ./index.js 2:1-16 ⚠ Critical dependency: the request of a dependency is an expression diff --git a/tests/rspack-test/statsOutputCases/entry-filename/__snapshots__/stats.txt b/tests/rspack-test/statsOutputCases/entry-filename/__snapshots__/stats.txt index c532b96db2c5..70ceec2fadf6 100644 --- a/tests/rspack-test/statsOutputCases/entry-filename/__snapshots__/stats.txt +++ b/tests/rspack-test/statsOutputCases/entry-filename/__snapshots__/stats.txt @@ -6,11 +6,9 @@ chunk (runtime: a) a.js (a) xx bytes [entry] [rendered] ./a.js xx bytes [built] [code generated] entry ./a.js cjs self exports reference self ./a.js - xx ms (resolving: xx ms, building: xx ms) chunk (runtime: b) c.js (b) xx bytes [entry] [rendered] > ./b.js b ./b.js xx bytes [built] [code generated] entry ./b.js cjs self exports reference self ./b.js - xx ms (resolving: xx ms, building: xx ms) Rspack x.x.x compiled successfully in X s \ No newline at end of file diff --git a/tests/rspack-test/statsOutputCases/preset-verbose/__snapshots__/stats.txt b/tests/rspack-test/statsOutputCases/preset-verbose/__snapshots__/stats.txt index 76c1fcef61a2..07aa3b214773 100644 --- a/tests/rspack-test/statsOutputCases/preset-verbose/__snapshots__/stats.txt +++ b/tests/rspack-test/statsOutputCases/preset-verbose/__snapshots__/stats.txt @@ -9,22 +9,17 @@ chunk {889} (runtime: main) main.js (main) xx bytes (javascript) xx bytes (runti ModuleConcatenation bailout: Module Concatenation is not implemented for javascript/auto commonjs require context . [237] ./index.js 2:1-16 commonjs require context . [237] ./index.js 3:1-16 - [237] -> - xx ms (resolving: xx ms, building: xx ms) ./a.js [670] xx bytes {889} [depth 1] [dependent] [built] [code generated] [used exports unknown] Statement with side_effects in source code at ./a.js-21 ModuleConcatenation bailout: Module is not an ECMAScript module cjs self exports reference self [670] ./a.js cjs require ./a [237] ./index.js 1:9-13 - [237] -> - xx ms (resolving: xx ms, building: xx ms) ./index.js [237] xx bytes {889} [depth 0] [built] [code generated] [2 warnings] [no exports used] Statement with side_effects in source code at ./index.js-15 ModuleConcatenation bailout: Module is not an ECMAScript module entry ./index - xx ms (resolving: xx ms, building: xx ms) LOG from LogTestPlugin diff --git a/tests/rspack-test/statsOutputCases/simple-more-info/__snapshots__/stats.txt b/tests/rspack-test/statsOutputCases/simple-more-info/__snapshots__/stats.txt index e6ed2022d3f9..b814faef11be 100644 --- a/tests/rspack-test/statsOutputCases/simple-more-info/__snapshots__/stats.txt +++ b/tests/rspack-test/statsOutputCases/simple-more-info/__snapshots__/stats.txt @@ -2,5 +2,4 @@ PublicPath: auto asset bundle.js xx bytes [emitted] (name: main) ./index.js xx bytes [built] [code generated] entry ./index - xx ms (resolving: xx ms, building: xx ms) Rspack x.x.x compiled successfully in X s \ No newline at end of file diff --git a/website/docs/en/api/cli.mdx b/website/docs/en/api/cli.mdx index ee58cad1646d..6c9c1285035e 100644 --- a/website/docs/en/api/cli.mdx +++ b/website/docs/en/api/cli.mdx @@ -68,8 +68,6 @@ Options: -d, --devtool devtool [boolean] [default: false] --analyze analyze [boolean] [default: false] --json emit stats json - --profile capture timing information for each module - [boolean] [default: false] ``` ## rspack dev diff --git a/website/docs/en/api/javascript-api/stats-json.mdx b/website/docs/en/api/javascript-api/stats-json.mdx index a69335697a04..939907b68308 100644 --- a/website/docs/en/api/javascript-api/stats-json.mdx +++ b/website/docs/en/api/javascript-api/stats-json.mdx @@ -245,14 +245,6 @@ type StatsModule = { // Source code source?: string | Buffer; - - // The compilation time statistics for each phase (in milliseconds, need to enable `profile`) - profile?: { - // Finding the module - resolving: number; - // Compiling the module - building: number; - }; }; ``` diff --git a/website/docs/en/config/other-options.mdx b/website/docs/en/config/other-options.mdx index db1e96f2165f..1ac96b9f9b26 100644 --- a/website/docs/en/config/other-options.mdx +++ b/website/docs/en/config/other-options.mdx @@ -184,12 +184,3 @@ module.exports = function (source) { :::tip You can override properties in the loader context as webpack copies all properties that are defined in the loader to the loader context. ::: - -## profile - - - -Capture a "profile" of the application, including statistics and hints, which can then be dissected using the Analyze tool. It will also log out a summary of module timings. diff --git a/website/docs/en/config/stats.mdx b/website/docs/en/config/stats.mdx index 64a66a431b8c..a17d27c3f82e 100644 --- a/website/docs/en/config/stats.mdx +++ b/website/docs/en/config/stats.mdx @@ -561,7 +561,6 @@ For `assetsSort`, `chunksSort` and `modulesSort` there are several possible fiel - `'optional'`: whether the item is optional. - `'identifier'`: identifier of the item. - `'index'`: item's processing index. -- `'profile'`: items's processing cost. - `'issuer'`: the identifier of the issuer. - `'issuerId'`: the id of the issuer. - `'issuerName'`: the name of the issuer. diff --git a/website/docs/zh/api/cli.mdx b/website/docs/zh/api/cli.mdx index 5e218c694f32..d7bdc877faea 100644 --- a/website/docs/zh/api/cli.mdx +++ b/website/docs/zh/api/cli.mdx @@ -68,8 +68,6 @@ Options: -d, --devtool devtool [boolean] [default: false] --analyze analyze [boolean] [default: false] --json emit stats json - --profile capture timing information for each module - [boolean] [default: false] ``` ## rspack dev diff --git a/website/docs/zh/api/javascript-api/stats-json.mdx b/website/docs/zh/api/javascript-api/stats-json.mdx index 24e718e0633c..eb53093f4426 100644 --- a/website/docs/zh/api/javascript-api/stats-json.mdx +++ b/website/docs/zh/api/javascript-api/stats-json.mdx @@ -248,14 +248,6 @@ type StatsModule = { // 模块的源代码 source?: string | Buffer; - - // 模块各阶段编译耗时统计(单位为毫秒,需开启 profile 配置) - profile?: { - // 查找模块 - resolving: number; - // 编译模块 - building: number; - }; }; ``` diff --git a/website/docs/zh/config/other-options.mdx b/website/docs/zh/config/other-options.mdx index 599ade037791..d1f790924f8d 100644 --- a/website/docs/zh/config/other-options.mdx +++ b/website/docs/zh/config/other-options.mdx @@ -183,12 +183,3 @@ module.exports = function (source) { :::tip 你可以覆盖 Loader 上下文中的属性,因为 Rspack 会将所有定义在 Loader 中的属性负责到 Loader 上下文中。 ::: - -## profile - - - -捕获构建的分析和提示数据,供分析工具消费。它会尽可能详细的打印模块的耗时信息。 diff --git a/website/docs/zh/config/stats.mdx b/website/docs/zh/config/stats.mdx index 27454c517878..0a37c4ba1847 100644 --- a/website/docs/zh/config/stats.mdx +++ b/website/docs/zh/config/stats.mdx @@ -561,7 +561,6 @@ export default { - `'optional'`: 资源是否可选 - `'identifier'`: 元素的标识符 - `'index'`: 元素处理顺序 -- `'profile'`: 元素的处理耗时 - `'issuer'`: 上游(issuer)的标识符 - `'issuerId'`: 上游(issuer)的 ID - `'issuerName'`: 上游(issuer)的名称