Skip to content

Commit 7c9be45

Browse files
robert-j-webbijjk
andauthored
[Turbopack] Include CSS URL attributes, including Layer, Media and Supports (#89300)
Note that this is my first contribution in Rust, so let me know if I missed anything idiomatic or if there is a particularly better way to do something. Also, I did not use AI to create this at all, although I did chat a bit to try to wrap my head around types. - Related issues linked using Fixes #88533 - Tests added. - Errors have a helpful link attached, see https://github.com/vercel/next.js/blob/canary/contributing.md Summary of changes: Adds support for all of the attributes of `@import` for Turbopack, by modifying the turbopack-css package, including Layer, Media and Supports. [W3 Reference](https://www.w3.org/TR/css-cascade-5/#at-import) --------- Co-authored-by: JJ Kasper <jj@jjsweb.site>
1 parent 9ce7250 commit 7c9be45

27 files changed

+218
-60
lines changed
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
@import url('https://cdn.jsdelivr.net/npm/modern-css-reset/dist/reset.min.css')
2+
layer(default);
3+
/* Any external stylesheet should work. Using this css-reset because it is very small and backed by CDN */
4+
5+
@layer default, new;
6+
7+
@layer new {
8+
h1 {
9+
margin: 5px;
10+
}
11+
}
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
import './external-layer.css'
2+
3+
export default function Home() {
4+
return <h1>Hello</h1>
5+
}
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
h2 {
2+
color: rgb(0, 0, 255);
3+
}
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
import './relative-layer.css'
2+
3+
export default function Home() {
4+
return <h2>Hello</h2>
5+
}
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
@import './import.css' layer(new);
2+
3+
@layer default, new;
4+
5+
@layer default {
6+
h2 {
7+
color: rgb(255, 0, 0);
8+
}
9+
}
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
body {
2+
background: black;
3+
}
4+
h1 {
5+
color: rgb(255, 255, 255);
6+
}
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
body {
2+
background: white;
3+
}
4+
h1 {
5+
color: rgb(0, 0, 0);
6+
}
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
import './url-media.css'
2+
3+
export default function Home() {
4+
return <h1>Hello</h1>
5+
}
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
@import url('./mobile-only.css') screen and (max-width: 400px);
2+
@import url('./desktop-only.css') screen and (min-width: 401px);
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
h1 {
2+
color: rgb(0, 100, 0) !important;
3+
}

0 commit comments

Comments
 (0)