From 43b17bc4767408df066d94f7b075ebca41317f81 Mon Sep 17 00:00:00 2001 From: AsyncIter Date: Wed, 4 Nov 2026 16:59:06 +0800 Subject: [PATCH] refactor: introduce the custom_sourcemap feature flag --- Cargo.toml | 6 ++++-- src/lib.rs | 6 +++--- src/printer.rs | 30 +++++++++++++++--------------- src/rules/container.rs | 2 +- src/rules/counter_style.rs | 2 +- src/rules/custom_media.rs | 2 +- src/rules/document.rs | 2 +- src/rules/font_face.rs | 2 +- src/rules/font_feature_values.rs | 4 ++-- src/rules/font_palette_values.rs | 2 +- src/rules/import.rs | 2 +- src/rules/keyframes.rs | 2 +- src/rules/layer.rs | 4 ++-- src/rules/media.rs | 2 +- src/rules/namespace.rs | 2 +- src/rules/nesting.rs | 4 ++-- src/rules/page.rs | 4 ++-- src/rules/position_try.rs | 2 +- src/rules/property.rs | 2 +- src/rules/scope.rs | 2 +- src/rules/starting_style.rs | 2 +- src/rules/style.rs | 2 +- src/rules/supports.rs | 2 +- src/rules/unknown.rs | 2 +- src/rules/view_transition.rs | 2 +- src/rules/viewport.rs | 2 +- src/stylesheet.rs | 18 +++++++++--------- 27 files changed, 58 insertions(+), 56 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 8e57a8bf..38d4d136 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -49,7 +49,7 @@ crate-type = ["rlib"] [features] default = ["bundler", "nodejs", "sourcemap"] browserslist = ["browserslist-rs"] -bundler = ["dashmap", "sourcemap", "rayon"] +bundler = ["dashmap", "custom_sourcemap", "rayon"] cli = ["clap", "serde_json", "browserslist", "jemallocator"] jsonschema = ["schemars", "serde", "rspack-lightningcss-selectors/jsonschema"] nodejs = ["dep:serde", "dep:serde-content"] @@ -62,7 +62,9 @@ serde = [ "rspack-lightningcss-selectors/serde", "into_owned", ] -sourcemap = ["parcel_sourcemap"] +# Keep the existing feature name as a compatibility alias. +sourcemap = ["custom_sourcemap"] +custom_sourcemap = ["parcel_sourcemap"] visitor = [] into_owned = [ "rspack-lightningcss-static-self", diff --git a/src/lib.rs b/src/lib.rs index 263cc5d7..85c465b5 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -32661,7 +32661,7 @@ b\0 c'); } #[test] - #[cfg(feature = "sourcemap")] + #[cfg(feature = "custom_sourcemap")] fn test_url_quoting_source_map() { let stylesheet = StyleSheet::parse( r#" @@ -32699,7 +32699,7 @@ b\0 c'); } #[test] - #[cfg(feature = "sourcemap")] + #[cfg(feature = "custom_sourcemap")] fn test_input_source_map() { let source = r#".imported { content: "yay, file support!"; @@ -32734,7 +32734,7 @@ b\0 c'); } #[test] - #[cfg(feature = "sourcemap")] + #[cfg(feature = "custom_sourcemap")] fn test_source_maps_with_license_comments() { let source = r#"/*! a single line comment */ /*! diff --git a/src/printer.rs b/src/printer.rs index 5a64abf9..ca93cf6a 100644 --- a/src/printer.rs +++ b/src/printer.rs @@ -8,7 +8,7 @@ use crate::selector::SelectorList; use crate::targets::{Targets, TargetsWithSupportsScope}; use crate::vendor_prefix::VendorPrefix; use cssparser::{serialize_identifier, serialize_name}; -#[cfg(feature = "sourcemap")] +#[cfg(feature = "custom_sourcemap")] use parcel_sourcemap::{OriginalLocation, SourceMap}; use std::fmt::Write; @@ -17,8 +17,8 @@ pub struct PrinterOptions<'a> { /// Whether to minify the CSS, i.e. remove white space. pub minify: bool, /// An optional reference to a source map to write mappings into. - #[cfg(feature = "sourcemap")] - #[cfg_attr(docsrs, doc(cfg(feature = "sourcemap")))] + #[cfg(feature = "custom_sourcemap")] + #[cfg_attr(docsrs, doc(cfg(feature = "custom_sourcemap")))] pub source_map: Option<&'a mut SourceMap>, /// An optional project root path, used to generate relative paths for sources used in CSS module hashes. pub project_root: Option<&'a str>, @@ -41,7 +41,7 @@ impl<'a> Default for PrinterOptions<'a> { fn default() -> Self { PrinterOptions { minify: false, - #[cfg(feature = "sourcemap")] + #[cfg(feature = "custom_sourcemap")] source_map: None, project_root: None, targets: Targets::default(), @@ -96,17 +96,17 @@ pub struct Printer<'a, 'c, W> { dest: &'a mut W, pub(crate) options: PrinterOptions<'a>, pub(crate) state: PrinterState<'a, 'c>, - #[cfg(feature = "sourcemap")] + #[cfg(feature = "custom_sourcemap")] pub(crate) source_map: Option<&'a mut SourceMap>, - #[cfg(feature = "sourcemap")] + #[cfg(feature = "custom_sourcemap")] pub(crate) source_maps: Vec>, - #[cfg(feature = "sourcemap")] + #[cfg(feature = "custom_sourcemap")] pub(crate) source_map_source_indices: &'c [Option], } impl<'a, 'c, W: std::fmt::Write + Sized> Printer<'a, 'c, W> { /// Create a new Printer wrapping the given destination. - #[cfg_attr(not(feature = "sourcemap"), allow(unused_mut))] + #[cfg_attr(not(feature = "custom_sourcemap"), allow(unused_mut))] pub fn new(dest: &'a mut W, mut options: PrinterOptions<'a>) -> Self { let dependencies = if options.analyze_dependencies.is_some() { Some(Vec::new()) @@ -117,7 +117,7 @@ impl<'a, 'c, W: std::fmt::Write + Sized> Printer<'a, 'c, W> { Printer { sources: None, dest, - #[cfg(feature = "sourcemap")] + #[cfg(feature = "custom_sourcemap")] source_map: options.source_map.take(), state: PrinterState { loc: Location { @@ -137,9 +137,9 @@ impl<'a, 'c, W: std::fmt::Write + Sized> Printer<'a, 'c, W> { context: None, }, options, - #[cfg(feature = "sourcemap")] + #[cfg(feature = "custom_sourcemap")] source_maps: Vec::new(), - #[cfg(feature = "sourcemap")] + #[cfg(feature = "custom_sourcemap")] source_map_source_indices: &[], } } @@ -307,8 +307,8 @@ impl<'a, 'c, W: std::fmt::Write + Sized> Printer<'a, 'c, W> { } /// Adds a mapping to the source map, if any. - #[cfg(feature = "sourcemap")] - #[cfg_attr(docsrs, doc(cfg(feature = "sourcemap")))] + #[cfg(feature = "custom_sourcemap")] + #[cfg_attr(docsrs, doc(cfg(feature = "custom_sourcemap")))] pub fn add_mapping(&mut self, loc: Location) { self.state.loc = loc; @@ -481,7 +481,7 @@ pub trait PrinterTrait: std::fmt::Write + private::Sealed { fn whitespace(&mut self) -> Result<(), PrinterError>; fn delim(&mut self, c: char, ws_before: bool) -> Result<(), PrinterError>; fn newline(&mut self) -> Result<(), PrinterError>; - #[cfg(feature = "sourcemap")] + #[cfg(feature = "custom_sourcemap")] fn add_mapping(&mut self, loc: Location); fn indent(&mut self); fn dedent(&mut self); @@ -604,7 +604,7 @@ impl<'a, 'c, W: std::fmt::Write + Sized> PrinterTrait for Printer<'a, 'c, W> { Printer::newline(self) } - #[cfg(feature = "sourcemap")] + #[cfg(feature = "custom_sourcemap")] fn add_mapping(&mut self, loc: Location) { Printer::add_mapping(self, loc) } diff --git a/src/rules/container.rs b/src/rules/container.rs index 03823eaa..3e231d00 100644 --- a/src/rules/container.rs +++ b/src/rules/container.rs @@ -458,7 +458,7 @@ impl<'i, T: Clone> ContainerRule<'i, T> { impl<'a, 'i, T: ToCss> ToCss for ContainerRule<'i, T> { fn to_css(&self, dest: &mut PrinterT) -> Result<(), PrinterError> { - #[cfg(feature = "sourcemap")] + #[cfg(feature = "custom_sourcemap")] dest.add_mapping(self.loc); dest.write_str("@container ")?; let has_condition = self.condition.is_some(); diff --git a/src/rules/counter_style.rs b/src/rules/counter_style.rs index d0501274..338aeef3 100644 --- a/src/rules/counter_style.rs +++ b/src/rules/counter_style.rs @@ -28,7 +28,7 @@ pub struct CounterStyleRule<'i> { impl<'i> ToCss for CounterStyleRule<'i> { fn to_css(&self, dest: &mut PrinterT) -> Result<(), PrinterError> { - #[cfg(feature = "sourcemap")] + #[cfg(feature = "custom_sourcemap")] dest.add_mapping(self.loc); dest.write_str("@counter-style ")?; self.name.to_css(dest)?; diff --git a/src/rules/custom_media.rs b/src/rules/custom_media.rs index 6f392e25..a9f0fc78 100644 --- a/src/rules/custom_media.rs +++ b/src/rules/custom_media.rs @@ -27,7 +27,7 @@ pub struct CustomMediaRule<'i> { impl<'i> ToCss for CustomMediaRule<'i> { fn to_css(&self, dest: &mut PrinterT) -> Result<(), PrinterError> { - #[cfg(feature = "sourcemap")] + #[cfg(feature = "custom_sourcemap")] dest.add_mapping(self.loc); dest.write_str("@custom-media ")?; self.name.to_css(dest)?; diff --git a/src/rules/document.rs b/src/rules/document.rs index 3d4265a9..95dea723 100644 --- a/src/rules/document.rs +++ b/src/rules/document.rs @@ -34,7 +34,7 @@ impl<'i, T: Clone> MozDocumentRule<'i, T> { impl<'i, T: ToCss> ToCss for MozDocumentRule<'i, T> { fn to_css(&self, dest: &mut PrinterT) -> Result<(), PrinterError> { - #[cfg(feature = "sourcemap")] + #[cfg(feature = "custom_sourcemap")] dest.add_mapping(self.loc); dest.write_str("@-moz-document url-prefix()")?; dest.whitespace()?; diff --git a/src/rules/font_face.rs b/src/rules/font_face.rs index 4e61be4f..66a33c1d 100644 --- a/src/rules/font_face.rs +++ b/src/rules/font_face.rs @@ -501,7 +501,7 @@ impl<'i> RuleBodyItemParser<'i, FontFaceProperty<'i>, ParserError<'i>> for FontF impl<'i> ToCss for FontFaceRule<'i> { fn to_css(&self, dest: &mut PrinterT) -> Result<(), PrinterError> { - #[cfg(feature = "sourcemap")] + #[cfg(feature = "custom_sourcemap")] dest.add_mapping(self.loc); dest.write_str("@font-face")?; dest.whitespace()?; diff --git a/src/rules/font_feature_values.rs b/src/rules/font_feature_values.rs index e2ddd575..80994986 100644 --- a/src/rules/font_feature_values.rs +++ b/src/rules/font_feature_values.rs @@ -151,7 +151,7 @@ impl<'a, 'i> RuleBodyItemParser<'i, (), ParserError<'i>> for FontFeatureValuesRu impl<'i> ToCss for FontFeatureValuesRule<'i> { fn to_css(&self, dest: &mut PrinterT) -> Result<(), PrinterError> { - #[cfg(feature = "sourcemap")] + #[cfg(feature = "custom_sourcemap")] dest.add_mapping(self.loc); dest.write_str("@font-feature-values ")?; self.name.to_css(dest)?; @@ -237,7 +237,7 @@ pub struct FontFeatureSubrule<'i> { impl<'i> ToCss for FontFeatureSubrule<'i> { fn to_css(&self, dest: &mut PrinterT) -> Result<(), PrinterError> { - #[cfg(feature = "sourcemap")] + #[cfg(feature = "custom_sourcemap")] dest.add_mapping(self.loc); dest.write_char('@')?; self.name.to_css(dest)?; diff --git a/src/rules/font_palette_values.rs b/src/rules/font_palette_values.rs index 8e6f1834..df4d4c95 100644 --- a/src/rules/font_palette_values.rs +++ b/src/rules/font_palette_values.rs @@ -358,7 +358,7 @@ impl<'i> FontPaletteValuesRule<'i> { impl<'i> ToCss for FontPaletteValuesRule<'i> { fn to_css(&self, dest: &mut PrinterT) -> Result<(), PrinterError> { - #[cfg(feature = "sourcemap")] + #[cfg(feature = "custom_sourcemap")] dest.add_mapping(self.loc); dest.write_str("@font-palette-values ")?; self.name.to_css(dest)?; diff --git a/src/rules/import.rs b/src/rules/import.rs index 920546cd..0e6e39c9 100644 --- a/src/rules/import.rs +++ b/src/rules/import.rs @@ -43,7 +43,7 @@ impl<'i> ToCss for ImportRule<'i> { } else { None }; - #[cfg(feature = "sourcemap")] + #[cfg(feature = "custom_sourcemap")] dest.add_mapping(self.loc); dest.write_str("@import ")?; if let Some(dep) = dep { diff --git a/src/rules/keyframes.rs b/src/rules/keyframes.rs index 0ef43704..439b29ae 100644 --- a/src/rules/keyframes.rs +++ b/src/rules/keyframes.rs @@ -211,7 +211,7 @@ impl<'i> KeyframesRule<'i> { impl<'i> ToCss for KeyframesRule<'i> { fn to_css(&self, dest: &mut PrinterT) -> Result<(), PrinterError> { - #[cfg(feature = "sourcemap")] + #[cfg(feature = "custom_sourcemap")] dest.add_mapping(self.loc); let mut first_rule = true; macro_rules! write_prefix { diff --git a/src/rules/layer.rs b/src/rules/layer.rs index e8396d75..1fedc693 100644 --- a/src/rules/layer.rs +++ b/src/rules/layer.rs @@ -96,7 +96,7 @@ pub struct LayerStatementRule<'i> { impl<'i> ToCss for LayerStatementRule<'i> { fn to_css(&self, dest: &mut PrinterT) -> Result<(), PrinterError> { - #[cfg(feature = "sourcemap")] + #[cfg(feature = "custom_sourcemap")] dest.add_mapping(self.loc); dest.write_str("@layer ")?; self.names.to_css(dest)?; @@ -137,7 +137,7 @@ impl<'i, T: Clone> LayerBlockRule<'i, T> { impl<'a, 'i, T: ToCss> ToCss for LayerBlockRule<'i, T> { fn to_css(&self, dest: &mut PrinterT) -> Result<(), PrinterError> { - #[cfg(feature = "sourcemap")] + #[cfg(feature = "custom_sourcemap")] dest.add_mapping(self.loc); dest.write_str("@layer")?; if let Some(name) = &self.name { diff --git a/src/rules/media.rs b/src/rules/media.rs index 9504fc3a..741d628b 100644 --- a/src/rules/media.rs +++ b/src/rules/media.rs @@ -50,7 +50,7 @@ impl<'a, 'i, T: ToCss> ToCss for MediaRule<'i, T> { self.rules.to_css(dest)?; return Ok(()); } - #[cfg(feature = "sourcemap")] + #[cfg(feature = "custom_sourcemap")] dest.add_mapping(self.loc); dest.write_str("@media ")?; self.query.to_css(dest)?; diff --git a/src/rules/namespace.rs b/src/rules/namespace.rs index 56635a33..896bf164 100644 --- a/src/rules/namespace.rs +++ b/src/rules/namespace.rs @@ -30,7 +30,7 @@ pub struct NamespaceRule<'i> { impl<'i> ToCss for NamespaceRule<'i> { fn to_css(&self, dest: &mut PrinterT) -> Result<(), PrinterError> { - #[cfg(feature = "sourcemap")] + #[cfg(feature = "custom_sourcemap")] dest.add_mapping(self.loc); dest.write_str("@namespace ")?; if let Some(prefix) = &self.prefix { diff --git a/src/rules/nesting.rs b/src/rules/nesting.rs index aae557c6..ac0e8afb 100644 --- a/src/rules/nesting.rs +++ b/src/rules/nesting.rs @@ -42,7 +42,7 @@ impl<'i, T: Clone> NestingRule<'i, T> { impl<'a, 'i, T: ToCss> ToCss for NestingRule<'i, T> { fn to_css(&self, dest: &mut PrinterT) -> Result<(), PrinterError> { - #[cfg(feature = "sourcemap")] + #[cfg(feature = "custom_sourcemap")] dest.add_mapping(self.loc); if !dest.has_context() { dest.write_str("@nest ")?; @@ -83,7 +83,7 @@ impl<'i> NestedDeclarationsRule<'i> { impl<'i> ToCss for NestedDeclarationsRule<'i> { fn to_css(&self, dest: &mut PrinterT) -> Result<(), PrinterError> { - #[cfg(feature = "sourcemap")] + #[cfg(feature = "custom_sourcemap")] dest.add_mapping(self.loc); dest.with_current_context(ContextAccess, |dest, context| { diff --git a/src/rules/page.rs b/src/rules/page.rs index 7b60afcf..016c2b47 100644 --- a/src/rules/page.rs +++ b/src/rules/page.rs @@ -141,7 +141,7 @@ pub struct PageMarginRule<'i> { impl<'i> ToCss for PageMarginRule<'i> { fn to_css(&self, dest: &mut PrinterT) -> Result<(), PrinterError> { - #[cfg(feature = "sourcemap")] + #[cfg(feature = "custom_sourcemap")] dest.add_mapping(self.loc); dest.write_char('@')?; self.margin_box.to_css(dest)?; @@ -206,7 +206,7 @@ impl<'i> PageRule<'i> { impl<'i> ToCss for PageRule<'i> { fn to_css(&self, dest: &mut PrinterT) -> Result<(), PrinterError> { - #[cfg(feature = "sourcemap")] + #[cfg(feature = "custom_sourcemap")] dest.add_mapping(self.loc); dest.write_str("@page")?; if let Some(first) = self.selectors.first() { diff --git a/src/rules/position_try.rs b/src/rules/position_try.rs index e63e6ec7..216ca9ac 100644 --- a/src/rules/position_try.rs +++ b/src/rules/position_try.rs @@ -27,7 +27,7 @@ pub struct PositionTryRule<'i> { impl<'i> ToCss for PositionTryRule<'i> { fn to_css(&self, dest: &mut PrinterT) -> Result<(), PrinterError> { - #[cfg(feature = "sourcemap")] + #[cfg(feature = "custom_sourcemap")] dest.add_mapping(self.loc); dest.write_str("@position-try ")?; self.name.to_css(dest)?; diff --git a/src/rules/property.rs b/src/rules/property.rs index 89c58ed8..440bfbbb 100644 --- a/src/rules/property.rs +++ b/src/rules/property.rs @@ -110,7 +110,7 @@ impl<'i> PropertyRule<'i> { impl<'i> ToCss for PropertyRule<'i> { fn to_css(&self, dest: &mut PrinterT) -> Result<(), PrinterError> { - #[cfg(feature = "sourcemap")] + #[cfg(feature = "custom_sourcemap")] dest.add_mapping(self.loc); dest.write_str("@property ")?; self.name.to_css(dest)?; diff --git a/src/rules/scope.rs b/src/rules/scope.rs index e1347066..86064277 100644 --- a/src/rules/scope.rs +++ b/src/rules/scope.rs @@ -65,7 +65,7 @@ impl<'i, T: Clone> ScopeRule<'i, T> { impl<'i, T: ToCss> ToCss for ScopeRule<'i, T> { fn to_css(&self, dest: &mut PrinterT) -> Result<(), PrinterError> { - #[cfg(feature = "sourcemap")] + #[cfg(feature = "custom_sourcemap")] dest.add_mapping(self.loc); dest.write_str("@scope")?; dest.whitespace()?; diff --git a/src/rules/starting_style.rs b/src/rules/starting_style.rs index a65d370a..d309fa33 100644 --- a/src/rules/starting_style.rs +++ b/src/rules/starting_style.rs @@ -36,7 +36,7 @@ impl<'i, T: Clone> StartingStyleRule<'i, T> { impl<'i, T: ToCss> ToCss for StartingStyleRule<'i, T> { fn to_css(&self, dest: &mut PrinterT) -> Result<(), PrinterError> { - #[cfg(feature = "sourcemap")] + #[cfg(feature = "custom_sourcemap")] dest.add_mapping(self.loc); dest.write_str("@starting-style")?; dest.whitespace()?; diff --git a/src/rules/style.rs b/src/rules/style.rs index a8aad4a5..c4c5055f 100644 --- a/src/rules/style.rs +++ b/src/rules/style.rs @@ -245,7 +245,7 @@ impl<'a, 'i, T: ToCss> StyleRule<'i, T> { let has_declarations = supports_nesting || len > 0 || self.rules.0.is_empty() || has_preserved_rules; if has_declarations { - #[cfg(feature = "sourcemap")] + #[cfg(feature = "custom_sourcemap")] dest.add_mapping(self.loc); self.selectors.to_css(dest)?; dest.whitespace()?; diff --git a/src/rules/supports.rs b/src/rules/supports.rs index 4c00ab85..4766acd3 100644 --- a/src/rules/supports.rs +++ b/src/rules/supports.rs @@ -60,7 +60,7 @@ impl<'i, T: Clone> SupportsRule<'i, T> { impl<'a, 'i, T: ToCss> ToCss for SupportsRule<'i, T> { fn to_css(&self, dest: &mut PrinterT) -> Result<(), PrinterError> { - #[cfg(feature = "sourcemap")] + #[cfg(feature = "custom_sourcemap")] dest.add_mapping(self.loc); dest.write_str("@supports ")?; self.condition.to_css(dest)?; diff --git a/src/rules/unknown.rs b/src/rules/unknown.rs index 88cca70a..404d60a7 100644 --- a/src/rules/unknown.rs +++ b/src/rules/unknown.rs @@ -30,7 +30,7 @@ pub struct UnknownAtRule<'i> { impl<'i> ToCss for UnknownAtRule<'i> { fn to_css(&self, dest: &mut PrinterT) -> Result<(), PrinterError> { - #[cfg(feature = "sourcemap")] + #[cfg(feature = "custom_sourcemap")] dest.add_mapping(self.loc); dest.write_char('@')?; dest.write_str(&self.name)?; diff --git a/src/rules/view_transition.rs b/src/rules/view_transition.rs index ba3562ea..3aa7240a 100644 --- a/src/rules/view_transition.rs +++ b/src/rules/view_transition.rs @@ -147,7 +147,7 @@ impl<'i> ViewTransitionRule<'i> { impl<'i> ToCss for ViewTransitionRule<'i> { fn to_css(&self, dest: &mut PrinterT) -> Result<(), PrinterError> { - #[cfg(feature = "sourcemap")] + #[cfg(feature = "custom_sourcemap")] dest.add_mapping(self.loc); dest.write_str("@view-transition")?; dest.whitespace()?; diff --git a/src/rules/viewport.rs b/src/rules/viewport.rs index ca6599a5..6e70d45e 100644 --- a/src/rules/viewport.rs +++ b/src/rules/viewport.rs @@ -32,7 +32,7 @@ pub struct ViewportRule<'i> { impl<'i> ToCss for ViewportRule<'i> { fn to_css(&self, dest: &mut PrinterT) -> Result<(), PrinterError> { - #[cfg(feature = "sourcemap")] + #[cfg(feature = "custom_sourcemap")] dest.add_mapping(self.loc); dest.write_char('@')?; self.vendor_prefix.to_css(dest)?; diff --git a/src/stylesheet.rs b/src/stylesheet.rs index 259b1309..e492c5b8 100644 --- a/src/stylesheet.rs +++ b/src/stylesheet.rs @@ -19,7 +19,7 @@ use crate::values::string::CowArcStr; #[cfg(feature = "visitor")] use crate::visitor::{Visit, VisitTypes, Visitor}; use cssparser::{Parser, ParserInput, StyleSheetParser}; -#[cfg(feature = "sourcemap")] +#[cfg(feature = "custom_sourcemap")] use parcel_sourcemap::SourceMap; use std::collections::{HashMap, HashSet}; use std::fmt::Write; @@ -83,7 +83,7 @@ pub struct StyleSheet<'i, T = DefaultAtRule> { /// The source map URL extracted from the original style sheet. pub source_map_urls: Vec>, /// Output source map indices corresponding to the bundler's source indices. - #[cfg(feature = "sourcemap")] + #[cfg(feature = "custom_sourcemap")] #[cfg_attr(feature = "serde", serde(skip))] pub(crate) source_map_source_indices: Vec>, /// The license comments that appeared at the start of the file. @@ -141,7 +141,7 @@ where StyleSheet { sources, source_map_urls: Vec::new(), - #[cfg(feature = "sourcemap")] + #[cfg(feature = "custom_sourcemap")] source_map_source_indices: Vec::new(), license_comments: Vec::new(), content_hashes: None, @@ -210,7 +210,7 @@ where Ok(StyleSheet { sources: vec![options.filename.clone()], source_map_urls: vec![parser.current_source_map_url().map(|s| s.to_owned())], - #[cfg(feature = "sourcemap")] + #[cfg(feature = "custom_sourcemap")] source_map_source_indices: Vec::new(), content_hashes, rules, @@ -225,8 +225,8 @@ where } /// Returns the inline source map associated with the source at the given index. - #[cfg(feature = "sourcemap")] - #[cfg_attr(docsrs, doc(cfg(feature = "sourcemap")))] + #[cfg(feature = "custom_sourcemap")] + #[cfg_attr(docsrs, doc(cfg(feature = "custom_sourcemap")))] pub fn source_map(&self, source_index: usize) -> Option { SourceMap::from_data_url("/", self.source_map_url(source_index)?).ok() } @@ -282,12 +282,12 @@ where let project_root = options.project_root.clone(); let mut printer = Printer::new(&mut dest, options); - #[cfg(feature = "sourcemap")] + #[cfg(feature = "custom_sourcemap")] { printer.sources = Some(&self.sources); } - #[cfg(feature = "sourcemap")] + #[cfg(feature = "custom_sourcemap")] if printer.source_map.is_some() { printer.source_maps = self.sources.iter().enumerate().map(|(i, _)| self.source_map(i)).collect(); printer.source_map_source_indices = &self.source_map_source_indices; @@ -408,7 +408,7 @@ impl<'i> StyleAttribute<'i> { /// Serializes the style attribute to a CSS string. pub fn to_css(&self, options: PrinterOptions) -> Result { - #[cfg(feature = "sourcemap")] + #[cfg(feature = "custom_sourcemap")] assert!( options.source_map.is_none(), "Source maps are not supported for style attributes"