Skip to content

Commit

Permalink
fix(css): Do not resolve urls in supports query (#7730)
Browse files Browse the repository at this point in the history
### Description

 - Closes vercel/next.js#63102
 - Closes PACK-2717


### Testing Instructions

I added a test.
  • Loading branch information
kdy1 committed Mar 14, 2024
1 parent 85545db commit 8359016
Show file tree
Hide file tree
Showing 14 changed files with 95 additions and 0 deletions.
15 changes: 15 additions & 0 deletions crates/turbopack-css/src/references/mod.rs
Expand Up @@ -117,6 +117,11 @@ impl VisitMut for ModuleReferencesVisitor<'_> {
// res
}

/// Noop. Urls in `@supports` are not used.
///
/// See https://github.com/vercel/next.js/issues/63102
fn visit_mut_supports_condition(&mut self, _: &mut swc_core::css::ast::SupportsCondition) {}

fn visit_mut_url(&mut self, u: &mut swc_core::css::ast::Url) {
u.visit_mut_children_with(self);

Expand Down Expand Up @@ -221,6 +226,16 @@ impl<'a> Visitor<'_> for ModuleReferencesVisitor<'a> {

Ok(())
}

/// Noop. Urls in `@supports` are not used.
///
/// See https://github.com/vercel/next.js/issues/63102
fn visit_supports_condition(
&mut self,
_: &mut lightningcss::rules::supports::SupportsCondition<'_>,
) -> Result<(), Self::Error> {
Ok(())
}
}

#[turbo_tasks::function]
Expand Down
5 changes: 5 additions & 0 deletions crates/turbopack-tests/tests/snapshot.rs
Expand Up @@ -88,6 +88,8 @@ struct SnapshotOptions {
runtime_type: RuntimeType,
#[serde(default)]
environment: SnapshotEnvironment,
#[serde(default)]
use_swc_css: bool,
}

#[derive(Debug, Deserialize, Default)]
Expand All @@ -113,6 +115,7 @@ impl Default for SnapshotOptions {
runtime: Default::default(),
runtime_type: default_runtime_type(),
environment: Default::default(),
use_swc_css: Default::default(),
}
}
}
Expand Down Expand Up @@ -262,9 +265,11 @@ async fn run_test(resource: String) -> Result<Vc<FileSystemPath>> {
})),
preset_env_versions: Some(env),
ignore_dynamic_requests: true,
use_swc_css: options.use_swc_css,
rules: vec![(
ContextCondition::InDirectory("node_modules".to_string()),
ModuleOptionsContext {
use_swc_css: options.use_swc_css,
..Default::default()
}
.cell(),
Expand Down
@@ -0,0 +1 @@
import "./style.css";
@@ -0,0 +1,5 @@
@supports ((-webkit-mask: url("")) or (mask: url(""))) {
.supports-url-in-query {
color: red;
}
}
@@ -0,0 +1,3 @@
{
"useSwcCss": true
}

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 8359016

Please sign in to comment.