diff --git a/Cargo.toml b/Cargo.toml index 31b0f6d3f24..7b517132fa1 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -48,8 +48,8 @@ proc-macro2 = { version = "1.0.79" } quote = { version = "1.0.35" } rayon = { version = "1.10.0" } regex = { version = "1.10.4" } -rspack_resolver = { version = "0.3.3", features = ["package_json_raw_json_api"] } ropey = "1.6.1" +rspack_resolver = { version = "0.3.3", features = ["package_json_raw_json_api"] } rspack_sources = { version = "=0.3.2" } rustc-hash = { version = "1.1.0" } serde = { version = "1.0.197" } diff --git a/crates/rspack_core/src/build_chunk_graph/code_splitter.rs b/crates/rspack_core/src/build_chunk_graph/code_splitter.rs index c9728aac33b..a6dda703b17 100644 --- a/crates/rspack_core/src/build_chunk_graph/code_splitter.rs +++ b/crates/rspack_core/src/build_chunk_graph/code_splitter.rs @@ -20,7 +20,7 @@ use crate::{ AsyncDependenciesBlockIdentifier, ChunkGroup, ChunkGroupKind, ChunkGroupOptions, ChunkGroupUkey, ChunkLoading, ChunkUkey, Compilation, ConnectionId, ConnectionState, DependenciesBlock, DependencyLocation, EntryDependency, EntryRuntime, GroupOptions, Logger, ModuleDependency, - ModuleGraph, ModuleIdentifier, RuntimeSpec, SyntheticDependencyLocation, + ModuleGraph, ModuleIdentifier, RuntimeSpec, SyntheticDependencyName, }; type IndexMap = RawIndexMap>; @@ -424,9 +424,9 @@ impl<'me> CodeSplitter<'me> { )); for request in requests { - let loc = Some(DependencyLocation::Synthetic( - SyntheticDependencyLocation::new(&name), - )); + let loc = Some(DependencyLocation::Synthetic(SyntheticDependencyName::new( + &name, + ))); entrypoint.add_origin(None, loc, request); } diff --git a/crates/rspack_core/src/context_module.rs b/crates/rspack_core/src/context_module.rs index 02fb03a5bb6..b4f169f3f8e 100644 --- a/crates/rspack_core/src/context_module.rs +++ b/crates/rspack_core/src/context_module.rs @@ -25,9 +25,9 @@ use crate::{ BuildMetaDefaultObject, BuildMetaExportsType, BuildResult, ChunkGraph, ChunkGroupOptions, CodeGenerationResult, Compilation, ConcatenationScope, ContextElementDependency, DependenciesBlock, Dependency, DependencyCategory, DependencyId, DependencyLocation, - DynamicImportMode, ExportsType, FactoryMeta, FakeNamespaceObjectMode, GroupOptions, - ImportAttributes, LibIdentOptions, Module, ModuleLayer, ModuleType, RealDependencyLocation, - Resolve, RuntimeGlobals, RuntimeSpec, SourceType, + DependencyRange, DynamicImportMode, ExportsType, FactoryMeta, FakeNamespaceObjectMode, + GroupOptions, ImportAttributes, LibIdentOptions, Module, ModuleLayer, ModuleType, Resolve, + RuntimeGlobals, RuntimeSpec, SourceType, }; static WEBPACK_CHUNK_NAME_PLACEHOLDER: LazyLock = @@ -883,7 +883,7 @@ impl Module for ContextModule { if matches!(self.options.context_options.mode, ContextMode::LazyOnce) && !context_element_dependencies.is_empty() { - let loc = RealDependencyLocation::new( + let loc = DependencyRange::new( self.options.context_options.start, self.options.context_options.end, ); diff --git a/crates/rspack_core/src/dependency/dependency_location.rs b/crates/rspack_core/src/dependency/dependency_location.rs index c2e6efaad2a..b8e111f9aa9 100644 --- a/crates/rspack_core/src/dependency/dependency_location.rs +++ b/crates/rspack_core/src/dependency/dependency_location.rs @@ -4,16 +4,16 @@ use derivative::Derivative; #[derive(Derivative)] #[derivative(Debug, Clone, Hash)] -pub struct RealDependencyLocation { +pub struct DependencyRange { pub end: u32, pub start: u32, #[derivative(Debug = "ignore", Hash = "ignore")] source: Option>, } -impl RealDependencyLocation { +impl DependencyRange { pub fn new(start: u32, end: u32) -> Self { - RealDependencyLocation { + DependencyRange { end, start, source: None, @@ -26,7 +26,7 @@ impl RealDependencyLocation { } } -impl From<(u32, u32)> for RealDependencyLocation { +impl From<(u32, u32)> for DependencyRange { fn from(range: (u32, u32)) -> Self { Self { start: range.0, @@ -36,7 +36,7 @@ impl From<(u32, u32)> for RealDependencyLocation { } } -impl From for RealDependencyLocation { +impl From for DependencyRange { fn from(span: swc_core::common::Span) -> Self { Self { start: span.lo.0.saturating_sub(1), @@ -46,7 +46,7 @@ impl From for RealDependencyLocation { } } -impl fmt::Display for RealDependencyLocation { +impl fmt::Display for DependencyRange { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { if let Some(source) = &self.source { let (start, end) = source.look_up_range_pos(self.start, self.end); @@ -71,19 +71,19 @@ impl fmt::Display for RealDependencyLocation { } #[derive(Debug, Clone)] -pub struct SyntheticDependencyLocation { +pub struct SyntheticDependencyName { pub name: String, } -impl SyntheticDependencyLocation { +impl SyntheticDependencyName { pub fn new(name: &str) -> Self { - SyntheticDependencyLocation { + SyntheticDependencyName { name: name.to_string(), } } } -impl fmt::Display for SyntheticDependencyLocation { +impl fmt::Display for SyntheticDependencyName { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { write!(f, "{}", self.name) } @@ -91,8 +91,8 @@ impl fmt::Display for SyntheticDependencyLocation { #[derive(Debug, Clone)] pub enum DependencyLocation { - Real(RealDependencyLocation), - Synthetic(SyntheticDependencyLocation), + Real(DependencyRange), + Synthetic(SyntheticDependencyName), } impl fmt::Display for DependencyLocation { diff --git a/crates/rspack_core/src/dependency/dependency_trait.rs b/crates/rspack_core/src/dependency/dependency_trait.rs index 7b9eb202c30..bbeebc14d0f 100644 --- a/crates/rspack_core/src/dependency/dependency_trait.rs +++ b/crates/rspack_core/src/dependency/dependency_trait.rs @@ -8,8 +8,8 @@ use swc_core::ecma::atoms::Atom; use super::dependency_template::AsDependencyTemplate; use super::module_dependency::*; +use super::DependencyRange; use super::ExportsSpec; -use super::RealDependencyLocation; use super::{DependencyCategory, DependencyId, DependencyType}; use crate::create_exports_object_referenced; use crate::AsContextDependency; @@ -78,7 +78,7 @@ pub trait Dependency: None } - fn range(&self) -> Option<&RealDependencyLocation> { + fn range(&self) -> Option<&DependencyRange> { None } diff --git a/crates/rspack_core/src/diagnostics.rs b/crates/rspack_core/src/diagnostics.rs index 7e6ad787d78..94506e5e4f0 100644 --- a/crates/rspack_core/src/diagnostics.rs +++ b/crates/rspack_core/src/diagnostics.rs @@ -9,7 +9,7 @@ use rspack_error::{ }; use rspack_util::ext::AsAny; -use crate::{BoxLoader, RealDependencyLocation}; +use crate::{BoxLoader, DependencyRange}; ///////////////////// Module Factory ///////////////////// @@ -18,7 +18,7 @@ use crate::{BoxLoader, RealDependencyLocation}; pub struct EmptyDependency(Box); impl EmptyDependency { - pub fn new(span: RealDependencyLocation) -> Self { + pub fn new(span: DependencyRange) -> Self { Self( TraceableError::from_lazy_file( span.start as usize, diff --git a/crates/rspack_core/src/normal_module_factory.rs b/crates/rspack_core/src/normal_module_factory.rs index 4e07a9966e7..2859d227df5 100644 --- a/crates/rspack_core/src/normal_module_factory.rs +++ b/crates/rspack_core/src/normal_module_factory.rs @@ -13,10 +13,10 @@ use swc_core::common::Span; use crate::{ diagnostics::EmptyDependency, module_rules_matcher, parse_resource, resolve, stringify_loaders_and_resource, BoxLoader, BoxModule, CompilerOptions, Context, Dependency, - DependencyCategory, FuncUseCtx, GeneratorOptions, ModuleExt, ModuleFactory, + DependencyCategory, DependencyRange, FuncUseCtx, GeneratorOptions, ModuleExt, ModuleFactory, ModuleFactoryCreateData, ModuleFactoryResult, ModuleIdentifier, ModuleLayer, ModuleRuleEffect, ModuleRuleEnforce, ModuleRuleUse, ModuleRuleUseLoader, ModuleType, NormalModule, - ParserAndGenerator, ParserOptions, RawModule, RealDependencyLocation, Resolve, ResolveArgs, + ParserAndGenerator, ParserOptions, RawModule, Resolve, ResolveArgs, ResolveOptionsWithDependencyType, ResolveResult, Resolver, ResolverFactory, ResourceData, ResourceParsedData, RunnerContext, SharedPluginDriver, }; @@ -231,9 +231,7 @@ impl NormalModuleFactory { if first_char.is_none() { let span = dependency.source_span().unwrap_or_default(); - return Err( - EmptyDependency::new(RealDependencyLocation::new(span.start, span.end)).into(), - ); + return Err(EmptyDependency::new(DependencyRange::new(span.start, span.end)).into()); } // See: https://webpack.js.org/concepts/loaders/#inline diff --git a/crates/rspack_plugin_css/src/dependency/compose.rs b/crates/rspack_plugin_css/src/dependency/compose.rs index 4ab5d795ddf..19cde2c1db5 100644 --- a/crates/rspack_plugin_css/src/dependency/compose.rs +++ b/crates/rspack_plugin_css/src/dependency/compose.rs @@ -1,17 +1,17 @@ use rspack_core::{ AsContextDependency, AsDependencyTemplate, Dependency, DependencyCategory, DependencyId, - DependencyType, ModuleDependency, RealDependencyLocation, + DependencyRange, DependencyType, ModuleDependency, }; #[derive(Debug, Clone)] pub struct CssComposeDependency { id: DependencyId, request: String, - range: RealDependencyLocation, + range: DependencyRange, } impl CssComposeDependency { - pub fn new(request: String, range: RealDependencyLocation) -> Self { + pub fn new(request: String, range: DependencyRange) -> Self { Self { id: DependencyId::new(), request, @@ -33,7 +33,7 @@ impl Dependency for CssComposeDependency { &DependencyType::CssCompose } - fn range(&self) -> Option<&RealDependencyLocation> { + fn range(&self) -> Option<&DependencyRange> { Some(&self.range) } diff --git a/crates/rspack_plugin_css/src/dependency/import.rs b/crates/rspack_plugin_css/src/dependency/import.rs index 6982c685d44..6e5e1d547ab 100644 --- a/crates/rspack_plugin_css/src/dependency/import.rs +++ b/crates/rspack_plugin_css/src/dependency/import.rs @@ -1,18 +1,18 @@ use rspack_core::{ - AsContextDependency, Compilation, Dependency, DependencyCategory, DependencyId, - DependencyTemplate, DependencyType, ModuleDependency, RealDependencyLocation, RuntimeSpec, - TemplateContext, TemplateReplaceSource, + AsContextDependency, Compilation, Dependency, DependencyCategory, DependencyId, DependencyRange, + DependencyTemplate, DependencyType, ModuleDependency, RuntimeSpec, TemplateContext, + TemplateReplaceSource, }; #[derive(Debug, Clone)] pub struct CssImportDependency { id: DependencyId, request: String, - range: RealDependencyLocation, + range: DependencyRange, } impl CssImportDependency { - pub fn new(request: String, range: RealDependencyLocation) -> Self { + pub fn new(request: String, range: DependencyRange) -> Self { Self { id: DependencyId::new(), request, @@ -34,7 +34,7 @@ impl Dependency for CssImportDependency { &DependencyType::CssImport } - fn range(&self) -> Option<&RealDependencyLocation> { + fn range(&self) -> Option<&DependencyRange> { Some(&self.range) } diff --git a/crates/rspack_plugin_css/src/dependency/url.rs b/crates/rspack_plugin_css/src/dependency/url.rs index 5e2d3f5e0f6..72b23344db5 100644 --- a/crates/rspack_plugin_css/src/dependency/url.rs +++ b/crates/rspack_plugin_css/src/dependency/url.rs @@ -1,7 +1,7 @@ use rspack_core::{ AsContextDependency, CodeGenerationDataFilename, CodeGenerationDataUrl, Compilation, Dependency, - DependencyCategory, DependencyId, DependencyTemplate, DependencyType, ModuleDependency, - ModuleIdentifier, PublicPath, RealDependencyLocation, RuntimeSpec, TemplateContext, + DependencyCategory, DependencyId, DependencyRange, DependencyTemplate, DependencyType, + ModuleDependency, ModuleIdentifier, PublicPath, RuntimeSpec, TemplateContext, TemplateReplaceSource, }; @@ -11,12 +11,12 @@ use crate::utils::{css_escape_string, AUTO_PUBLIC_PATH_PLACEHOLDER}; pub struct CssUrlDependency { id: DependencyId, request: String, - range: RealDependencyLocation, + range: DependencyRange, replace_function: bool, } impl CssUrlDependency { - pub fn new(request: String, range: RealDependencyLocation, replace_function: bool) -> Self { + pub fn new(request: String, range: DependencyRange, replace_function: bool) -> Self { Self { request, range, @@ -64,7 +64,7 @@ impl Dependency for CssUrlDependency { &DependencyType::CssUrl } - fn range(&self) -> Option<&RealDependencyLocation> { + fn range(&self) -> Option<&DependencyRange> { Some(&self.range) } diff --git a/crates/rspack_plugin_css/src/parser_and_generator/mod.rs b/crates/rspack_plugin_css/src/parser_and_generator/mod.rs index 8a81021f42b..4f8adfd48cb 100644 --- a/crates/rspack_plugin_css/src/parser_and_generator/mod.rs +++ b/crates/rspack_plugin_css/src/parser_and_generator/mod.rs @@ -10,10 +10,10 @@ use rspack_core::{ diagnostics::map_box_diagnostics_to_module_parse_diagnostics, rspack_sources::{BoxSource, ConcatSource, RawSource, ReplaceSource, Source, SourceExt}, BuildMetaDefaultObject, BuildMetaExportsType, ChunkGraph, Compilation, ConstDependency, - CssExportsConvention, Dependency, DependencyId, DependencyTemplate, GenerateContext, - LocalIdentName, Module, ModuleDependency, ModuleGraph, ModuleIdentifier, ModuleType, - NormalModule, ParseContext, ParseResult, ParserAndGenerator, RealDependencyLocation, RuntimeSpec, - SourceType, TemplateContext, UsageState, + CssExportsConvention, Dependency, DependencyId, DependencyRange, DependencyTemplate, + GenerateContext, LocalIdentName, Module, ModuleDependency, ModuleGraph, ModuleIdentifier, + ModuleType, NormalModule, ParseContext, ParseResult, ParserAndGenerator, RuntimeSpec, SourceType, + TemplateContext, UsageState, }; use rspack_core::{ModuleInitFragments, RuntimeGlobals}; use rspack_error::{ @@ -161,7 +161,7 @@ impl ParserAndGenerator for CssParserAndGenerator { let request = normalize_url(request); let dep = Box::new(CssUrlDependency::new( request, - RealDependencyLocation::new(range.start, range.end), + DependencyRange::new(range.start, range.end), matches!(kind, css_module_lexer::UrlRangeKind::Function), )); dependencies.push(dep.clone()); @@ -186,7 +186,7 @@ impl ParserAndGenerator for CssParserAndGenerator { ); dependencies.push(Box::new(CssImportDependency::new( request.to_string(), - RealDependencyLocation::new(range.start, range.end), + DependencyRange::new(range.start, range.end), ))); } css_module_lexer::Dependency::Replace { content, range } => presentational_dependencies @@ -280,7 +280,7 @@ impl ParserAndGenerator for CssParserAndGenerator { let from = from.trim_matches(|c| c == '\'' || c == '"'); let dep = CssComposeDependency::new( from.to_string(), - RealDependencyLocation::new(range.start, range.end), + DependencyRange::new(range.start, range.end), ); dep_id = Some(*dep.id()); dependencies.push(Box::new(dep)); diff --git a/crates/rspack_plugin_extract_css/src/css_dependency.rs b/crates/rspack_plugin_extract_css/src/css_dependency.rs index f9d5d9af060..baa5207d38f 100644 --- a/crates/rspack_plugin_extract_css/src/css_dependency.rs +++ b/crates/rspack_plugin_extract_css/src/css_dependency.rs @@ -3,7 +3,7 @@ use std::path::PathBuf; use rspack_collections::IdentifierSet; use rspack_core::{ AffectType, AsContextDependency, AsDependencyTemplate, ConnectionState, Dependency, - DependencyCategory, DependencyId, ModuleDependency, ModuleGraph, RealDependencyLocation, + DependencyCategory, DependencyId, DependencyRange, ModuleDependency, ModuleGraph, }; use rustc_hash::FxHashSet; @@ -26,7 +26,7 @@ pub struct CssDependency { // determine module's postOrderIndex // @TODO(shulaoda) Does this have any additional side effects? // pub(crate) order_index: u32, - range: RealDependencyLocation, + range: DependencyRange, resource_identifier: String, pub(crate) cacheable: bool, pub(crate) file_dependencies: FxHashSet, @@ -46,7 +46,7 @@ impl CssDependency { supports: Option, source_map: Option, identifier_index: u32, - range: RealDependencyLocation, + range: DependencyRange, cacheable: bool, file_dependencies: FxHashSet, context_dependencies: FxHashSet, @@ -108,7 +108,7 @@ impl Dependency for CssDependency { // it can keep the right order, but Rspack uses HashSet, // when determining the postOrderIndex, Rspack uses // dependency span to set correct order - fn range(&self) -> Option<&RealDependencyLocation> { + fn range(&self) -> Option<&DependencyRange> { Some(&self.range) } diff --git a/crates/rspack_plugin_extract_css/src/parser_plugin.rs b/crates/rspack_plugin_extract_css/src/parser_plugin.rs index 2b6b9e56cf3..1f3d3174d6f 100644 --- a/crates/rspack_plugin_extract_css/src/parser_plugin.rs +++ b/crates/rspack_plugin_extract_css/src/parser_plugin.rs @@ -1,4 +1,4 @@ -use rspack_core::{BoxDependency, RealDependencyLocation}; +use rspack_core::{BoxDependency, DependencyRange}; use rspack_plugin_javascript::{visitors::JavascriptParser, JavascriptParserPlugin}; use rspack_util::fx_hash::FxDashMap; use serde::Deserialize; @@ -55,7 +55,7 @@ impl JavascriptParserPlugin for PluginCssExtractParserPlugin { supports.clone(), source_map.clone(), *identifier_index, - RealDependencyLocation::new(index as u32, (index + 1) as u32), + DependencyRange::new(index as u32, (index + 1) as u32), parser.build_info.cacheable, parser.build_info.file_dependencies.clone(), parser.build_info.context_dependencies.clone(), diff --git a/crates/rspack_plugin_javascript/src/dependency/commonjs/common_js_export_require_dependency.rs b/crates/rspack_plugin_javascript/src/dependency/commonjs/common_js_export_require_dependency.rs index 6e6e557d97e..a1f6d1c89e9 100644 --- a/crates/rspack_plugin_javascript/src/dependency/commonjs/common_js_export_require_dependency.rs +++ b/crates/rspack_plugin_javascript/src/dependency/commonjs/common_js_export_require_dependency.rs @@ -1,11 +1,11 @@ use itertools::Itertools; use rspack_core::{ module_raw, process_export_info, property_access, AsContextDependency, Compilation, Dependency, - DependencyCategory, DependencyId, DependencyTemplate, DependencyType, ExportInfoProvided, - ExportNameOrSpec, ExportSpec, ExportsOfExportsSpec, ExportsSpec, ExportsType, + DependencyCategory, DependencyId, DependencyRange, DependencyTemplate, DependencyType, + ExportInfoProvided, ExportNameOrSpec, ExportSpec, ExportsOfExportsSpec, ExportsSpec, ExportsType, ExtendedReferencedExport, ModuleDependency, ModuleGraph, ModuleIdentifier, Nullable, - RealDependencyLocation, ReferencedExport, RuntimeGlobals, RuntimeSpec, TemplateContext, - TemplateReplaceSource, UsageState, UsedName, + ReferencedExport, RuntimeGlobals, RuntimeSpec, TemplateContext, TemplateReplaceSource, + UsageState, UsedName, }; use rustc_hash::FxHashSet; use swc_core::atoms::Atom; @@ -18,7 +18,7 @@ pub struct CommonJsExportRequireDependency { id: DependencyId, request: String, optional: bool, - range: RealDependencyLocation, + range: DependencyRange, base: ExportsBase, names: Vec, ids: Vec, @@ -29,7 +29,7 @@ impl CommonJsExportRequireDependency { pub fn new( request: String, optional: bool, - range: RealDependencyLocation, + range: DependencyRange, base: ExportsBase, names: Vec, result_used: bool, diff --git a/crates/rspack_plugin_javascript/src/dependency/commonjs/common_js_full_require_dependency.rs b/crates/rspack_plugin_javascript/src/dependency/commonjs/common_js_full_require_dependency.rs index 6da0669be68..772ed0bd244 100644 --- a/crates/rspack_plugin_javascript/src/dependency/commonjs/common_js_full_require_dependency.rs +++ b/crates/rspack_plugin_javascript/src/dependency/commonjs/common_js_full_require_dependency.rs @@ -1,7 +1,6 @@ use rspack_core::{ - module_id, property_access, to_normal_comment, Compilation, ExportsType, - ExtendedReferencedExport, ModuleGraph, RealDependencyLocation, RuntimeGlobals, RuntimeSpec, - UsedName, + module_id, property_access, to_normal_comment, Compilation, DependencyRange, ExportsType, + ExtendedReferencedExport, ModuleGraph, RuntimeGlobals, RuntimeSpec, UsedName, }; use rspack_core::{AsContextDependency, Dependency, DependencyCategory}; use rspack_core::{DependencyId, DependencyTemplate}; @@ -14,7 +13,7 @@ pub struct CommonJsFullRequireDependency { id: DependencyId, request: String, names: Vec, - range: RealDependencyLocation, + range: DependencyRange, is_call: bool, optional: bool, asi_safe: bool, @@ -24,7 +23,7 @@ impl CommonJsFullRequireDependency { pub fn new( request: String, names: Vec, - range: RealDependencyLocation, + range: DependencyRange, is_call: bool, optional: bool, asi_safe: bool, @@ -58,7 +57,7 @@ impl Dependency for CommonJsFullRequireDependency { Some(self.range.to_string()) } - fn range(&self) -> Option<&RealDependencyLocation> { + fn range(&self) -> Option<&DependencyRange> { Some(&self.range) } diff --git a/crates/rspack_plugin_javascript/src/dependency/commonjs/common_js_require_dependency.rs b/crates/rspack_plugin_javascript/src/dependency/commonjs/common_js_require_dependency.rs index 74ff2d3c5bf..77df7a4ec90 100644 --- a/crates/rspack_plugin_javascript/src/dependency/commonjs/common_js_require_dependency.rs +++ b/crates/rspack_plugin_javascript/src/dependency/commonjs/common_js_require_dependency.rs @@ -1,4 +1,4 @@ -use rspack_core::{module_id, Compilation, RealDependencyLocation, RuntimeSpec}; +use rspack_core::{module_id, Compilation, DependencyRange, RuntimeSpec}; use rspack_core::{AsContextDependency, Dependency, DependencyCategory}; use rspack_core::{DependencyId, DependencyTemplate}; use rspack_core::{DependencyType, ModuleDependency}; @@ -9,15 +9,15 @@ pub struct CommonJsRequireDependency { id: DependencyId, request: String, optional: bool, - range: RealDependencyLocation, - range_expr: Option, + range: DependencyRange, + range_expr: Option, } impl CommonJsRequireDependency { pub fn new( request: String, - range: RealDependencyLocation, - range_expr: Option, + range: DependencyRange, + range_expr: Option, optional: bool, ) -> Self { Self { @@ -47,7 +47,7 @@ impl Dependency for CommonJsRequireDependency { &DependencyType::CjsRequire } - fn range(&self) -> Option<&RealDependencyLocation> { + fn range(&self) -> Option<&DependencyRange> { self.range_expr.as_ref() } diff --git a/crates/rspack_plugin_javascript/src/dependency/commonjs/require_header_dependency.rs b/crates/rspack_plugin_javascript/src/dependency/commonjs/require_header_dependency.rs index 5087ca509eb..3f88dd88d47 100644 --- a/crates/rspack_plugin_javascript/src/dependency/commonjs/require_header_dependency.rs +++ b/crates/rspack_plugin_javascript/src/dependency/commonjs/require_header_dependency.rs @@ -1,18 +1,17 @@ use rspack_core::DependencyId; use rspack_core::{ - AsContextDependency, AsModuleDependency, Compilation, Dependency, RealDependencyLocation, - RuntimeSpec, + AsContextDependency, AsModuleDependency, Compilation, Dependency, DependencyRange, RuntimeSpec, }; use rspack_core::{DependencyTemplate, RuntimeGlobals, TemplateContext}; #[derive(Debug, Clone)] pub struct RequireHeaderDependency { id: DependencyId, - range: RealDependencyLocation, + range: DependencyRange, } impl RequireHeaderDependency { - pub fn new(range: RealDependencyLocation) -> Self { + pub fn new(range: DependencyRange) -> Self { Self { id: DependencyId::new(), range, diff --git a/crates/rspack_plugin_javascript/src/dependency/commonjs/require_resolve_dependency.rs b/crates/rspack_plugin_javascript/src/dependency/commonjs/require_resolve_dependency.rs index e1fc470a77f..3fea1d71dcf 100644 --- a/crates/rspack_plugin_javascript/src/dependency/commonjs/require_resolve_dependency.rs +++ b/crates/rspack_plugin_javascript/src/dependency/commonjs/require_resolve_dependency.rs @@ -1,7 +1,7 @@ use rspack_core::{ module_id, AsContextDependency, Compilation, Dependency, DependencyCategory, DependencyId, - DependencyTemplate, DependencyType, ExtendedReferencedExport, ModuleDependency, ModuleGraph, - RealDependencyLocation, RuntimeSpec, TemplateContext, TemplateReplaceSource, + DependencyRange, DependencyTemplate, DependencyType, ExtendedReferencedExport, ModuleDependency, + ModuleGraph, RuntimeSpec, TemplateContext, TemplateReplaceSource, }; #[derive(Debug, Clone)] @@ -9,12 +9,12 @@ pub struct RequireResolveDependency { pub id: DependencyId, pub request: String, pub weak: bool, - range: RealDependencyLocation, + range: DependencyRange, optional: bool, } impl RequireResolveDependency { - pub fn new(request: String, range: RealDependencyLocation, weak: bool, optional: bool) -> Self { + pub fn new(request: String, range: DependencyRange, weak: bool, optional: bool) -> Self { Self { range, request, @@ -38,7 +38,7 @@ impl Dependency for RequireResolveDependency { &DependencyType::RequireResolve } - fn range(&self) -> Option<&RealDependencyLocation> { + fn range(&self) -> Option<&DependencyRange> { Some(&self.range) } diff --git a/crates/rspack_plugin_javascript/src/dependency/commonjs/require_resolve_header_dependency.rs b/crates/rspack_plugin_javascript/src/dependency/commonjs/require_resolve_header_dependency.rs index 83b97ce3a42..50ef4e5fe3e 100644 --- a/crates/rspack_plugin_javascript/src/dependency/commonjs/require_resolve_header_dependency.rs +++ b/crates/rspack_plugin_javascript/src/dependency/commonjs/require_resolve_header_dependency.rs @@ -1,16 +1,16 @@ use rspack_core::{ AffectType, AsContextDependency, AsModuleDependency, Compilation, Dependency, DependencyId, - DependencyTemplate, RealDependencyLocation, RuntimeSpec, TemplateContext, TemplateReplaceSource, + DependencyRange, DependencyTemplate, RuntimeSpec, TemplateContext, TemplateReplaceSource, }; #[derive(Debug, Clone)] pub struct RequireResolveHeaderDependency { id: DependencyId, - range: RealDependencyLocation, + range: DependencyRange, } impl RequireResolveHeaderDependency { - pub fn new(range: RealDependencyLocation) -> Self { + pub fn new(range: DependencyRange) -> Self { Self { id: DependencyId::new(), range, diff --git a/crates/rspack_plugin_javascript/src/dependency/context/common_js_require_context_dependency.rs b/crates/rspack_plugin_javascript/src/dependency/context/common_js_require_context_dependency.rs index f4a00bea6ec..db85cd03947 100644 --- a/crates/rspack_plugin_javascript/src/dependency/context/common_js_require_context_dependency.rs +++ b/crates/rspack_plugin_javascript/src/dependency/context/common_js_require_context_dependency.rs @@ -1,7 +1,7 @@ use rspack_core::{ AsModuleDependency, Compilation, ContextDependency, ContextOptions, Dependency, - DependencyCategory, DependencyId, DependencyTemplate, DependencyType, ModuleGraph, - RealDependencyLocation, RuntimeSpec, TemplateContext, TemplateReplaceSource, + DependencyCategory, DependencyId, DependencyRange, DependencyTemplate, DependencyType, + ModuleGraph, RuntimeSpec, TemplateContext, TemplateReplaceSource, }; use rspack_error::Diagnostic; @@ -12,8 +12,8 @@ use super::{ #[derive(Debug, Clone)] pub struct CommonJsRequireContextDependency { id: DependencyId, - range: RealDependencyLocation, - range_callee: RealDependencyLocation, + range: DependencyRange, + range_callee: DependencyRange, resource_identifier: String, options: ContextOptions, optional: bool, @@ -23,8 +23,8 @@ pub struct CommonJsRequireContextDependency { impl CommonJsRequireContextDependency { pub fn new( options: ContextOptions, - range: RealDependencyLocation, - range_callee: RealDependencyLocation, + range: DependencyRange, + range_callee: DependencyRange, optional: bool, ) -> Self { let resource_identifier = create_resource_identifier_for_context_dependency(None, &options); @@ -53,7 +53,7 @@ impl Dependency for CommonJsRequireContextDependency { &DependencyType::CommonJSRequireContext } - fn range(&self) -> Option<&RealDependencyLocation> { + fn range(&self) -> Option<&DependencyRange> { Some(&self.range) } diff --git a/crates/rspack_plugin_javascript/src/dependency/context/import_context_dependency.rs b/crates/rspack_plugin_javascript/src/dependency/context/import_context_dependency.rs index d52ff9677aa..f9300be561d 100644 --- a/crates/rspack_plugin_javascript/src/dependency/context/import_context_dependency.rs +++ b/crates/rspack_plugin_javascript/src/dependency/context/import_context_dependency.rs @@ -1,7 +1,7 @@ use rspack_core::{ AsModuleDependency, Compilation, ContextDependency, ContextOptions, Dependency, - DependencyCategory, DependencyId, DependencyTemplate, DependencyType, ModuleGraph, - RealDependencyLocation, RuntimeSpec, TemplateContext, TemplateReplaceSource, + DependencyCategory, DependencyId, DependencyRange, DependencyTemplate, DependencyType, + ModuleGraph, RuntimeSpec, TemplateContext, TemplateReplaceSource, }; use rspack_error::Diagnostic; @@ -13,8 +13,8 @@ use super::{ pub struct ImportContextDependency { id: DependencyId, options: ContextOptions, - range: RealDependencyLocation, - range_callee: RealDependencyLocation, + range: DependencyRange, + range_callee: DependencyRange, resource_identifier: String, optional: bool, critical: Option, @@ -23,8 +23,8 @@ pub struct ImportContextDependency { impl ImportContextDependency { pub fn new( options: ContextOptions, - range: RealDependencyLocation, - range_callee: RealDependencyLocation, + range: DependencyRange, + range_callee: DependencyRange, optional: bool, ) -> Self { let resource_identifier = create_resource_identifier_for_context_dependency(None, &options); @@ -53,7 +53,7 @@ impl Dependency for ImportContextDependency { &DependencyType::ImportContext } - fn range(&self) -> Option<&RealDependencyLocation> { + fn range(&self) -> Option<&DependencyRange> { Some(&self.range) } diff --git a/crates/rspack_plugin_javascript/src/dependency/context/import_meta_context_dependency.rs b/crates/rspack_plugin_javascript/src/dependency/context/import_meta_context_dependency.rs index a7c5a9bad85..2deac51f215 100644 --- a/crates/rspack_plugin_javascript/src/dependency/context/import_meta_context_dependency.rs +++ b/crates/rspack_plugin_javascript/src/dependency/context/import_meta_context_dependency.rs @@ -1,7 +1,7 @@ use rspack_core::{ module_raw, AsModuleDependency, Compilation, ContextDependency, ContextOptions, Dependency, - DependencyCategory, DependencyId, DependencyTemplate, DependencyType, ModuleGraph, - RealDependencyLocation, RuntimeSpec, TemplateContext, TemplateReplaceSource, + DependencyCategory, DependencyId, DependencyRange, DependencyTemplate, DependencyType, + ModuleGraph, RuntimeSpec, TemplateContext, TemplateReplaceSource, }; use rspack_error::Diagnostic; @@ -11,14 +11,14 @@ use super::create_resource_identifier_for_context_dependency; pub struct ImportMetaContextDependency { id: DependencyId, options: ContextOptions, - range: RealDependencyLocation, + range: DependencyRange, resource_identifier: String, optional: bool, critical: Option, } impl ImportMetaContextDependency { - pub fn new(options: ContextOptions, range: RealDependencyLocation, optional: bool) -> Self { + pub fn new(options: ContextOptions, range: DependencyRange, optional: bool) -> Self { let resource_identifier = create_resource_identifier_for_context_dependency(None, &options); Self { options, @@ -44,7 +44,7 @@ impl Dependency for ImportMetaContextDependency { &DependencyType::ImportMetaContext } - fn range(&self) -> Option<&RealDependencyLocation> { + fn range(&self) -> Option<&DependencyRange> { Some(&self.range) } diff --git a/crates/rspack_plugin_javascript/src/dependency/context/mod.rs b/crates/rspack_plugin_javascript/src/dependency/context/mod.rs index 3bffc502332..2a878792fa4 100644 --- a/crates/rspack_plugin_javascript/src/dependency/context/mod.rs +++ b/crates/rspack_plugin_javascript/src/dependency/context/mod.rs @@ -10,8 +10,8 @@ pub use import_meta_context_dependency::ImportMetaContextDependency; pub use require_context_dependency::RequireContextDependency; pub use require_resolve_context_dependency::RequireResolveContextDependency; use rspack_core::{ - module_raw, ContextDependency, ContextMode, ContextOptions, RealDependencyLocation, - TemplateContext, TemplateReplaceSource, + module_raw, ContextDependency, ContextMode, ContextOptions, DependencyRange, TemplateContext, + TemplateReplaceSource, }; fn create_resource_identifier_for_context_dependency( @@ -80,7 +80,7 @@ fn context_dependency_template_as_id( dep: &dyn ContextDependency, source: &mut TemplateReplaceSource, code_generatable_context: &mut TemplateContext, - range: &RealDependencyLocation, + range: &DependencyRange, ) { let TemplateContext { compilation, diff --git a/crates/rspack_plugin_javascript/src/dependency/context/require_context_dependency.rs b/crates/rspack_plugin_javascript/src/dependency/context/require_context_dependency.rs index 5d0041e1237..c8bd043a876 100644 --- a/crates/rspack_plugin_javascript/src/dependency/context/require_context_dependency.rs +++ b/crates/rspack_plugin_javascript/src/dependency/context/require_context_dependency.rs @@ -1,7 +1,7 @@ use rspack_core::{ module_raw, AsModuleDependency, Compilation, ContextDependency, ContextOptions, Dependency, - DependencyCategory, DependencyId, DependencyTemplate, DependencyType, ModuleGraph, - RealDependencyLocation, RuntimeSpec, TemplateContext, TemplateReplaceSource, + DependencyCategory, DependencyId, DependencyRange, DependencyTemplate, DependencyType, + ModuleGraph, RuntimeSpec, TemplateContext, TemplateReplaceSource, }; use rspack_error::Diagnostic; @@ -11,14 +11,14 @@ use super::create_resource_identifier_for_context_dependency; pub struct RequireContextDependency { id: DependencyId, options: ContextOptions, - range: RealDependencyLocation, + range: DependencyRange, resource_identifier: String, optional: bool, critical: Option, } impl RequireContextDependency { - pub fn new(options: ContextOptions, range: RealDependencyLocation, optional: bool) -> Self { + pub fn new(options: ContextOptions, range: DependencyRange, optional: bool) -> Self { let resource_identifier = create_resource_identifier_for_context_dependency(None, &options); Self { options, @@ -44,7 +44,7 @@ impl Dependency for RequireContextDependency { &DependencyType::RequireContext } - fn range(&self) -> Option<&RealDependencyLocation> { + fn range(&self) -> Option<&DependencyRange> { Some(&self.range) } diff --git a/crates/rspack_plugin_javascript/src/dependency/context/require_resolve_context_dependency.rs b/crates/rspack_plugin_javascript/src/dependency/context/require_resolve_context_dependency.rs index 067bbf8429e..0affdac24b7 100644 --- a/crates/rspack_plugin_javascript/src/dependency/context/require_resolve_context_dependency.rs +++ b/crates/rspack_plugin_javascript/src/dependency/context/require_resolve_context_dependency.rs @@ -1,7 +1,7 @@ use rspack_core::{ AffectType, AsModuleDependency, Compilation, ContextDependency, ContextOptions, - ContextTypePrefix, Dependency, DependencyCategory, DependencyId, DependencyTemplate, - DependencyType, RealDependencyLocation, RuntimeSpec, TemplateContext, TemplateReplaceSource, + ContextTypePrefix, Dependency, DependencyCategory, DependencyId, DependencyRange, + DependencyTemplate, DependencyType, RuntimeSpec, TemplateContext, TemplateReplaceSource, }; use rspack_error::Diagnostic; @@ -11,14 +11,14 @@ use super::{context_dependency_template_as_id, create_resource_identifier_for_co pub struct RequireResolveContextDependency { id: DependencyId, options: ContextOptions, - range: RealDependencyLocation, + range: DependencyRange, resource_identifier: String, optional: bool, critical: Option, } impl RequireResolveContextDependency { - pub fn new(options: ContextOptions, range: RealDependencyLocation, optional: bool) -> Self { + pub fn new(options: ContextOptions, range: DependencyRange, optional: bool) -> Self { let resource_identifier = create_resource_identifier_for_context_dependency(None, &options); Self { id: DependencyId::new(), @@ -44,7 +44,7 @@ impl Dependency for RequireResolveContextDependency { &DependencyType::RequireContext } - fn range(&self) -> Option<&RealDependencyLocation> { + fn range(&self) -> Option<&DependencyRange> { Some(&self.range) } diff --git a/crates/rspack_plugin_javascript/src/dependency/esm/harmony_export_expression_dependency.rs b/crates/rspack_plugin_javascript/src/dependency/esm/harmony_export_expression_dependency.rs index 597944a608f..a2048d69199 100644 --- a/crates/rspack_plugin_javascript/src/dependency/esm/harmony_export_expression_dependency.rs +++ b/crates/rspack_plugin_javascript/src/dependency/esm/harmony_export_expression_dependency.rs @@ -3,8 +3,8 @@ use rspack_collections::{Identifier, IdentifierSet}; use rspack_core::rspack_sources::ReplacementEnforce; use rspack_core::{ property_access, AsContextDependency, AsModuleDependency, Compilation, Dependency, DependencyId, - DependencyTemplate, DependencyType, ExportNameOrSpec, ExportsOfExportsSpec, ExportsSpec, - HarmonyExportInitFragment, ModuleGraph, RealDependencyLocation, RuntimeGlobals, RuntimeSpec, + DependencyRange, DependencyTemplate, DependencyType, ExportNameOrSpec, ExportsOfExportsSpec, + ExportsSpec, HarmonyExportInitFragment, ModuleGraph, RuntimeGlobals, RuntimeSpec, TemplateContext, TemplateReplaceSource, UsedName, DEFAULT_EXPORT, }; use swc_core::atoms::Atom; @@ -19,13 +19,13 @@ pub enum DeclarationId { #[derive(Debug, Clone)] pub struct DeclarationInfo { - range: RealDependencyLocation, + range: DependencyRange, prefix: String, suffix: String, } impl DeclarationInfo { - pub fn new(range: RealDependencyLocation, prefix: String, suffix: String) -> Self { + pub fn new(range: DependencyRange, prefix: String, suffix: String) -> Self { Self { range, prefix, @@ -37,15 +37,15 @@ impl DeclarationInfo { #[derive(Debug, Clone)] pub struct HarmonyExportExpressionDependency { id: DependencyId, - range: RealDependencyLocation, - range_stmt: RealDependencyLocation, + range: DependencyRange, + range_stmt: DependencyRange, declaration: Option, } impl HarmonyExportExpressionDependency { pub fn new( - range: RealDependencyLocation, - range_stmt: RealDependencyLocation, + range: DependencyRange, + range_stmt: DependencyRange, declaration: Option, ) -> Self { Self { diff --git a/crates/rspack_plugin_javascript/src/dependency/esm/harmony_export_header_dependency.rs b/crates/rspack_plugin_javascript/src/dependency/esm/harmony_export_header_dependency.rs index a5584a91d9d..700cc9f15cd 100644 --- a/crates/rspack_plugin_javascript/src/dependency/esm/harmony_export_header_dependency.rs +++ b/crates/rspack_plugin_javascript/src/dependency/esm/harmony_export_header_dependency.rs @@ -1,7 +1,6 @@ use rspack_core::{ - AsContextDependency, AsModuleDependency, Compilation, Dependency, DependencyId, - DependencyTemplate, DependencyType, RealDependencyLocation, RuntimeSpec, TemplateContext, - TemplateReplaceSource, + AsContextDependency, AsModuleDependency, Compilation, Dependency, DependencyId, DependencyRange, + DependencyTemplate, DependencyType, RuntimeSpec, TemplateContext, TemplateReplaceSource, }; // Remove `export` label. @@ -10,12 +9,12 @@ use rspack_core::{ #[derive(Debug, Clone)] pub struct HarmonyExportHeaderDependency { id: DependencyId, - range: RealDependencyLocation, - range_decl: Option, + range: DependencyRange, + range_decl: Option, } impl HarmonyExportHeaderDependency { - pub fn new(range: RealDependencyLocation, range_decl: Option) -> Self { + pub fn new(range: DependencyRange, range_decl: Option) -> Self { Self { range, range_decl, diff --git a/crates/rspack_plugin_javascript/src/dependency/esm/harmony_export_imported_specifier_dependency.rs b/crates/rspack_plugin_javascript/src/dependency/esm/harmony_export_imported_specifier_dependency.rs index 5ccfc8e8967..6c0fc1874ce 100644 --- a/crates/rspack_plugin_javascript/src/dependency/esm/harmony_export_imported_specifier_dependency.rs +++ b/crates/rspack_plugin_javascript/src/dependency/esm/harmony_export_imported_specifier_dependency.rs @@ -7,13 +7,13 @@ use rspack_core::{ create_exports_object_referenced, create_no_exports_referenced, filter_runtime, get_exports_type, process_export_info, property_access, property_name, string_of_used_name, AsContextDependency, Compilation, ConditionalInitFragment, ConnectionState, Dependency, DependencyCategory, - DependencyCondition, DependencyConditionFn, DependencyId, DependencyTemplate, DependencyType, - ExportInfo, ExportInfoProvided, ExportNameOrSpec, ExportPresenceMode, ExportSpec, ExportsInfo, - ExportsOfExportsSpec, ExportsSpec, ExportsType, ExtendedReferencedExport, + DependencyCondition, DependencyConditionFn, DependencyId, DependencyRange, DependencyTemplate, + DependencyType, ExportInfo, ExportInfoProvided, ExportNameOrSpec, ExportPresenceMode, ExportSpec, + ExportsInfo, ExportsOfExportsSpec, ExportsSpec, ExportsType, ExtendedReferencedExport, HarmonyExportInitFragment, ImportAttributes, InitFragmentExt, InitFragmentKey, InitFragmentStage, JavascriptParserOptions, ModuleDependency, ModuleGraph, ModuleIdentifier, NormalInitFragment, - RealDependencyLocation, RuntimeCondition, RuntimeGlobals, RuntimeSpec, Template, TemplateContext, - TemplateReplaceSource, UsageState, UsedName, + RuntimeCondition, RuntimeGlobals, RuntimeSpec, Template, TemplateContext, TemplateReplaceSource, + UsageState, UsedName, }; use rspack_error::{ miette::{MietteDiagnostic, Severity}, @@ -41,7 +41,7 @@ pub struct HarmonyExportImportedSpecifierDependency { pub export_all: bool, pub source_order: i32, pub other_star_exports: Option>, - range: RealDependencyLocation, + range: DependencyRange, attributes: Option, resource_identifier: String, export_presence_mode: ExportPresenceMode, @@ -56,7 +56,7 @@ impl HarmonyExportImportedSpecifierDependency { name: Option, export_all: bool, other_star_exports: Option>, - range: RealDependencyLocation, + range: DependencyRange, export_presence_mode: ExportPresenceMode, attributes: Option, ) -> Self { @@ -1054,7 +1054,7 @@ impl Dependency for HarmonyExportImportedSpecifierDependency { Some(self.range.to_string()) } - fn range(&self) -> Option<&RealDependencyLocation> { + fn range(&self) -> Option<&DependencyRange> { Some(&self.range) } diff --git a/crates/rspack_plugin_javascript/src/dependency/esm/harmony_export_specifier_dependency.rs b/crates/rspack_plugin_javascript/src/dependency/esm/harmony_export_specifier_dependency.rs index ab87132bb1b..111bd836178 100644 --- a/crates/rspack_plugin_javascript/src/dependency/esm/harmony_export_specifier_dependency.rs +++ b/crates/rspack_plugin_javascript/src/dependency/esm/harmony_export_specifier_dependency.rs @@ -1,8 +1,8 @@ use rspack_collections::IdentifierSet; use rspack_core::{ AsContextDependency, AsModuleDependency, Compilation, Dependency, DependencyCategory, - DependencyId, DependencyTemplate, DependencyType, ExportNameOrSpec, ExportsOfExportsSpec, - ExportsSpec, HarmonyExportInitFragment, ModuleGraph, RealDependencyLocation, RuntimeSpec, + DependencyId, DependencyRange, DependencyTemplate, DependencyType, ExportNameOrSpec, + ExportsOfExportsSpec, ExportsSpec, HarmonyExportInitFragment, ModuleGraph, RuntimeSpec, TemplateContext, TemplateReplaceSource, UsedName, }; use swc_core::ecma::atoms::Atom; @@ -11,13 +11,13 @@ use swc_core::ecma::atoms::Atom; #[derive(Debug, Clone)] pub struct HarmonyExportSpecifierDependency { id: DependencyId, - range: RealDependencyLocation, + range: DependencyRange, pub name: Atom, pub value: Atom, // id } impl HarmonyExportSpecifierDependency { - pub fn new(name: Atom, value: Atom, range: RealDependencyLocation) -> Self { + pub fn new(name: Atom, value: Atom, range: DependencyRange) -> Self { Self { name, value, diff --git a/crates/rspack_plugin_javascript/src/dependency/esm/harmony_import_dependency.rs b/crates/rspack_plugin_javascript/src/dependency/esm/harmony_import_dependency.rs index 8437204e183..421b0a0cabb 100644 --- a/crates/rspack_plugin_javascript/src/dependency/esm/harmony_import_dependency.rs +++ b/crates/rspack_plugin_javascript/src/dependency/esm/harmony_import_dependency.rs @@ -4,7 +4,7 @@ use std::sync::LazyLock; use rspack_collections::{IdentifierDashMap, IdentifierMap, IdentifierSet}; use rspack_core::Compilation; use rspack_core::DependencyConditionFn; -use rspack_core::RealDependencyLocation; +use rspack_core::DependencyRange; use rspack_core::{ filter_runtime, import_statement, merge_runtime, AsContextDependency, AwaitDependenciesInitFragment, BuildMetaDefaultObject, ConditionalInitFragment, ConnectionState, @@ -47,8 +47,8 @@ pub struct HarmonyImportSideEffectDependency { pub request: Atom, pub source_order: i32, pub id: DependencyId, - pub range: RealDependencyLocation, - pub range_src: RealDependencyLocation, + pub range: DependencyRange, + pub range_src: DependencyRange, pub dependency_type: DependencyType, pub export_all: bool, attributes: Option, @@ -60,8 +60,8 @@ impl HarmonyImportSideEffectDependency { pub fn new( request: Atom, source_order: i32, - range: RealDependencyLocation, - range_src: RealDependencyLocation, + range: DependencyRange, + range_src: DependencyRange, dependency_type: DependencyType, export_all: bool, attributes: Option, @@ -380,7 +380,7 @@ impl Dependency for HarmonyImportSideEffectDependency { Some(self.range.to_string()) } - fn range(&self) -> Option<&RealDependencyLocation> { + fn range(&self) -> Option<&DependencyRange> { Some(&self.range) } diff --git a/crates/rspack_plugin_javascript/src/dependency/esm/harmony_import_specifier_dependency.rs b/crates/rspack_plugin_javascript/src/dependency/esm/harmony_import_specifier_dependency.rs index 514a2ca87d4..0180ece2127 100644 --- a/crates/rspack_plugin_javascript/src/dependency/esm/harmony_import_specifier_dependency.rs +++ b/crates/rspack_plugin_javascript/src/dependency/esm/harmony_import_specifier_dependency.rs @@ -2,10 +2,10 @@ use rspack_collections::IdentifierSet; use rspack_core::{ create_exports_object_referenced, export_from_import, get_dependency_used_by_exports_condition, get_exports_type, AsContextDependency, Compilation, ConnectionState, Dependency, - DependencyCategory, DependencyCondition, DependencyId, DependencyTemplate, DependencyType, - ExportPresenceMode, ExportsType, ExtendedReferencedExport, ImportAttributes, - JavascriptParserOptions, ModuleDependency, ModuleGraph, RealDependencyLocation, ReferencedExport, - RuntimeSpec, TemplateContext, TemplateReplaceSource, UsedByExports, + DependencyCategory, DependencyCondition, DependencyId, DependencyRange, DependencyTemplate, + DependencyType, ExportPresenceMode, ExportsType, ExtendedReferencedExport, ImportAttributes, + JavascriptParserOptions, ModuleDependency, ModuleGraph, ReferencedExport, RuntimeSpec, + TemplateContext, TemplateReplaceSource, UsedByExports, }; use rspack_core::{property_access, ModuleReferenceOptions}; use rspack_error::Diagnostic; @@ -23,7 +23,7 @@ pub struct HarmonyImportSpecifierDependency { source_order: i32, shorthand: bool, asi_safe: bool, - range: RealDependencyLocation, + range: DependencyRange, ids: Vec, call: bool, direct_import: bool, @@ -43,7 +43,7 @@ impl HarmonyImportSpecifierDependency { source_order: i32, shorthand: bool, asi_safe: bool, - range: RealDependencyLocation, + range: DependencyRange, ids: Vec, call: bool, direct_import: bool, @@ -228,7 +228,7 @@ impl Dependency for HarmonyImportSpecifierDependency { Some(self.range.to_string()) } - fn range(&self) -> Option<&RealDependencyLocation> { + fn range(&self) -> Option<&DependencyRange> { Some(&self.range) } diff --git a/crates/rspack_plugin_javascript/src/dependency/esm/import_dependency.rs b/crates/rspack_plugin_javascript/src/dependency/esm/import_dependency.rs index f994de56db2..441848eef7a 100644 --- a/crates/rspack_plugin_javascript/src/dependency/esm/import_dependency.rs +++ b/crates/rspack_plugin_javascript/src/dependency/esm/import_dependency.rs @@ -1,6 +1,6 @@ use rspack_core::{ - create_exports_object_referenced, module_namespace_promise, Compilation, DependencyType, - ExportsType, ExtendedReferencedExport, ImportAttributes, ModuleGraph, RealDependencyLocation, + create_exports_object_referenced, module_namespace_promise, Compilation, DependencyRange, + DependencyType, ExportsType, ExtendedReferencedExport, ImportAttributes, ModuleGraph, ReferencedExport, RuntimeSpec, }; use rspack_core::{AsContextDependency, Dependency}; @@ -56,7 +56,7 @@ pub fn create_import_dependency_referenced_exports( pub struct ImportDependency { id: DependencyId, pub request: Atom, - pub range: RealDependencyLocation, + pub range: DependencyRange, referenced_exports: Option>, attributes: Option, resource_identifier: String, @@ -65,7 +65,7 @@ pub struct ImportDependency { impl ImportDependency { pub fn new( request: Atom, - range: RealDependencyLocation, + range: DependencyRange, referenced_exports: Option>, attributes: Option, ) -> Self { @@ -103,7 +103,7 @@ impl Dependency for ImportDependency { self.attributes.as_ref() } - fn range(&self) -> Option<&RealDependencyLocation> { + fn range(&self) -> Option<&DependencyRange> { Some(&self.range) } diff --git a/crates/rspack_plugin_javascript/src/dependency/esm/import_eager_dependency.rs b/crates/rspack_plugin_javascript/src/dependency/esm/import_eager_dependency.rs index b996032592b..392e62a9b7a 100644 --- a/crates/rspack_plugin_javascript/src/dependency/esm/import_eager_dependency.rs +++ b/crates/rspack_plugin_javascript/src/dependency/esm/import_eager_dependency.rs @@ -1,7 +1,7 @@ use rspack_core::{ module_namespace_promise, AsContextDependency, Compilation, Dependency, DependencyCategory, - DependencyId, DependencyTemplate, DependencyType, ImportAttributes, ModuleDependency, - RealDependencyLocation, RuntimeSpec, TemplateContext, TemplateReplaceSource, + DependencyId, DependencyRange, DependencyTemplate, DependencyType, ImportAttributes, + ModuleDependency, RuntimeSpec, TemplateContext, TemplateReplaceSource, }; use swc_core::ecma::atoms::Atom; @@ -14,7 +14,7 @@ use super::{ pub struct ImportEagerDependency { id: DependencyId, request: Atom, - range: RealDependencyLocation, + range: DependencyRange, referenced_exports: Option>, attributes: Option, resource_identifier: String, @@ -23,7 +23,7 @@ pub struct ImportEagerDependency { impl ImportEagerDependency { pub fn new( request: Atom, - range: RealDependencyLocation, + range: DependencyRange, referenced_exports: Option>, attributes: Option, ) -> Self { @@ -61,7 +61,7 @@ impl Dependency for ImportEagerDependency { self.attributes.as_ref() } - fn range(&self) -> Option<&RealDependencyLocation> { + fn range(&self) -> Option<&DependencyRange> { Some(&self.range) } diff --git a/crates/rspack_plugin_javascript/src/dependency/esm/provide_dependency.rs b/crates/rspack_plugin_javascript/src/dependency/esm/provide_dependency.rs index 47a8fe48128..94ddcfa634c 100644 --- a/crates/rspack_plugin_javascript/src/dependency/esm/provide_dependency.rs +++ b/crates/rspack_plugin_javascript/src/dependency/esm/provide_dependency.rs @@ -1,8 +1,7 @@ use itertools::Itertools; use rspack_core::{ - create_exports_object_referenced, module_raw, Compilation, DependencyType, - ExtendedReferencedExport, ModuleGraph, NormalInitFragment, RealDependencyLocation, RuntimeSpec, - UsedName, + create_exports_object_referenced, module_raw, Compilation, DependencyRange, DependencyType, + ExtendedReferencedExport, ModuleGraph, NormalInitFragment, RuntimeSpec, UsedName, }; use rspack_core::{AsContextDependency, Dependency, InitFragmentKey, InitFragmentStage}; use rspack_core::{DependencyCategory, DependencyId, DependencyTemplate}; @@ -16,16 +15,11 @@ pub struct ProvideDependency { request: Atom, identifier: String, ids: Vec, - range: RealDependencyLocation, + range: DependencyRange, } impl ProvideDependency { - pub fn new( - range: RealDependencyLocation, - request: Atom, - identifier: String, - ids: Vec, - ) -> Self { + pub fn new(range: DependencyRange, request: Atom, identifier: String, ids: Vec) -> Self { Self { range, request, diff --git a/crates/rspack_plugin_javascript/src/dependency/hmr/harmony_accept_dependency.rs b/crates/rspack_plugin_javascript/src/dependency/hmr/harmony_accept_dependency.rs index 0fcc1d4631e..84a8e5a9731 100644 --- a/crates/rspack_plugin_javascript/src/dependency/hmr/harmony_accept_dependency.rs +++ b/crates/rspack_plugin_javascript/src/dependency/hmr/harmony_accept_dependency.rs @@ -1,6 +1,6 @@ use rspack_core::{ import_statement, runtime_condition_expression, AsDependency, Compilation, DependencyId, - DependencyTemplate, RealDependencyLocation, RuntimeCondition, RuntimeSpec, TemplateContext, + DependencyRange, DependencyTemplate, RuntimeCondition, RuntimeSpec, TemplateContext, TemplateReplaceSource, }; @@ -8,14 +8,14 @@ use crate::dependency::get_import_emitted_runtime; #[derive(Debug, Clone)] pub struct HarmonyAcceptDependency { - range: RealDependencyLocation, + range: DependencyRange, has_callback: bool, dependency_ids: Vec, } impl HarmonyAcceptDependency { pub fn new( - range: RealDependencyLocation, + range: DependencyRange, has_callback: bool, dependency_ids: Vec, ) -> Self { diff --git a/crates/rspack_plugin_javascript/src/dependency/hmr/import_meta_hot_accept.rs b/crates/rspack_plugin_javascript/src/dependency/hmr/import_meta_hot_accept.rs index 601c7ffe1f4..bd7dd91ecc5 100644 --- a/crates/rspack_plugin_javascript/src/dependency/hmr/import_meta_hot_accept.rs +++ b/crates/rspack_plugin_javascript/src/dependency/hmr/import_meta_hot_accept.rs @@ -1,6 +1,6 @@ use rspack_core::{ module_id, AsContextDependency, Compilation, Dependency, DependencyCategory, DependencyId, - DependencyTemplate, DependencyType, ModuleDependency, RealDependencyLocation, RuntimeSpec, + DependencyRange, DependencyTemplate, DependencyType, ModuleDependency, RuntimeSpec, TemplateContext, TemplateReplaceSource, }; use swc_core::ecma::atoms::Atom; @@ -9,11 +9,11 @@ use swc_core::ecma::atoms::Atom; pub struct ImportMetaHotAcceptDependency { id: DependencyId, request: Atom, - range: RealDependencyLocation, + range: DependencyRange, } impl ImportMetaHotAcceptDependency { - pub fn new(request: Atom, range: RealDependencyLocation) -> Self { + pub fn new(request: Atom, range: DependencyRange) -> Self { Self { request, range, @@ -35,7 +35,7 @@ impl Dependency for ImportMetaHotAcceptDependency { &DependencyType::ImportMetaHotAccept } - fn range(&self) -> Option<&RealDependencyLocation> { + fn range(&self) -> Option<&DependencyRange> { Some(&self.range) } diff --git a/crates/rspack_plugin_javascript/src/dependency/hmr/import_meta_hot_decline.rs b/crates/rspack_plugin_javascript/src/dependency/hmr/import_meta_hot_decline.rs index 7fd044ba3c0..af1f1e8f373 100644 --- a/crates/rspack_plugin_javascript/src/dependency/hmr/import_meta_hot_decline.rs +++ b/crates/rspack_plugin_javascript/src/dependency/hmr/import_meta_hot_decline.rs @@ -1,6 +1,6 @@ use rspack_core::{ module_id, AsContextDependency, Compilation, Dependency, DependencyCategory, DependencyId, - DependencyTemplate, DependencyType, ModuleDependency, RealDependencyLocation, RuntimeSpec, + DependencyRange, DependencyTemplate, DependencyType, ModuleDependency, RuntimeSpec, TemplateContext, TemplateReplaceSource, }; use swc_core::ecma::atoms::Atom; @@ -9,11 +9,11 @@ use swc_core::ecma::atoms::Atom; pub struct ImportMetaHotDeclineDependency { id: DependencyId, request: Atom, - range: RealDependencyLocation, + range: DependencyRange, } impl ImportMetaHotDeclineDependency { - pub fn new(request: Atom, range: RealDependencyLocation) -> Self { + pub fn new(request: Atom, range: DependencyRange) -> Self { Self { request, range, @@ -35,7 +35,7 @@ impl Dependency for ImportMetaHotDeclineDependency { &DependencyType::ImportMetaHotDecline } - fn range(&self) -> Option<&RealDependencyLocation> { + fn range(&self) -> Option<&DependencyRange> { Some(&self.range) } diff --git a/crates/rspack_plugin_javascript/src/dependency/hmr/module_hot_accept.rs b/crates/rspack_plugin_javascript/src/dependency/hmr/module_hot_accept.rs index 4f4400349a3..f50b48b16c3 100644 --- a/crates/rspack_plugin_javascript/src/dependency/hmr/module_hot_accept.rs +++ b/crates/rspack_plugin_javascript/src/dependency/hmr/module_hot_accept.rs @@ -1,6 +1,6 @@ use rspack_core::{ module_id, AsContextDependency, Compilation, Dependency, DependencyCategory, DependencyId, - DependencyTemplate, DependencyType, ModuleDependency, RealDependencyLocation, RuntimeSpec, + DependencyRange, DependencyTemplate, DependencyType, ModuleDependency, RuntimeSpec, TemplateContext, TemplateReplaceSource, }; use swc_core::ecma::atoms::Atom; @@ -9,11 +9,11 @@ use swc_core::ecma::atoms::Atom; pub struct ModuleHotAcceptDependency { id: DependencyId, request: Atom, - range: RealDependencyLocation, + range: DependencyRange, } impl ModuleHotAcceptDependency { - pub fn new(request: Atom, range: RealDependencyLocation) -> Self { + pub fn new(request: Atom, range: DependencyRange) -> Self { Self { id: DependencyId::new(), request, @@ -35,7 +35,7 @@ impl Dependency for ModuleHotAcceptDependency { &DependencyType::ModuleHotAccept } - fn range(&self) -> Option<&RealDependencyLocation> { + fn range(&self) -> Option<&DependencyRange> { Some(&self.range) } diff --git a/crates/rspack_plugin_javascript/src/dependency/hmr/module_hot_decline.rs b/crates/rspack_plugin_javascript/src/dependency/hmr/module_hot_decline.rs index 9228da1bc92..5dbea529212 100644 --- a/crates/rspack_plugin_javascript/src/dependency/hmr/module_hot_decline.rs +++ b/crates/rspack_plugin_javascript/src/dependency/hmr/module_hot_decline.rs @@ -1,6 +1,6 @@ use rspack_core::{ module_id, AsContextDependency, Compilation, Dependency, DependencyCategory, DependencyId, - DependencyTemplate, DependencyType, ModuleDependency, RealDependencyLocation, RuntimeSpec, + DependencyRange, DependencyTemplate, DependencyType, ModuleDependency, RuntimeSpec, TemplateContext, TemplateReplaceSource, }; use swc_core::ecma::atoms::Atom; @@ -9,11 +9,11 @@ use swc_core::ecma::atoms::Atom; pub struct ModuleHotDeclineDependency { id: DependencyId, request: Atom, - range: RealDependencyLocation, + range: DependencyRange, } impl ModuleHotDeclineDependency { - pub fn new(request: Atom, range: RealDependencyLocation) -> Self { + pub fn new(request: Atom, range: DependencyRange) -> Self { Self { id: DependencyId::new(), request, @@ -35,7 +35,7 @@ impl Dependency for ModuleHotDeclineDependency { &DependencyType::ModuleHotDecline } - fn range(&self) -> Option<&RealDependencyLocation> { + fn range(&self) -> Option<&DependencyRange> { Some(&self.range) } diff --git a/crates/rspack_plugin_javascript/src/dependency/module_argument_dependency.rs b/crates/rspack_plugin_javascript/src/dependency/module_argument_dependency.rs index d3145af3e24..e2d63762877 100644 --- a/crates/rspack_plugin_javascript/src/dependency/module_argument_dependency.rs +++ b/crates/rspack_plugin_javascript/src/dependency/module_argument_dependency.rs @@ -1,17 +1,17 @@ use rspack_core::{ - AsDependency, Compilation, DependencyTemplate, RealDependencyLocation, RuntimeGlobals, - RuntimeSpec, TemplateContext, TemplateReplaceSource, + AsDependency, Compilation, DependencyRange, DependencyTemplate, RuntimeGlobals, RuntimeSpec, + TemplateContext, TemplateReplaceSource, }; use rspack_util::ext::DynHash; #[derive(Debug, Clone)] pub struct ModuleArgumentDependency { id: Option<&'static str>, - range: RealDependencyLocation, + range: DependencyRange, } impl ModuleArgumentDependency { - pub fn new(id: Option<&'static str>, range: RealDependencyLocation) -> Self { + pub fn new(id: Option<&'static str>, range: DependencyRange) -> Self { Self { id, range } } diff --git a/crates/rspack_plugin_javascript/src/dependency/url/mod.rs b/crates/rspack_plugin_javascript/src/dependency/url/mod.rs index a6ea7fb8fc4..da6440037b1 100644 --- a/crates/rspack_plugin_javascript/src/dependency/url/mod.rs +++ b/crates/rspack_plugin_javascript/src/dependency/url/mod.rs @@ -1,7 +1,7 @@ use rspack_core::{ get_dependency_used_by_exports_condition, module_id, AsContextDependency, Compilation, - Dependency, DependencyCategory, DependencyCondition, DependencyId, DependencyTemplate, - DependencyType, ModuleDependency, RealDependencyLocation, RuntimeGlobals, RuntimeSpec, + Dependency, DependencyCategory, DependencyCondition, DependencyId, DependencyRange, + DependencyTemplate, DependencyType, ModuleDependency, RuntimeGlobals, RuntimeSpec, TemplateContext, TemplateReplaceSource, UsedByExports, }; use swc_core::ecma::atoms::Atom; @@ -10,8 +10,8 @@ use swc_core::ecma::atoms::Atom; pub struct URLDependency { id: DependencyId, request: Atom, - range: RealDependencyLocation, - range_url: RealDependencyLocation, + range: DependencyRange, + range_url: DependencyRange, used_by_exports: Option, relative: bool, } @@ -19,8 +19,8 @@ pub struct URLDependency { impl URLDependency { pub fn new( request: Atom, - range: RealDependencyLocation, - range_url: RealDependencyLocation, + range: DependencyRange, + range_url: DependencyRange, relative: bool, ) -> Self { Self { @@ -47,7 +47,7 @@ impl Dependency for URLDependency { &DependencyType::NewUrl } - fn range(&self) -> Option<&RealDependencyLocation> { + fn range(&self) -> Option<&DependencyRange> { Some(&self.range) } diff --git a/crates/rspack_plugin_javascript/src/dependency/worker/create_script_url_dependency.rs b/crates/rspack_plugin_javascript/src/dependency/worker/create_script_url_dependency.rs index 9934d7f2a33..627bd7f2da4 100644 --- a/crates/rspack_plugin_javascript/src/dependency/worker/create_script_url_dependency.rs +++ b/crates/rspack_plugin_javascript/src/dependency/worker/create_script_url_dependency.rs @@ -1,18 +1,18 @@ use rspack_core::{ AsContextDependency, AsModuleDependency, Compilation, Dependency, DependencyCategory, - DependencyId, DependencyTemplate, DependencyType, RealDependencyLocation, RuntimeGlobals, - RuntimeSpec, TemplateContext, TemplateReplaceSource, + DependencyId, DependencyRange, DependencyTemplate, DependencyType, RuntimeGlobals, RuntimeSpec, + TemplateContext, TemplateReplaceSource, }; #[derive(Debug, Clone)] pub struct CreateScriptUrlDependency { id: DependencyId, - range: RealDependencyLocation, - range_path: RealDependencyLocation, + range: DependencyRange, + range_path: DependencyRange, } impl CreateScriptUrlDependency { - pub fn new(range: RealDependencyLocation, range_path: RealDependencyLocation) -> Self { + pub fn new(range: DependencyRange, range_path: DependencyRange) -> Self { Self { id: DependencyId::new(), range, @@ -34,7 +34,7 @@ impl Dependency for CreateScriptUrlDependency { &DependencyType::CreateScriptUrl } - fn range(&self) -> Option<&RealDependencyLocation> { + fn range(&self) -> Option<&DependencyRange> { Some(&self.range) } diff --git a/crates/rspack_plugin_javascript/src/dependency/worker/mod.rs b/crates/rspack_plugin_javascript/src/dependency/worker/mod.rs index 59927371823..9a694b46d04 100644 --- a/crates/rspack_plugin_javascript/src/dependency/worker/mod.rs +++ b/crates/rspack_plugin_javascript/src/dependency/worker/mod.rs @@ -2,8 +2,8 @@ mod create_script_url_dependency; pub use create_script_url_dependency::CreateScriptUrlDependency; use rspack_core::{ get_chunk_from_ukey, AsContextDependency, Compilation, Dependency, DependencyCategory, - DependencyId, DependencyTemplate, DependencyType, ExtendedReferencedExport, ModuleDependency, - ModuleGraph, RealDependencyLocation, RuntimeGlobals, RuntimeSpec, TemplateContext, + DependencyId, DependencyRange, DependencyTemplate, DependencyType, ExtendedReferencedExport, + ModuleDependency, ModuleGraph, RuntimeGlobals, RuntimeSpec, TemplateContext, TemplateReplaceSource, }; use rspack_util::ext::DynHash; @@ -13,16 +13,16 @@ pub struct WorkerDependency { id: DependencyId, request: String, public_path: String, - range: RealDependencyLocation, - range_path: RealDependencyLocation, + range: DependencyRange, + range_path: DependencyRange, } impl WorkerDependency { pub fn new( request: String, public_path: String, - range: RealDependencyLocation, - range_path: RealDependencyLocation, + range: DependencyRange, + range_path: DependencyRange, ) -> Self { Self { id: DependencyId::new(), @@ -47,7 +47,7 @@ impl Dependency for WorkerDependency { &DependencyType::NewWorker } - fn range(&self) -> Option<&RealDependencyLocation> { + fn range(&self) -> Option<&DependencyRange> { Some(&self.range) } diff --git a/crates/rspack_plugin_javascript/src/parser_plugin/api_plugin.rs b/crates/rspack_plugin_javascript/src/parser_plugin/api_plugin.rs index 023eeda65d5..c0b7a6ad19f 100644 --- a/crates/rspack_plugin_javascript/src/parser_plugin/api_plugin.rs +++ b/crates/rspack_plugin_javascript/src/parser_plugin/api_plugin.rs @@ -1,5 +1,5 @@ use rspack_core::{ - ConstDependency, RealDependencyLocation, RuntimeGlobals, RuntimeRequirementsDependency, SpanExt, + ConstDependency, DependencyRange, RuntimeGlobals, RuntimeRequirementsDependency, SpanExt, }; use swc_core::common::Spanned; use swc_core::ecma::ast::{CallExpr, Callee, Expr, Ident, UnaryExpr}; @@ -156,7 +156,7 @@ impl JavascriptParserPlugin for APIPlugin { Some(true) } WEBPACK_MODULE => { - let range: RealDependencyLocation = ident.span.into(); + let range: DependencyRange = ident.span.into(); parser .presentational_dependencies .push(Box::new(ModuleArgumentDependency::new( @@ -371,7 +371,7 @@ impl JavascriptParserPlugin for APIPlugin { .push(Box::new(RuntimeRequirementsDependency::new( RuntimeGlobals::MODULE_ID, ))); - let range: RealDependencyLocation = expr.span().into(); + let range: DependencyRange = expr.span().into(); parser .presentational_dependencies .push(Box::new(ModuleArgumentDependency::new( diff --git a/crates/rspack_plugin_javascript/src/parser_plugin/common_js_exports_parse_plugin.rs b/crates/rspack_plugin_javascript/src/parser_plugin/common_js_exports_parse_plugin.rs index d4e5945e60b..6c1d4537480 100644 --- a/crates/rspack_plugin_javascript/src/parser_plugin/common_js_exports_parse_plugin.rs +++ b/crates/rspack_plugin_javascript/src/parser_plugin/common_js_exports_parse_plugin.rs @@ -1,5 +1,5 @@ use rspack_core::{ - BuildMetaDefaultObject, BuildMetaExportsType, RealDependencyLocation, RuntimeGlobals, + BuildMetaDefaultObject, BuildMetaExportsType, DependencyRange, RuntimeGlobals, RuntimeRequirementsDependency, SpanExt, }; use swc_core::atoms::Atom; @@ -391,7 +391,7 @@ impl JavascriptParserPlugin for CommonJsExportsParserPlugin { // exports.aaa = require('xx'); // module.exports.aaa = require('xx'); // this.aaa = require('xx'); - let range: RealDependencyLocation = assign_expr.span.into(); + let range: DependencyRange = assign_expr.span.into(); parser .dependencies .push(Box::new(CommonJsExportRequireDependency::new( diff --git a/crates/rspack_plugin_javascript/src/parser_plugin/common_js_imports_parse_plugin.rs b/crates/rspack_plugin_javascript/src/parser_plugin/common_js_imports_parse_plugin.rs index 249e6b5b644..dd6be35d565 100644 --- a/crates/rspack_plugin_javascript/src/parser_plugin/common_js_imports_parse_plugin.rs +++ b/crates/rspack_plugin_javascript/src/parser_plugin/common_js_imports_parse_plugin.rs @@ -1,6 +1,5 @@ use rspack_core::{ - ConstDependency, ContextDependency, ContextMode, DependencyCategory, RealDependencyLocation, - SpanExt, + ConstDependency, ContextDependency, ContextMode, DependencyCategory, DependencyRange, SpanExt, }; use rspack_core::{ContextNameSpaceObject, ContextOptions}; use rspack_error::{DiagnosticExt, Severity}; @@ -57,7 +56,7 @@ fn create_require_resolve_context_dependency( parser: &mut JavascriptParser, param: &BasicEvaluatedExpression, expr: &Expr, - range: RealDependencyLocation, + range: DependencyRange, weak: bool, ) -> RequireResolveContextDependency { let start = range.start; @@ -176,7 +175,7 @@ impl CommonJsImportsParserPlugin { let (members, first_arg) = extract_require_call_info(parser, mem_expr)?; - let range: RealDependencyLocation = mem_expr.span.into(); + let range: DependencyRange = mem_expr.span.into(); let param = parser.evaluate_expression(&first_arg.expr); param.is_string().then(|| { CommonJsFullRequireDependency::new( @@ -197,7 +196,7 @@ impl CommonJsImportsParserPlugin { param: &BasicEvaluatedExpression, ) -> Option { param.is_string().then(|| { - let range_expr: RealDependencyLocation = param.range().into(); + let range_expr: DependencyRange = param.range().into(); let dep = CommonJsRequireDependency::new( param.string().to_string(), range_expr.with_source(parser.source_map.clone()), @@ -258,7 +257,7 @@ impl CommonJsImportsParserPlugin { } } if !is_expression { - let range: RealDependencyLocation = call_expr.callee.span().into(); + let range: DependencyRange = call_expr.callee.span().into(); parser .presentational_dependencies .push(Box::new(RequireHeaderDependency::new( @@ -275,7 +274,7 @@ impl CommonJsImportsParserPlugin { { self.process_require_context(parser, call_expr, ¶m); } else { - let range: RealDependencyLocation = call_expr.callee.span().into(); + let range: DependencyRange = call_expr.callee.span().into(); parser .presentational_dependencies .push(Box::new(RequireHeaderDependency::new( diff --git a/crates/rspack_plugin_javascript/src/parser_plugin/compatibility_plugin.rs b/crates/rspack_plugin_javascript/src/parser_plugin/compatibility_plugin.rs index 4a706b5bc3e..42c31617d39 100644 --- a/crates/rspack_plugin_javascript/src/parser_plugin/compatibility_plugin.rs +++ b/crates/rspack_plugin_javascript/src/parser_plugin/compatibility_plugin.rs @@ -1,6 +1,4 @@ -use rspack_core::{ - ConstDependency, ContextDependency, RealDependencyLocation, RuntimeGlobals, SpanExt, -}; +use rspack_core::{ConstDependency, ContextDependency, DependencyRange, RuntimeGlobals, SpanExt}; use rspack_util::itoa; use swc_core::{common::Spanned, ecma::ast::CallExpr}; @@ -16,7 +14,7 @@ const NESTED_WEBPACK_IDENTIFIER_TAG: &str = "_identifier__nested_webpack_identif struct NestedRequireData { name: String, update: bool, - loc: RealDependencyLocation, + loc: DependencyRange, } pub struct CompatibilityPlugin; @@ -68,7 +66,7 @@ impl CompatibilityPlugin { Some(NestedRequireData { name: rename, update: false, - loc: RealDependencyLocation::new(start, end).with_source(parser.source_map.clone()), + loc: DependencyRange::new(start, end).with_source(parser.source_map.clone()), }), ); } diff --git a/crates/rspack_plugin_javascript/src/parser_plugin/harmony_export_dependency_parser_plugin.rs b/crates/rspack_plugin_javascript/src/parser_plugin/harmony_export_dependency_parser_plugin.rs index ac6f48123eb..459c22a7152 100644 --- a/crates/rspack_plugin_javascript/src/parser_plugin/harmony_export_dependency_parser_plugin.rs +++ b/crates/rspack_plugin_javascript/src/parser_plugin/harmony_export_dependency_parser_plugin.rs @@ -1,6 +1,4 @@ -use rspack_core::{ - BoxDependency, ConstDependency, DependencyType, RealDependencyLocation, SpanExt, -}; +use rspack_core::{BoxDependency, ConstDependency, DependencyRange, DependencyType, SpanExt}; use swc_core::atoms::Atom; use swc_core::common::Spanned; @@ -24,7 +22,7 @@ pub struct HarmonyExportDependencyParserPlugin; impl JavascriptParserPlugin for HarmonyExportDependencyParserPlugin { fn export(&self, parser: &mut JavascriptParser, statement: ExportLocal) -> Option { - let range: RealDependencyLocation = statement.span().into(); + let range: DependencyRange = statement.span().into(); let dep = HarmonyExportHeaderDependency::new( range.with_source(parser.source_map.clone()), statement.declaration_span().map(|span| span.into()), @@ -41,7 +39,7 @@ impl JavascriptParserPlugin for HarmonyExportDependencyParserPlugin { ) -> Option { parser.last_harmony_import_order += 1; let span = statement.span(); - let range: RealDependencyLocation = span.into(); + let range: DependencyRange = span.into(); let clean_dep = ConstDependency::new(span.real_lo(), span.real_hi(), "".into(), None); parser.presentational_dependencies.push(Box::new(clean_dep)); let side_effect_dep = HarmonyImportSideEffectDependency::new( @@ -75,7 +73,7 @@ impl JavascriptParserPlugin for HarmonyExportDependencyParserPlugin { .insert(export_name.clone()); let dep = if let Some(settings) = parser.get_tag_data(local_id, HARMONY_SPECIFIER_TAG) { let settings = HarmonySpecifierData::downcast(settings); - let range: RealDependencyLocation = statement.span().into(); + let range: DependencyRange = statement.span().into(); Box::new(HarmonyExportImportedSpecifierDependency::new( settings.source, settings.source_order, @@ -90,7 +88,7 @@ impl JavascriptParserPlugin for HarmonyExportDependencyParserPlugin { settings.attributes, )) as BoxDependency } else { - let range: RealDependencyLocation = statement.span().into(); + let range: DependencyRange = statement.span().into(); Box::new(HarmonyExportSpecifierDependency::new( export_name.clone(), local_id.clone(), @@ -122,7 +120,7 @@ impl JavascriptParserPlugin for HarmonyExportDependencyParserPlugin { } else { Some(parser.build_info.all_star_exports.clone()) }; - let range: RealDependencyLocation = statement.span().into(); + let range: DependencyRange = statement.span().into(); let dep = HarmonyExportImportedSpecifierDependency::new( source.clone(), parser.last_harmony_import_order, @@ -156,7 +154,7 @@ impl JavascriptParserPlugin for HarmonyExportDependencyParserPlugin { let expr_span = expr.span(); let statement_span = statement.span(); - let range: RealDependencyLocation = expr_span.into(); + let range: DependencyRange = expr_span.into(); let dep: HarmonyExportExpressionDependency = HarmonyExportExpressionDependency::new( range.with_source(parser.source_map.clone()), statement_span.into(), @@ -169,7 +167,7 @@ impl JavascriptParserPlugin for HarmonyExportDependencyParserPlugin { f.function.body.span().real_lo() }; Some(DeclarationId::Func(DeclarationInfo::new( - RealDependencyLocation::new(start, end), + DependencyRange::new(start, end), format!( "{}function{} ", if f.function.is_async { "async " } else { "" }, diff --git a/crates/rspack_plugin_javascript/src/parser_plugin/harmony_import_dependency_parser_plugin.rs b/crates/rspack_plugin_javascript/src/parser_plugin/harmony_import_dependency_parser_plugin.rs index d9a3278a21f..b52bc4cdfcd 100644 --- a/crates/rspack_plugin_javascript/src/parser_plugin/harmony_import_dependency_parser_plugin.rs +++ b/crates/rspack_plugin_javascript/src/parser_plugin/harmony_import_dependency_parser_plugin.rs @@ -1,5 +1,5 @@ use rspack_core::{ - ConstDependency, Dependency, DependencyType, ImportAttributes, RealDependencyLocation, SpanExt, + ConstDependency, Dependency, DependencyRange, DependencyType, ImportAttributes, SpanExt, }; use swc_core::atoms::Atom; use swc_core::common::{Span, Spanned}; @@ -70,7 +70,7 @@ impl JavascriptParserPlugin for HarmonyImportDependencyParserPlugin { source: &str, ) -> Option { parser.last_harmony_import_order += 1; - let range: RealDependencyLocation = import_decl.span.into(); + let range: DependencyRange = import_decl.span.into(); let attributes = import_decl.with.as_ref().map(|obj| get_attributes(obj)); let dependency = HarmonyImportSideEffectDependency::new( source.into(), @@ -134,7 +134,7 @@ impl JavascriptParserPlugin for HarmonyImportDependencyParserPlugin { .definitions_db .expect_get_tag_info(parser.current_tag_info?); let settings = HarmonySpecifierData::downcast(tag_info.data.clone()?); - let range: RealDependencyLocation = ident.span.into(); + let range: DependencyRange = ident.span.into(); let dep = HarmonyImportSpecifierDependency::new( settings.source, settings.name, @@ -201,7 +201,7 @@ impl JavascriptParserPlugin for HarmonyImportDependencyParserPlugin { let mut ids = settings.ids; ids.extend(non_optional_members.iter().cloned()); let direct_import = members.is_empty(); - let range: RealDependencyLocation = span.into(); + let range: DependencyRange = span.into(); let dep = HarmonyImportSpecifierDependency::new( settings.source, settings.name, @@ -265,7 +265,7 @@ impl JavascriptParserPlugin for HarmonyImportDependencyParserPlugin { }; let mut ids = settings.ids; ids.extend(non_optional_members.iter().cloned()); - let range: RealDependencyLocation = span.into(); + let range: DependencyRange = span.into(); let dep = HarmonyImportSpecifierDependency::new( settings.source, settings.name, diff --git a/crates/rspack_plugin_javascript/src/parser_plugin/hot_module_replacement_plugin.rs b/crates/rspack_plugin_javascript/src/parser_plugin/hot_module_replacement_plugin.rs index 4dcff8580d9..487802145ea 100644 --- a/crates/rspack_plugin_javascript/src/parser_plugin/hot_module_replacement_plugin.rs +++ b/crates/rspack_plugin_javascript/src/parser_plugin/hot_module_replacement_plugin.rs @@ -3,7 +3,7 @@ pub mod hot_module_replacement { pub use super::ModuleHotReplacementParserPlugin; } -use rspack_core::{BoxDependency, RealDependencyLocation, SpanExt}; +use rspack_core::{BoxDependency, DependencyRange, SpanExt}; use swc_core::common::{Span, Spanned}; use swc_core::ecma::ast::{CallExpr, Expr, Lit}; use swc_core::ecma::atoms::Atom; @@ -16,7 +16,7 @@ use crate::parser_plugin::JavascriptParserPlugin; use crate::utils::eval; use crate::visitors::{expr_name, JavascriptParser}; -type CreateDependency = fn(Atom, RealDependencyLocation) -> BoxDependency; +type CreateDependency = fn(Atom, DependencyRange) -> BoxDependency; fn extract_deps(call_expr: &CallExpr, create_dependency: CreateDependency) -> Vec { let mut dependencies: Vec = vec![]; @@ -44,7 +44,7 @@ fn extract_deps(call_expr: &CallExpr, create_dependency: CreateDependency) -> Ve impl<'parser> JavascriptParser<'parser> { fn create_hmr_expression_handler(&mut self, span: Span) { - let range: RealDependencyLocation = span.into(); + let range: DependencyRange = span.into(); self.build_info.module_concatenation_bailout = Some(String::from("Hot Module Replacement")); self .presentational_dependencies @@ -59,7 +59,7 @@ impl<'parser> JavascriptParser<'parser> { call_expr: &CallExpr, create_dependency: CreateDependency, ) -> Option { - let range: RealDependencyLocation = call_expr.callee.span().into(); + let range: DependencyRange = call_expr.callee.span().into(); self.build_info.module_concatenation_bailout = Some(String::from("Hot Module Replacement")); self .presentational_dependencies @@ -72,9 +72,9 @@ impl<'parser> JavascriptParser<'parser> { let dependency_ids = dependencies.iter().map(|dep| *dep.id()).collect::>(); let callback_arg = call_expr.args.get(1); let range = if let Some(callback) = callback_arg { - Into::::into(callback.span()) + Into::::into(callback.span()) } else { - RealDependencyLocation::new(call_expr.span().real_hi() - 1, 0) + DependencyRange::new(call_expr.span().real_hi() - 1, 0) }; self .presentational_dependencies @@ -94,7 +94,7 @@ impl<'parser> JavascriptParser<'parser> { call_expr: &CallExpr, create_dependency: CreateDependency, ) -> Option { - let range: RealDependencyLocation = call_expr.callee.span().into(); + let range: DependencyRange = call_expr.callee.span().into(); self.build_info.module_concatenation_bailout = Some(String::from("Hot Module Replacement")); self .presentational_dependencies diff --git a/crates/rspack_plugin_javascript/src/parser_plugin/import_parser_plugin.rs b/crates/rspack_plugin_javascript/src/parser_plugin/import_parser_plugin.rs index cf08407983b..ab3e02b7c83 100644 --- a/crates/rspack_plugin_javascript/src/parser_plugin/import_parser_plugin.rs +++ b/crates/rspack_plugin_javascript/src/parser_plugin/import_parser_plugin.rs @@ -1,7 +1,7 @@ use itertools::Itertools; use rspack_core::{ - AsyncDependenciesBlock, ContextDependency, DependencyLocation, DynamicImportMode, GroupOptions, - ImportAttributes, RealDependencyLocation, + AsyncDependenciesBlock, ContextDependency, DependencyLocation, DependencyRange, + DynamicImportMode, GroupOptions, ImportAttributes, }; use rspack_core::{ChunkGroupOptions, DynamicImportFetchPriority}; use rspack_core::{ContextNameSpaceObject, ContextOptions, DependencyCategory, SpanExt}; @@ -131,7 +131,7 @@ impl JavascriptParserPlugin for ImportParserPlugin { let mut block = AsyncDependenciesBlock::new( *parser.module_identifier, Some(DependencyLocation::Real( - Into::::into(node.span).with_source(parser.source_map.clone()), + Into::::into(node.span).with_source(parser.source_map.clone()), )), None, vec![dep], diff --git a/crates/rspack_plugin_javascript/src/parser_plugin/provide_plugin.rs b/crates/rspack_plugin_javascript/src/parser_plugin/provide_plugin.rs index 1a59b6b9046..6948c6e42ad 100644 --- a/crates/rspack_plugin_javascript/src/parser_plugin/provide_plugin.rs +++ b/crates/rspack_plugin_javascript/src/parser_plugin/provide_plugin.rs @@ -2,8 +2,8 @@ use cow_utils::CowUtils; use itertools::Itertools; use once_cell::sync::OnceCell; use rspack_core::{ - ApplyContext, CompilerOptions, ModuleType, NormalModuleFactoryParser, ParserAndGenerator, - ParserOptions, Plugin, PluginContext, RealDependencyLocation, + ApplyContext, CompilerOptions, DependencyRange, ModuleType, NormalModuleFactoryParser, + ParserAndGenerator, ParserOptions, Plugin, PluginContext, }; use rspack_error::Result; use rspack_hook::{plugin, plugin_hook}; @@ -20,7 +20,7 @@ const MODULE_DOT: &str = r#"_dot_"#; fn create_provide_dep( name: &str, value: &ProvideValue, - range: RealDependencyLocation, + range: DependencyRange, ) -> Option { if let Some(requests) = value.get(name) { let name_identifier = if name.contains(SOURCE_DOT) { @@ -90,7 +90,7 @@ impl JavascriptParserPlugin for ProvidePlugin { expr: &swc_core::ecma::ast::CallExpr, for_name: &str, ) -> Option { - let range: RealDependencyLocation = expr.callee.span().into(); + let range: DependencyRange = expr.callee.span().into(); create_provide_dep( for_name, &self.provide, @@ -110,7 +110,7 @@ impl JavascriptParserPlugin for ProvidePlugin { expr: &swc_core::ecma::ast::MemberExpr, for_name: &str, ) -> Option { - let range: RealDependencyLocation = expr.span().into(); + let range: DependencyRange = expr.span().into(); create_provide_dep( for_name, &self.provide, @@ -128,7 +128,7 @@ impl JavascriptParserPlugin for ProvidePlugin { ident: &swc_core::ecma::ast::Ident, for_name: &str, ) -> Option { - let range: RealDependencyLocation = ident.span.into(); + let range: DependencyRange = ident.span.into(); create_provide_dep( for_name, &self.provide, diff --git a/crates/rspack_plugin_javascript/src/parser_plugin/worker_plugin.rs b/crates/rspack_plugin_javascript/src/parser_plugin/worker_plugin.rs index 0d2a108cd0c..9076bd593c3 100644 --- a/crates/rspack_plugin_javascript/src/parser_plugin/worker_plugin.rs +++ b/crates/rspack_plugin_javascript/src/parser_plugin/worker_plugin.rs @@ -4,8 +4,8 @@ use std::sync::LazyLock; use itertools::Itertools; use regex::Regex; use rspack_core::{ - AsyncDependenciesBlock, ConstDependency, DependencyLocation, EntryOptions, GroupOptions, - RealDependencyLocation, SpanExt, + AsyncDependenciesBlock, ConstDependency, DependencyLocation, DependencyRange, EntryOptions, + GroupOptions, SpanExt, }; use rspack_hash::RspackHash; use rustc_hash::{FxHashMap, FxHashSet}; @@ -98,7 +98,7 @@ fn add_dependencies( let mut block = AsyncDependenciesBlock::new( *parser.module_identifier, Some(DependencyLocation::Real( - Into::::into(span).with_source(parser.source_map.clone()), + Into::::into(span).with_source(parser.source_map.clone()), )), None, vec![dep], diff --git a/crates/rspack_plugin_javascript/src/utils/eval/eval_binary_expr.rs b/crates/rspack_plugin_javascript/src/utils/eval/eval_binary_expr.rs index 2702eeb19ac..649df0aa874 100644 --- a/crates/rspack_plugin_javascript/src/utils/eval/eval_binary_expr.rs +++ b/crates/rspack_plugin_javascript/src/utils/eval/eval_binary_expr.rs @@ -1,4 +1,4 @@ -use rspack_core::{RealDependencyLocation, SpanExt}; +use rspack_core::{DependencyRange, SpanExt}; use swc_core::{ common::Spanned, ecma::ast::{BinExpr, BinaryOp}, @@ -529,10 +529,7 @@ pub fn eval_binary_expression( evaluated } -fn join_locations( - start: Option<&RealDependencyLocation>, - end: Option<&RealDependencyLocation>, -) -> (u32, u32) { +fn join_locations(start: Option<&DependencyRange>, end: Option<&DependencyRange>) -> (u32, u32) { match (start, end) { (None, None) => unreachable!("invalid range"), (None, Some(end)) => (end.start, end.end), diff --git a/crates/rspack_plugin_javascript/src/utils/eval/mod.rs b/crates/rspack_plugin_javascript/src/utils/eval/mod.rs index d329332dd19..37a3523a2e7 100644 --- a/crates/rspack_plugin_javascript/src/utils/eval/mod.rs +++ b/crates/rspack_plugin_javascript/src/utils/eval/mod.rs @@ -11,7 +11,7 @@ mod eval_unary_expr; use bitflags::bitflags; use num_bigint::BigInt; -use rspack_core::RealDependencyLocation; +use rspack_core::DependencyRange; use swc_core::atoms::Atom; use swc_core::common::Span; @@ -60,7 +60,7 @@ type Regexp = (String, String); // (expr, flags) #[derive(Debug, Clone)] pub struct BasicEvaluatedExpression { ty: Ty, - range: Option, + range: Option, falsy: bool, truthy: bool, side_effects: bool, @@ -442,7 +442,7 @@ impl BasicEvaluatedExpression { } pub fn set_range(&mut self, start: u32, end: u32) { - self.range = Some(RealDependencyLocation::new(start, end)) + self.range = Some(DependencyRange::new(start, end)) } pub fn set_template_string( diff --git a/crates/rspack_plugin_lazy_compilation/src/module.rs b/crates/rspack_plugin_lazy_compilation/src/module.rs index 538b57ca5cb..6388ed180e9 100644 --- a/crates/rspack_plugin_lazy_compilation/src/module.rs +++ b/crates/rspack_plugin_lazy_compilation/src/module.rs @@ -7,9 +7,9 @@ use rspack_core::{ rspack_sources::{RawSource, Source}, AsyncDependenciesBlock, AsyncDependenciesBlockIdentifier, BoxDependency, BuildContext, BuildInfo, BuildMeta, BuildResult, CodeGenerationData, CodeGenerationResult, Compilation, - ConcatenationScope, Context, DependenciesBlock, DependencyId, FactoryMeta, Module, - ModuleFactoryCreateData, ModuleIdentifier, ModuleLayer, ModuleType, RealDependencyLocation, - RuntimeGlobals, RuntimeSpec, SourceType, TemplateContext, + ConcatenationScope, Context, DependenciesBlock, DependencyId, DependencyRange, FactoryMeta, + Module, ModuleFactoryCreateData, ModuleIdentifier, ModuleLayer, ModuleType, RuntimeGlobals, + RuntimeSpec, SourceType, TemplateContext, }; use rspack_error::{Diagnosable, Diagnostic, Result}; use rspack_plugin_javascript::dependency::CommonJsRequireDependency; @@ -137,12 +137,8 @@ impl Module for LazyCompilationProxyModule { _build_context: BuildContext<'_>, _compilation: Option<&Compilation>, ) -> Result { - let client_dep = CommonJsRequireDependency::new( - self.client.clone(), - RealDependencyLocation::new(0, 0), - None, - false, - ); + let client_dep = + CommonJsRequireDependency::new(self.client.clone(), DependencyRange::new(0, 0), None, false); let mut dependencies = vec![]; let mut blocks = vec![]; diff --git a/crates/rspack_plugin_library/src/modern_module/dependency.rs b/crates/rspack_plugin_library/src/modern_module/dependency.rs index 6d5c7019bd8..b6cc783cbcb 100644 --- a/crates/rspack_plugin_library/src/modern_module/dependency.rs +++ b/crates/rspack_plugin_library/src/modern_module/dependency.rs @@ -1,7 +1,7 @@ use rspack_core::{AsContextDependency, Dependency}; use rspack_core::{ - Compilation, DependencyType, ExternalRequest, ExternalType, ImportAttributes, - RealDependencyLocation, RuntimeSpec, + Compilation, DependencyRange, DependencyType, ExternalRequest, ExternalType, ImportAttributes, + RuntimeSpec, }; use rspack_core::{DependencyCategory, DependencyId, DependencyTemplate}; use rspack_core::{ModuleDependency, TemplateContext, TemplateReplaceSource}; @@ -14,7 +14,7 @@ pub struct ModernModuleImportDependency { request: Atom, target_request: ExternalRequest, external_type: ExternalType, - range: RealDependencyLocation, + range: DependencyRange, attributes: Option, resource_identifier: String, } @@ -24,7 +24,7 @@ impl ModernModuleImportDependency { request: Atom, target_request: ExternalRequest, external_type: ExternalType, - range: RealDependencyLocation, + range: DependencyRange, attributes: Option, ) -> Self { let resource_identifier = @@ -62,7 +62,7 @@ impl Dependency for ModernModuleImportDependency { self.attributes.as_ref() } - fn range(&self) -> Option<&RealDependencyLocation> { + fn range(&self) -> Option<&DependencyRange> { Some(&self.range) } diff --git a/crates/rspack_plugin_wasm/src/dependency/wasm_import_dependency.rs b/crates/rspack_plugin_wasm/src/dependency/wasm_import_dependency.rs index 48b36f1bfec..fd772e81bba 100644 --- a/crates/rspack_plugin_wasm/src/dependency/wasm_import_dependency.rs +++ b/crates/rspack_plugin_wasm/src/dependency/wasm_import_dependency.rs @@ -1,6 +1,6 @@ use rspack_core::{ AsContextDependency, AsDependencyTemplate, Dependency, DependencyCategory, DependencyId, - DependencyType, ExtendedReferencedExport, ModuleDependency, ModuleGraph, RealDependencyLocation, + DependencyRange, DependencyType, ExtendedReferencedExport, ModuleDependency, ModuleGraph, RuntimeSpec, }; use swc_core::ecma::atoms::Atom; @@ -16,7 +16,7 @@ pub struct WasmImportDependency { // only_direct_import: bool, /// the WASM AST node pub desc: WasmNode, - span: Option, + span: Option, } impl WasmImportDependency {