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
09bd4411
Unverified
Commit
09bd4411
authored
Aug 11, 2025
by
Jude Gao
Committed by
GitHub
Aug 11, 2025
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Revert "Turbopack: fix CSS module references, take 2 (#82448)"
This reverts commit
0ec5511d
.
parent
d75d90f3
Show whitespace changes
Inline
Side-by-side
Showing
14 changed files
with
102 additions
and
186 deletions
+102
-186
build_and_test.yml
.github/workflows/build_and_test.yml
+2
-0
app.rs
crates/next-api/src/app.rs
+34
-27
context.rs
crates/next-core/src/next_client/context.rs
+1
-5
context.rs
crates/next-core/src/next_server/context.rs
+0
-2
transforms.rs
crates/next-core/src/next_server/transforms.rs
+27
-10
util.rs
crates/next-core/src/util.rs
+0
-46
raw_vc.rs
turbopack/crates/turbo-tasks/src/raw_vc.rs
+2
-29
mod.rs
turbopack/crates/turbo-tasks/src/vc/mod.rs
+1
-1
resolved.rs
turbopack/crates/turbo-tasks/src/vc/resolved.rs
+3
-1
mod.rs
turbopack/crates/turbopack-core/src/module_graph/mod.rs
+2
-0
reference_type.rs
turbopack/crates/turbopack-core/src/reference_type.rs
+7
-2
module_asset.rs
turbopack/crates/turbopack-css/src/module_asset.rs
+1
-1
mod.rs
turbopack/crates/turbopack/src/module_options/mod.rs
+22
-56
module_options_context.rs
...es/turbopack/src/module_options/module_options_context.rs
+0
-6
No files found.
.github/workflows/build_and_test.yml
View file @
09bd4411
...
@@ -314,6 +314,8 @@ jobs:
...
@@ -314,6 +314,8 @@ jobs:
export TURBOPACK_BUILD=1
export TURBOPACK_BUILD=1
export NEXT_TEST_MODE=start
export NEXT_TEST_MODE=start
export NEXT_TEST_REACT_VERSION="${{ matrix.react }}"
export NEXT_TEST_REACT_VERSION="${{ matrix.react }}"
# TODO(PACK-4578): Remove
export TURBOPACK_TEMP_DISABLE_DUPLICATE_MODULES_CHECK=1
node run-tests.js --timings -g ${{ matrix.group }} --type production
node run-tests.js --timings -g ${{ matrix.group }} --type production
stepName
:
'
test-turbopack-production-react-${{
matrix.react
}}-${{
matrix.group
}}'
stepName
:
'
test-turbopack-production-react-${{
matrix.react
}}-${{
matrix.group
}}'
...
...
crates/next-api/src/app.rs
View file @
09bd4411
...
@@ -34,7 +34,7 @@ use next_core::{
...
@@ -34,7 +34,7 @@ use next_core::{
},
},
next_server_utility
::{
NEXT_SERVER_UTILITY_MERGE_TAG
,
NextServerUtilityTransition
},
next_server_utility
::{
NEXT_SERVER_UTILITY_MERGE_TAG
,
NextServerUtilityTransition
},
parse_segment_config_from_source
,
parse_segment_config_from_source
,
util
::
{
NextRuntime
,
module_styles_rule_condition
,
styles_rule_condition
}
,
util
::
NextRuntime
,
};
};
use
serde
::{
Deserialize
,
Serialize
};
use
serde
::{
Deserialize
,
Serialize
};
use
tracing
::
Instrument
;
use
tracing
::
Instrument
;
...
@@ -99,6 +99,37 @@ pub struct AppProject {
...
@@ -99,6 +99,37 @@ pub struct AppProject {
pub
struct
OptionAppProject
(
Option
<
ResolvedVc
<
AppProject
>>
);
pub
struct
OptionAppProject
(
Option
<
ResolvedVc
<
AppProject
>>
);
impl
AppProject
{}
impl
AppProject
{}
fn
styles_rule_condition
()
->
RuleCondition
{
RuleCondition
::
any
(
vec!
[
RuleCondition
::
all
(
vec!
[
RuleCondition
::
ResourcePathEndsWith
(
".css"
.into
()),
RuleCondition
::
not
(
RuleCondition
::
ResourcePathEndsWith
(
".module.css"
.into
())),
]),
RuleCondition
::
all
(
vec!
[
RuleCondition
::
ResourcePathEndsWith
(
".scss"
.into
()),
RuleCondition
::
not
(
RuleCondition
::
ResourcePathEndsWith
(
".module.scss"
.into
())),
]),
RuleCondition
::
all
(
vec!
[
RuleCondition
::
ResourcePathEndsWith
(
".sass"
.into
()),
RuleCondition
::
not
(
RuleCondition
::
ResourcePathEndsWith
(
".module.sass"
.into
())),
]),
RuleCondition
::
all
(
vec!
[
RuleCondition
::
ContentTypeStartsWith
(
"text/css"
.into
()),
RuleCondition
::
not
(
RuleCondition
::
ContentTypeStartsWith
(
"text/css+module"
.into
(),
)),
]),
])
}
fn
module_styles_rule_condition
()
->
RuleCondition
{
RuleCondition
::
any
(
vec!
[
RuleCondition
::
ResourcePathEndsWith
(
".module.css"
.into
()),
RuleCondition
::
ResourcePathEndsWith
(
".module.scss"
.into
()),
RuleCondition
::
ResourcePathEndsWith
(
".module.sass"
.into
()),
RuleCondition
::
ContentTypeStartsWith
(
"text/css+module"
.into
()),
])
}
impl
AppProject
{
impl
AppProject
{
pub
fn
client_transition_name
()
->
RcStr
{
pub
fn
client_transition_name
()
->
RcStr
{
rcstr!
(
"next-ecmascript-client-reference"
)
rcstr!
(
"next-ecmascript-client-reference"
)
...
@@ -375,10 +406,10 @@ impl AppProject {
...
@@ -375,10 +406,10 @@ impl AppProject {
transition_rules
:
vec!
[
transition_rules
:
vec!
[
// Mark as client reference (and exclude from RSC chunking) the edge from the
// Mark as client reference (and exclude from RSC chunking) the edge from the
// CSS Module to the actual CSS
// CSS Module to the actual CSS
TransitionRule
::
new
(
TransitionRule
::
new
_internal
(
RuleCondition
::
all
(
vec!
[
RuleCondition
::
all
(
vec!
[
RuleCondition
::
ReferenceType
(
ReferenceType
::
Css
(
RuleCondition
::
ReferenceType
(
ReferenceType
::
Css
(
CssReferenceSubType
::
In
ner
,
CssReferenceSubType
::
In
ternal
,
)),
)),
module_styles_rule_condition
(),
module_styles_rule_condition
(),
]),
]),
...
@@ -647,18 +678,6 @@ impl AppProject {
...
@@ -647,18 +678,6 @@ impl AppProject {
Ok
(
ModuleAssetContext
::
new
(
Ok
(
ModuleAssetContext
::
new
(
TransitionOptions
{
TransitionOptions
{
named_transitions
:
transitions
,
named_transitions
:
transitions
,
transition_rules
:
vec!
[
// Change context, this is used to determine the list of CSS module classes.
TransitionRule
::
new
(
RuleCondition
::
all
(
vec!
[
RuleCondition
::
ReferenceType
(
ReferenceType
::
Css
(
CssReferenceSubType
::
Analyze
,
)),
module_styles_rule_condition
(),
]),
ResolvedVc
::
upcast
(
self
.client_transition
()
.to_resolved
()
.await
?
),
),
],
..
Default
::
default
()
..
Default
::
default
()
}
}
.cell
(),
.cell
(),
...
@@ -719,18 +738,6 @@ impl AppProject {
...
@@ -719,18 +738,6 @@ impl AppProject {
Ok
(
ModuleAssetContext
::
new
(
Ok
(
ModuleAssetContext
::
new
(
TransitionOptions
{
TransitionOptions
{
named_transitions
:
transitions
,
named_transitions
:
transitions
,
transition_rules
:
vec!
[
// Change context, this is used to determine the list of CSS module classes.
TransitionRule
::
new
(
RuleCondition
::
all
(
vec!
[
RuleCondition
::
ReferenceType
(
ReferenceType
::
Css
(
CssReferenceSubType
::
Analyze
,
)),
module_styles_rule_condition
(),
]),
ResolvedVc
::
upcast
(
self
.client_transition
()
.to_resolved
()
.await
?
),
),
],
..
Default
::
default
()
..
Default
::
default
()
}
}
.cell
(),
.cell
(),
...
...
crates/next-core/src/next_client/context.rs
View file @
09bd4411
...
@@ -64,10 +64,7 @@ use crate::{
...
@@ -64,10 +64,7 @@ use crate::{
get_decorators_transform_options
,
get_jsx_transform_options
,
get_decorators_transform_options
,
get_jsx_transform_options
,
get_typescript_transform_options
,
get_typescript_transform_options
,
},
},
util
::{
util
::{
OptionEnvMap
,
defines
,
foreign_code_context_condition
,
internal_assets_conditions
},
OptionEnvMap
,
defines
,
foreign_code_context_condition
,
internal_assets_conditions
,
module_styles_rule_condition
,
},
};
};
#[turbo_tasks
::
function]
#[turbo_tasks
::
function]
...
@@ -319,7 +316,6 @@ pub async fn get_client_module_options_context(
...
@@ -319,7 +316,6 @@ pub async fn get_client_module_options_context(
},
},
css
:
CssOptionsContext
{
css
:
CssOptionsContext
{
source_maps
,
source_maps
,
module_css_condition
:
Some
(
module_styles_rule_condition
()),
..
Default
::
default
()
..
Default
::
default
()
},
},
environment
:
Some
(
env
),
environment
:
Some
(
env
),
...
...
crates/next-core/src/next_server/context.rs
View file @
09bd4411
...
@@ -75,7 +75,6 @@ use crate::{
...
@@ -75,7 +75,6 @@ use crate::{
util
::{
util
::{
NextRuntime
,
OptionEnvMap
,
defines
,
foreign_code_context_condition
,
NextRuntime
,
OptionEnvMap
,
defines
,
foreign_code_context_condition
,
get_transpiled_packages
,
internal_assets_conditions
,
load_next_js_templateon
,
get_transpiled_packages
,
internal_assets_conditions
,
load_next_js_templateon
,
module_styles_rule_condition
,
},
},
};
};
...
@@ -584,7 +583,6 @@ pub async fn get_server_module_options_context(
...
@@ -584,7 +583,6 @@ pub async fn get_server_module_options_context(
environment
:
Some
(
environment
),
environment
:
Some
(
environment
),
css
:
CssOptionsContext
{
css
:
CssOptionsContext
{
source_maps
,
source_maps
,
module_css_condition
:
Some
(
module_styles_rule_condition
()),
..
Default
::
default
()
..
Default
::
default
()
},
},
tree_shaking_mode
:
tree_shaking_mode_for_user_code
,
tree_shaking_mode
:
tree_shaking_mode_for_user_code
,
...
...
crates/next-core/src/next_server/transforms.rs
View file @
09bd4411
...
@@ -3,7 +3,7 @@ use next_custom_transforms::transforms::strip_page_exports::ExportFilter;
...
@@ -3,7 +3,7 @@ use next_custom_transforms::transforms::strip_page_exports::ExportFilter;
use
turbo_rcstr
::
RcStr
;
use
turbo_rcstr
::
RcStr
;
use
turbo_tasks
::{
ResolvedVc
,
Vc
};
use
turbo_tasks
::{
ResolvedVc
,
Vc
};
use
turbopack
::
module_options
::{
ModuleRule
,
ModuleRuleEffect
,
RuleCondition
};
use
turbopack
::
module_options
::{
ModuleRule
,
ModuleRuleEffect
,
RuleCondition
};
use
turbopack_core
::
reference_type
::{
CssReferenceSubType
,
ReferenceType
,
UrlReferenceSubType
};
use
turbopack_core
::
reference_type
::{
ReferenceType
,
UrlReferenceSubType
};
use
crate
::{
use
crate
::{
mode
::
NextMode
,
mode
::
NextMode
,
...
@@ -21,7 +21,7 @@ use crate::{
...
@@ -21,7 +21,7 @@ use crate::{
next_page_static_info
::
get_next_page_static_info_assert_rule
,
next_page_static_info
::
get_next_page_static_info_assert_rule
,
next_pure
::
get_next_pure_rule
,
server_actions
::
ActionsTransform
,
next_pure
::
get_next_pure_rule
,
server_actions
::
ActionsTransform
,
},
},
util
::
{
NextRuntime
,
module_styles_rule_condition
,
styles_rule_condition
}
,
util
::
NextRuntime
,
};
};
/// Returns a list of module rules which apply server-side, Next.js-specific
/// Returns a list of module rules which apply server-side, Next.js-specific
...
@@ -51,18 +51,35 @@ pub async fn get_next_server_transforms_rules(
...
@@ -51,18 +51,35 @@ pub async fn get_next_server_transforms_rules(
if
!
matches!
(
context_ty
,
ServerContextType
::
AppRSC
{
..
})
{
if
!
matches!
(
context_ty
,
ServerContextType
::
AppRSC
{
..
})
{
rules
.extend
([
rules
.extend
([
// Ignore the inner ModuleCssAsset -> CssModuleAsset references
// Ignore the internal ModuleCssAsset -> CssModuleAsset references
// The CSS Module module itself (and the Analyze reference) is still needed to generate
// The CSS Module module itself is still needed for class names
// the class names object.
ModuleRule
::
new_internal
(
RuleCondition
::
any
(
vec!
[
RuleCondition
::
ResourcePathEndsWith
(
".module.css"
.into
()),
RuleCondition
::
ContentTypeStartsWith
(
"text/css+module"
.into
()),
]),
vec!
[
ModuleRuleEffect
::
Ignore
],
),
]);
rules
.extend
([
// Ignore all non-module CSS references
ModuleRule
::
new
(
ModuleRule
::
new
(
RuleCondition
::
any
(
vec!
[
RuleCondition
::
all
(
vec!
[
RuleCondition
::
ResourcePathEndsWith
(
".css"
.into
()),
RuleCondition
::
not
(
RuleCondition
::
ResourcePathEndsWith
(
".module.css"
.into
(),
)),
]),
RuleCondition
::
all
(
vec!
[
RuleCondition
::
all
(
vec!
[
RuleCondition
::
ReferenceType
(
ReferenceType
::
Css
(
CssReferenceSubType
::
Inner
)),
RuleCondition
::
ContentTypeStartsWith
(
"text/css"
.into
()),
module_styles_rule_condition
(),
RuleCondition
::
not
(
RuleCondition
::
ContentTypeStartsWith
(
"text/css+module"
.into
(),
)),
]),
]),
]),
vec!
[
ModuleRuleEffect
::
Ignore
],
vec!
[
ModuleRuleEffect
::
Ignore
],
),
),
// Ignore all non-module CSS references
ModuleRule
::
new
(
styles_rule_condition
(),
vec!
[
ModuleRuleEffect
::
Ignore
]),
]);
]);
}
}
...
...
crates/next-core/src/util.rs
View file @
09bd4411
...
@@ -16,7 +16,6 @@ use turbo_tasks_fs::{
...
@@ -16,7 +16,6 @@ use turbo_tasks_fs::{
self
,
File
,
FileContent
,
FileSystem
,
FileSystemPath
,
json
::
parse_json_rope_with_source_context
,
self
,
File
,
FileContent
,
FileSystem
,
FileSystemPath
,
json
::
parse_json_rope_with_source_context
,
rope
::
Rope
,
rope
::
Rope
,
};
};
use
turbopack
::
module_options
::
RuleCondition
;
use
turbopack_core
::{
use
turbopack_core
::{
asset
::
AssetContent
,
asset
::
AssetContent
,
compile_time_info
::{
CompileTimeDefineValue
,
CompileTimeDefines
,
DefinableNameSegment
},
compile_time_info
::{
CompileTimeDefineValue
,
CompileTimeDefines
,
DefinableNameSegment
},
...
@@ -794,48 +793,3 @@ pub async fn load_next_js_templateon<T: DeserializeOwned>(
...
@@ -794,48 +793,3 @@ pub async fn load_next_js_templateon<T: DeserializeOwned>(
Ok
(
result
)
Ok
(
result
)
}
}
pub
fn
styles_rule_condition
()
->
RuleCondition
{
RuleCondition
::
any
(
vec!
[
RuleCondition
::
all
(
vec!
[
RuleCondition
::
ResourcePathEndsWith
(
".css"
.into
()),
RuleCondition
::
not
(
RuleCondition
::
ResourcePathEndsWith
(
".module.css"
.into
())),
]),
RuleCondition
::
all
(
vec!
[
RuleCondition
::
ResourcePathEndsWith
(
".sass"
.into
()),
RuleCondition
::
not
(
RuleCondition
::
ResourcePathEndsWith
(
".module.sass"
.into
())),
]),
RuleCondition
::
all
(
vec!
[
RuleCondition
::
ResourcePathEndsWith
(
".scss"
.into
()),
RuleCondition
::
not
(
RuleCondition
::
ResourcePathEndsWith
(
".module.scss"
.into
())),
]),
RuleCondition
::
all
(
vec!
[
RuleCondition
::
ContentTypeStartsWith
(
"text/css"
.into
()),
RuleCondition
::
not
(
RuleCondition
::
ContentTypeStartsWith
(
"text/css+module"
.into
(),
)),
]),
RuleCondition
::
all
(
vec!
[
RuleCondition
::
ContentTypeStartsWith
(
"text/sass"
.into
()),
RuleCondition
::
not
(
RuleCondition
::
ContentTypeStartsWith
(
"text/sass+module"
.into
(),
)),
]),
RuleCondition
::
all
(
vec!
[
RuleCondition
::
ContentTypeStartsWith
(
"text/scss"
.into
()),
RuleCondition
::
not
(
RuleCondition
::
ContentTypeStartsWith
(
"text/scss+module"
.into
(),
)),
]),
])
}
pub
fn
module_styles_rule_condition
()
->
RuleCondition
{
RuleCondition
::
any
(
vec!
[
RuleCondition
::
ResourcePathEndsWith
(
".module.css"
.into
()),
RuleCondition
::
ResourcePathEndsWith
(
".module.scss"
.into
()),
RuleCondition
::
ResourcePathEndsWith
(
".module.sass"
.into
()),
RuleCondition
::
ContentTypeStartsWith
(
"text/css+module"
.into
()),
RuleCondition
::
ContentTypeStartsWith
(
"text/sass+module"
.into
()),
RuleCondition
::
ContentTypeStartsWith
(
"text/scss+module"
.into
()),
])
}
turbopack/crates/turbo-tasks/src/raw_vc.rs
View file @
09bd4411
use
std
::{
use
std
::{
fmt
::
Display
,
future
::
Future
,
pin
::
Pin
,
task
::
Poll
};
fmt
::{
Debug
,
Display
},
future
::
Future
,
pin
::
Pin
,
task
::
Poll
,
};
use
anyhow
::
Result
;
use
anyhow
::
Result
;
use
auto_hash_map
::
AutoSet
;
use
auto_hash_map
::
AutoSet
;
...
@@ -59,7 +54,7 @@ impl Display for CellId {
...
@@ -59,7 +54,7 @@ impl Display for CellId {
/// otherwise be treated as an internal implementation detail of `turbo-tasks`.
/// otherwise be treated as an internal implementation detail of `turbo-tasks`.
///
///
/// [monomorphization]: https://doc.rust-lang.org/book/ch10-01-syntax.html#performance-of-code-using-generics
/// [monomorphization]: https://doc.rust-lang.org/book/ch10-01-syntax.html#performance-of-code-using-generics
#[derive(Clone,
Copy,
PartialEq,
Eq,
Hash,
Serialize,
Deserialize)]
#[derive(
Debug,
Clone,
Copy,
PartialEq,
Eq,
Hash,
Serialize,
Deserialize)]
pub
enum
RawVc
{
pub
enum
RawVc
{
/// The synchronous return value of a task (after argument resolution). This is the
/// The synchronous return value of a task (after argument resolution). This is the
/// representation used by [`OperationVc`][crate::OperationVc].
/// representation used by [`OperationVc`][crate::OperationVc].
...
@@ -79,28 +74,6 @@ pub enum RawVc {
...
@@ -79,28 +74,6 @@ pub enum RawVc {
LocalOutput
(
ExecutionId
,
LocalTaskId
,
TaskPersistence
),
LocalOutput
(
ExecutionId
,
LocalTaskId
,
TaskPersistence
),
}
}
impl
Debug
for
RawVc
{
fn
fmt
(
&
self
,
f
:
&
mut
std
::
fmt
::
Formatter
<
'_
>
)
->
std
::
fmt
::
Result
{
match
self
{
RawVc
::
TaskOutput
(
task_id
)
=>
f
.debug_tuple
(
"RawVc::TaskOutput"
)
.field
(
&**
task_id
)
.finish
(),
RawVc
::
TaskCell
(
task_id
,
cell_id
)
=>
f
.debug_tuple
(
"RawVc::TaskCell"
)
.field
(
&**
task_id
)
.field
(
&
cell_id
.to_string
())
.finish
(),
RawVc
::
LocalOutput
(
execution_id
,
local_task_id
,
task_persistence
)
=>
f
.debug_tuple
(
"RawVc::LocalOutput"
)
.field
(
&**
execution_id
)
.field
(
&**
local_task_id
)
.field
(
task_persistence
)
.finish
(),
}
}
}
impl
RawVc
{
impl
RawVc
{
pub
fn
is_resolved
(
&
self
)
->
bool
{
pub
fn
is_resolved
(
&
self
)
->
bool
{
match
self
{
match
self
{
...
...
turbopack/crates/turbo-tasks/src/vc/mod.rs
View file @
09bd4411
...
@@ -357,7 +357,7 @@ where
...
@@ -357,7 +357,7 @@ where
T
:
?
Sized
,
T
:
?
Sized
,
{
{
fn
fmt
(
&
self
,
f
:
&
mut
std
::
fmt
::
Formatter
<
'_
>
)
->
std
::
fmt
::
Result
{
fn
fmt
(
&
self
,
f
:
&
mut
std
::
fmt
::
Formatter
<
'_
>
)
->
std
::
fmt
::
Result
{
f
.debug_
tuple
(
"Vc"
)
.field
(
&
self
.node
)
.finish
()
f
.debug_
struct
(
"Vc"
)
.field
(
"node"
,
&
self
.node
)
.finish
()
}
}
}
}
...
...
turbopack/crates/turbo-tasks/src/vc/resolved.rs
View file @
09bd4411
...
@@ -295,7 +295,9 @@ where
...
@@ -295,7 +295,9 @@ where
T
:
?
Sized
,
T
:
?
Sized
,
{
{
fn
fmt
(
&
self
,
f
:
&
mut
std
::
fmt
::
Formatter
<
'_
>
)
->
std
::
fmt
::
Result
{
fn
fmt
(
&
self
,
f
:
&
mut
std
::
fmt
::
Formatter
<
'_
>
)
->
std
::
fmt
::
Result
{
f
.debug_tuple
(
"ResolvedVc"
)
.field
(
&
self
.node.node
)
.finish
()
f
.debug_struct
(
"ResolvedVc"
)
.field
(
"node"
,
&
self
.node.node
)
.finish
()
}
}
}
}
...
...
turbopack/crates/turbopack-core/src/module_graph/mod.rs
View file @
09bd4411
...
@@ -348,6 +348,8 @@ impl SingleModuleGraph {
...
@@ -348,6 +348,8 @@ impl SingleModuleGraph {
#[cfg(debug_assertions)]
#[cfg(debug_assertions)]
{
{
use
once_cell
::
sync
::
Lazy
;
use
once_cell
::
sync
::
Lazy
;
// TODO(PACK-4578): This is temporary while the last issues are being addressed.
static
CHECK_FOR_DUPLICATE_MODULES
:
Lazy
<
bool
>
=
Lazy
::
new
(||
{
static
CHECK_FOR_DUPLICATE_MODULES
:
Lazy
<
bool
>
=
Lazy
::
new
(||
{
match
std
::
env
::
var_os
(
"TURBOPACK_TEMP_DISABLE_DUPLICATE_MODULES_CHECK"
)
{
match
std
::
env
::
var_os
(
"TURBOPACK_TEMP_DISABLE_DUPLICATE_MODULES_CHECK"
)
{
Some
(
v
)
=>
v
!=
"1"
&&
v
!=
"true"
,
Some
(
v
)
=>
v
!=
"1"
&&
v
!=
"true"
,
...
...
turbopack/crates/turbopack-core/src/reference_type.rs
View file @
09bd4411
...
@@ -221,7 +221,7 @@ pub enum CssReferenceSubType {
...
@@ -221,7 +221,7 @@ pub enum CssReferenceSubType {
/// class name
/// class name
Compose
,
Compose
,
/// Reference from ModuleCssAsset to the CssModuleAsset
/// Reference from ModuleCssAsset to the CssModuleAsset
In
ner
,
In
ternal
,
/// Used for generating the list of classes in a ModuleCssAsset
/// Used for generating the list of classes in a ModuleCssAsset
Analyze
,
Analyze
,
Custom
(
u8
),
Custom
(
u8
),
...
@@ -417,6 +417,11 @@ impl ReferenceType {
...
@@ -417,6 +417,11 @@ impl ReferenceType {
/// combination with [`ModuleRuleCondition::Internal`] to determine if a
/// combination with [`ModuleRuleCondition::Internal`] to determine if a
/// rule should be applied to an internal asset/reference.
/// rule should be applied to an internal asset/reference.
pub
fn
is_internal
(
&
self
)
->
bool
{
pub
fn
is_internal
(
&
self
)
->
bool
{
matches!
(
self
,
ReferenceType
::
Internal
(
_
)
|
ReferenceType
::
Runtime
)
matches!
(
self
,
ReferenceType
::
Internal
(
_
)
|
ReferenceType
::
Css
(
CssReferenceSubType
::
Internal
)
|
ReferenceType
::
Runtime
)
}
}
}
}
turbopack/crates/turbopack-css/src/module_asset.rs
View file @
09bd4411
...
@@ -88,7 +88,7 @@ impl Module for ModuleCssAsset {
...
@@ -88,7 +88,7 @@ impl Module for ModuleCssAsset {
.copied
()
.copied
()
.chain
(
.chain
(
match
*
self
match
*
self
.inner
(
ReferenceType
::
Css
(
CssReferenceSubType
::
In
ner
))
.inner
(
ReferenceType
::
Css
(
CssReferenceSubType
::
In
ternal
))
.try_into_module
()
.try_into_module
()
.await
?
.await
?
{
{
...
...
turbopack/crates/turbopack/src/module_options/mod.rs
View file @
09bd4411
...
@@ -137,7 +137,6 @@ impl ModuleOptions {
...
@@ -137,7 +137,6 @@ impl ModuleOptions {
CssOptionsContext
{
CssOptionsContext
{
enable_raw_css
,
enable_raw_css
,
source_maps
:
css_source_maps
,
source_maps
:
css_source_maps
,
ref
module_css_condition
,
..
..
},
},
ref
enable_postcss_transform
,
ref
enable_postcss_transform
,
...
@@ -150,28 +149,6 @@ impl ModuleOptions {
...
@@ -150,28 +149,6 @@ impl ModuleOptions {
..
..
}
=
*
module_options_context
.await
?
;
}
=
*
module_options_context
.await
?
;
let
module_css_condition
=
module_css_condition
.clone
()
.unwrap_or_else
(||
{
RuleCondition
::
any
(
vec!
[
RuleCondition
::
ResourcePathEndsWith
(
".module.css"
.to_string
()),
RuleCondition
::
ContentTypeStartsWith
(
"text/css+module"
.to_string
()),
])
});
// For React Client References, the CSS Module "facade" module lives in the parent (server)
// module context, but the facade's references should be transitioned to the client (and
// only then be processed with Webpack/PostCSS).
//
// Note that this is not an exhaustive condition for PostCSS/Webpack, but excludes certain
// cases, so it should be added conjunctively together with the `module_css_condition` rule.
//
// If module css, then only when (Inner or Analyze or Compose)
// <=> (not (module css)) or (Inner or Analyzer or Compose)
let
module_css_external_transform_conditions
=
vec!
[
RuleCondition
::
ReferenceType
(
ReferenceType
::
Css
(
CssReferenceSubType
::
Inner
)),
RuleCondition
::
ReferenceType
(
ReferenceType
::
Css
(
CssReferenceSubType
::
Analyze
)),
RuleCondition
::
ReferenceType
(
ReferenceType
::
Css
(
CssReferenceSubType
::
Compose
)),
];
let
mut
ts_preprocess
=
vec!
[];
let
mut
ts_preprocess
=
vec!
[];
let
mut
ecma_preprocess
=
vec!
[];
let
mut
ecma_preprocess
=
vec!
[];
let
mut
postprocess
=
vec!
[];
let
mut
postprocess
=
vec!
[];
...
@@ -481,7 +458,10 @@ impl ModuleOptions {
...
@@ -481,7 +458,10 @@ impl ModuleOptions {
})],
})],
),
),
ModuleRule
::
new
(
ModuleRule
::
new
(
module_css_condition
.clone
(),
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
,
environment
,
environment
,
...
@@ -505,23 +485,10 @@ impl ModuleOptions {
...
@@ -505,23 +485,10 @@ impl ModuleOptions {
};
};
rules
.push
(
ModuleRule
::
new
(
rules
.push
(
ModuleRule
::
new
(
RuleCondition
::
Any
(
vec!
[
RuleCondition
::
All
(
vec!
[
RuleCondition
::
Any
(
vec!
[
RuleCondition
::
Any
(
vec!
[
RuleCondition
::
ResourcePathEndsWith
(
".css"
.to_string
()),
RuleCondition
::
ResourcePathEndsWith
(
".css"
.to_string
()),
RuleCondition
::
ContentTypeStartsWith
(
"text/css"
.to_string
()),
RuleCondition
::
ContentTypeStartsWith
(
"text/css"
.to_string
()),
]),
]),
RuleCondition
::
not
(
module_css_condition
.clone
()),
]),
RuleCondition
::
All
(
[
vec!
[
module_css_condition
.clone
()],
// see comment on module_css_external_transform_conditions
module_css_external_transform_conditions
.clone
(),
]
.concat
(),
),
]),
vec!
[
ModuleRuleEffect
::
SourceTransforms
(
ResolvedVc
::
cell
(
vec!
[
vec!
[
ModuleRuleEffect
::
SourceTransforms
(
ResolvedVc
::
cell
(
vec!
[
ResolvedVc
::
upcast
(
ResolvedVc
::
upcast
(
PostCssTransform
::
new
(
PostCssTransform
::
new
(
...
@@ -556,7 +523,10 @@ impl ModuleOptions {
...
@@ -556,7 +523,10 @@ impl ModuleOptions {
),
),
ModuleRule
::
new
(
ModuleRule
::
new
(
RuleCondition
::
all
(
vec!
[
RuleCondition
::
all
(
vec!
[
module_css_condition
.clone
(),
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.
...
@@ -568,7 +538,10 @@ impl ModuleOptions {
...
@@ -568,7 +538,10 @@ impl ModuleOptions {
),
),
ModuleRule
::
new
(
ModuleRule
::
new
(
RuleCondition
::
all
(
vec!
[
RuleCondition
::
all
(
vec!
[
module_css_condition
.clone
(),
RuleCondition
::
Any
(
vec!
[
RuleCondition
::
ResourcePathEndsWith
(
".module.css"
.to_string
()),
RuleCondition
::
ContentTypeStartsWith
(
"text/css+module"
.to_string
()),
]),
// Create a normal CSS asset if `@import`ed from CSS already.
// Create a normal CSS asset if `@import`ed from CSS already.
RuleCondition
::
ReferenceType
(
ReferenceType
::
Css
(
RuleCondition
::
ReferenceType
(
ReferenceType
::
Css
(
CssReferenceSubType
::
AtImport
(
None
),
CssReferenceSubType
::
AtImport
(
None
),
...
@@ -580,12 +553,10 @@ impl ModuleOptions {
...
@@ -580,12 +553,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
(
ModuleRule
::
new_internal
(
RuleCondition
::
all
(
vec!
[
RuleCondition
::
Any
(
vec!
[
RuleCondition
::
ReferenceType
(
ReferenceType
::
Css
(
RuleCondition
::
ResourcePathEndsWith
(
".module.css"
.to_string
()),
CssReferenceSubType
::
Inner
,
RuleCondition
::
ContentTypeStartsWith
(
"text/css+module"
.to_string
()),
)),
module_css_condition
.clone
(),
]),
]),
vec!
[
ModuleRuleEffect
::
ModuleType
(
ModuleType
::
Css
{
vec!
[
ModuleRuleEffect
::
ModuleType
(
ModuleType
::
Css
{
ty
:
CssModuleAssetType
::
Module
,
ty
:
CssModuleAssetType
::
Module
,
...
@@ -598,7 +569,10 @@ impl ModuleOptions {
...
@@ -598,7 +569,10 @@ impl ModuleOptions {
RuleCondition
::
ReferenceType
(
ReferenceType
::
Css
(
RuleCondition
::
ReferenceType
(
ReferenceType
::
Css
(
CssReferenceSubType
::
Analyze
,
CssReferenceSubType
::
Analyze
,
)),
)),
module_css_condition
.clone
(),
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
,
...
@@ -703,14 +677,6 @@ impl ModuleOptions {
...
@@ -703,14 +677,6 @@ impl ModuleOptions {
RuleCondition
::
ResourceBasePathGlob
(
Glob
::
new
(
key
.clone
())
.await
?
)
RuleCondition
::
ResourceBasePathGlob
(
Glob
::
new
(
key
.clone
())
.await
?
)
},
},
RuleCondition
::
not
(
RuleCondition
::
ResourceIsVirtualSource
),
RuleCondition
::
not
(
RuleCondition
::
ResourceIsVirtualSource
),
// see comment on module_css_external_transform_conditions
RuleCondition
::
Any
(
[
vec!
[
RuleCondition
::
not
(
module_css_condition
.clone
())],
module_css_external_transform_conditions
.clone
(),
]
.concat
(),
),
]),
]),
vec!
[
ModuleRuleEffect
::
SourceTransforms
(
ResolvedVc
::
cell
(
vec!
[
vec!
[
ModuleRuleEffect
::
SourceTransforms
(
ResolvedVc
::
cell
(
vec!
[
ResolvedVc
::
upcast
(
ResolvedVc
::
upcast
(
...
...
turbopack/crates/turbopack/src/module_options/module_options_context.rs
View file @
09bd4411
...
@@ -17,7 +17,6 @@ use turbopack_node::{
...
@@ -17,7 +17,6 @@ use turbopack_node::{
};
};
use
super
::
ModuleRule
;
use
super
::
ModuleRule
;
use
crate
::
module_options
::
RuleCondition
;
#[derive(Clone,
PartialEq,
Eq,
Debug,
TraceRawVcs,
Serialize,
Deserialize,
NonLocalValue)]
#[derive(Clone,
PartialEq,
Eq,
Debug,
TraceRawVcs,
Serialize,
Deserialize,
NonLocalValue)]
pub
struct
LoaderRuleItem
{
pub
struct
LoaderRuleItem
{
...
@@ -215,11 +214,6 @@ pub struct CssOptionsContext {
...
@@ -215,11 +214,6 @@ pub struct CssOptionsContext {
/// Specifies how Source Maps are handled.
/// Specifies how Source Maps are handled.
pub
source_maps
:
SourceMapsType
,
pub
source_maps
:
SourceMapsType
,
/// Override the conditions for module CSS (doesn't have any effect if `enable_raw_css` is
/// true). By default (for `None`), it uses
/// `Any(ResourcePathEndsWith(".module.css"), ContentTypeStartsWith("text/css+module"))`
pub
module_css_condition
:
Option
<
RuleCondition
>
,
pub
placeholder_for_future_extensions
:
(),
pub
placeholder_for_future_extensions
:
(),
}
}
...
...
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