Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
N
next.js
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Alex
next.js
Commits
aebf26f7
Unverified
Commit
aebf26f7
authored
Apr 11, 2025
by
Jan Nicklas
Committed by
GitHub
Apr 11, 2025
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Turbopack: support for CSS Modules in Data URLs (#78040)
Co-authored-by:
Tobias Koppers
<
tobias.koppers@googlemail.com
>
parent
debc7924
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
38 additions
and
4 deletions
+38
-4
dark.svg
...s/tests/execution/turbopack/data-url/basic/input/dark.svg
+17
-0
index.js
...s/tests/execution/turbopack/data-url/basic/input/index.js
+5
-0
other.js
...s/tests/execution/turbopack/data-url/basic/input/other.js
+0
-0
mod.rs
turbopack/crates/turbopack/src/module_options/mod.rs
+16
-4
No files found.
turbopack/crates/turbopack-tests/tests/execution/turbopack/data-url/basic/input/dark.svg
0 → 100644
View file @
aebf26f7
<?xml version="1.0" encoding="UTF-8"?>
<svg
width=
"114px"
height=
"100px"
viewBox=
"0 0 114 100"
version=
"1.1"
xmlns=
"http://www.w3.org/2000/svg"
xmlns:xlink=
"http://www.w3.org/1999/xlink"
>
<!-- Generator: Sketch 51.2 (57519) - http://www.bohemiancoding.com/sketch -->
<title>
Logotype - Black
</title>
<desc>
Created with Sketch.
</desc>
<defs>
<linearGradient
x1=
"100.929941%"
y1=
"181.283245%"
x2=
"41.7687834%"
y2=
"100%"
id=
"linearGradient-1"
>
<stop
stop-color=
"#FFFFFF"
offset=
"0%"
></stop>
<stop
stop-color=
"#000000"
offset=
"100%"
></stop>
</linearGradient>
</defs>
<g
id=
"Page-1"
stroke=
"none"
stroke-width=
"1"
fill=
"none"
fill-rule=
"evenodd"
>
<g
id=
"Black-Triangle"
transform=
"translate(-293.000000, -150.000000)"
fill=
"url(#linearGradient-1)"
>
<polygon
id=
"Logotype---Black"
points=
"350 150 407 250 293 250"
></polygon>
</g>
</g>
</svg>
turbopack/crates/turbopack-tests/tests/execution/turbopack/data-url/basic/input/index.js
View file @
aebf26f7
...
@@ -3,10 +3,15 @@ import data from 'data:application/json,{ "foo": 1234 }';
...
@@ -3,10 +3,15 @@ import data from 'data:application/json,{ "foo": 1234 }';
import
dataURLEncoded
from
'data:application/json,%7B%20%22foo%22%3A%201234%20%7D'
;
import
dataURLEncoded
from
'data:application/json,%7B%20%22foo%22%3A%201234%20%7D'
;
import
dataBase64Encoded
from
'data:application/json;base64,eyAiZm9vIjogMTIzNCB9'
;
import
dataBase64Encoded
from
'data:application/json;base64,eyAiZm9vIjogMTIzNCB9'
;
import
"data:text/css,body { color: red }"
;
import
"data:text/css,body { color: red }"
;
import
"data:text/css,body { background: url('./dark.svg') }"
;
import
*
as
style
from
"data:text/css+module,.bar { background: url('./dark.svg') }"
;
import
*
as
style64
from
"data:text/css+module;base64,LmJhciB7IGJhY2tncm91bmQ6IHVybCgnLi9kYXJrLnN2ZycpIH0="
;
it
(
"support data URL imports"
,
()
=>
{
it
(
"support data URL imports"
,
()
=>
{
expect
(
bar
).
toEqual
(
1234
);
expect
(
bar
).
toEqual
(
1234
);
expect
(
data
).
toEqual
({
foo
:
1234
});
expect
(
data
).
toEqual
({
foo
:
1234
});
expect
(
dataURLEncoded
).
toEqual
({
foo
:
1234
});
expect
(
dataURLEncoded
).
toEqual
({
foo
:
1234
});
expect
(
dataBase64Encoded
).
toEqual
({
foo
:
1234
});
expect
(
dataBase64Encoded
).
toEqual
({
foo
:
1234
});
expect
(
style
.
bar
).
toMatch
(
/bar/
);
expect
(
style64
.
bar
).
toMatch
(
/bar/
);
});
});
turbopack/crates/turbopack-tests/tests/execution/turbopack/data-url/basic/input/other.js
deleted
100644 → 0
View file @
debc7924
turbopack/crates/turbopack/src/module_options/mod.rs
View file @
aebf26f7
...
@@ -450,7 +450,10 @@ impl ModuleOptions {
...
@@ -450,7 +450,10 @@ impl ModuleOptions {
})],
})],
),
),
ModuleRule
::
new
(
ModuleRule
::
new
(
RuleCondition
::
ResourcePathEndsWith
(
".module.css"
.to_string
()),
RuleCondition
::
any
(
vec!
[
RuleCondition
::
ResourcePathEndsWith
(
".module.css"
.to_string
()),
RuleCondition
::
ContentTypeStartsWith
(
"text/css+module"
.to_string
()),
]),
vec!
[
ModuleRuleEffect
::
ModuleType
(
ModuleType
::
Css
{
vec!
[
ModuleRuleEffect
::
ModuleType
(
ModuleType
::
Css
{
ty
:
CssModuleAssetType
::
Module
,
ty
:
CssModuleAssetType
::
Module
,
})],
})],
...
@@ -509,7 +512,10 @@ impl ModuleOptions {
...
@@ -509,7 +512,10 @@ impl ModuleOptions {
),
),
ModuleRule
::
new
(
ModuleRule
::
new
(
RuleCondition
::
all
(
vec!
[
RuleCondition
::
all
(
vec!
[
RuleCondition
::
ResourcePathEndsWith
(
".module.css"
.to_string
()),
RuleCondition
::
Any
(
vec!
[
RuleCondition
::
ResourcePathEndsWith
(
".module.css"
.to_string
()),
RuleCondition
::
ContentTypeStartsWith
(
"text/css+module"
.to_string
()),
]),
// Only create a module CSS asset if not `@import`ed from CSS already.
// Only create a module CSS asset if not `@import`ed from CSS already.
// NOTE: `composes` references should not be treated as `@import`s and
// NOTE: `composes` references should not be treated as `@import`s and
// should also create a module CSS asset.
// should also create a module CSS asset.
...
@@ -533,7 +539,10 @@ impl ModuleOptions {
...
@@ -533,7 +539,10 @@ impl ModuleOptions {
),
),
// Ecmascript CSS Modules referencing the actual CSS module to include it
// Ecmascript CSS Modules referencing the actual CSS module to include it
ModuleRule
::
new_internal
(
ModuleRule
::
new_internal
(
RuleCondition
::
ResourcePathEndsWith
(
".module.css"
.to_string
()),
RuleCondition
::
Any
(
vec!
[
RuleCondition
::
ResourcePathEndsWith
(
".module.css"
.to_string
()),
RuleCondition
::
ContentTypeStartsWith
(
"text/css+module"
.to_string
()),
]),
vec!
[
ModuleRuleEffect
::
ModuleType
(
ModuleType
::
Css
{
vec!
[
ModuleRuleEffect
::
ModuleType
(
ModuleType
::
Css
{
ty
:
CssModuleAssetType
::
Module
,
ty
:
CssModuleAssetType
::
Module
,
})],
})],
...
@@ -544,7 +553,10 @@ impl ModuleOptions {
...
@@ -544,7 +553,10 @@ impl ModuleOptions {
RuleCondition
::
ReferenceType
(
ReferenceType
::
Css
(
RuleCondition
::
ReferenceType
(
ReferenceType
::
Css
(
CssReferenceSubType
::
Analyze
,
CssReferenceSubType
::
Analyze
,
)),
)),
RuleCondition
::
ResourcePathEndsWith
(
".module.css"
.to_string
()),
RuleCondition
::
Any
(
vec!
[
RuleCondition
::
ResourcePathEndsWith
(
".module.css"
.to_string
()),
RuleCondition
::
ContentTypeStartsWith
(
"text/css+module"
.to_string
()),
]),
]),
]),
vec!
[
ModuleRuleEffect
::
ModuleType
(
ModuleType
::
Css
{
vec!
[
ModuleRuleEffect
::
ModuleType
(
ModuleType
::
Css
{
ty
:
CssModuleAssetType
::
Module
,
ty
:
CssModuleAssetType
::
Module
,
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment