Skip to content

Commit 85be8a4

Browse files
authoredJan 3, 2024
refactor(css/parser): Remove value normalization (#8434)
**Related issue :** - https://linear.app/vercel/issue/PACK-2154
1 parent 68b9646 commit 85be8a4

File tree

123 files changed

+1189
-1129
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

123 files changed

+1189
-1129
lines changed
 

‎crates/swc_css_ast/src/base.rs

+9
Original file line numberDiff line numberDiff line change
@@ -137,6 +137,15 @@ impl PartialEq<JsWord> for FunctionName {
137137
}
138138
}
139139

140+
impl FunctionName {
141+
pub fn as_str(&self) -> &str {
142+
match self {
143+
FunctionName::DashedIdent(v) => &v.value,
144+
FunctionName::Ident(v) => &v.value,
145+
}
146+
}
147+
}
148+
140149
#[ast_node("Function")]
141150
#[derive(Eq, Hash, EqIgnoreSpan)]
142151
pub struct Function {

‎crates/swc_css_codegen/tests/fixture.rs

+7-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ use swc_css_codegen::{
1111
};
1212
use swc_css_parser::parse_file;
1313
use swc_css_visit::{VisitMut, VisitMutWith};
14-
use testing::{assert_eq, run_test2, NormalizedOutput};
14+
use testing::{run_test2, NormalizedOutput};
1515

1616
fn run(input: &Path, minify: bool) {
1717
let dir = input.parent().unwrap();
@@ -80,6 +80,12 @@ fn run(input: &Path, minify: bool) {
8080
.compare_to_file(output)
8181
.unwrap();
8282

83+
if minify {
84+
// We lowercase identifiers to make gzip compression rate better, so we cannot
85+
// make the output equal to the input
86+
return Ok(());
87+
}
88+
8389
let mut errors = vec![];
8490
let mut stylesheet_output: Stylesheet =
8591
parse_file(&fm_output, None, Default::default(), &mut errors).map_err(|err| {

0 commit comments

Comments
 (0)
Please sign in to comment.