This mapping is unfinished: 94 of 3925 nodes are still unmarked.

Code view:

A painting is a person's account of this edit as text, recorded independently of the node mapping - a rendering often has several equally defensible answers where the mapping has one. Deletions and insertions carry no position on the opposite side in a painting, so that panel draws no caret for them.

Before

…lines 1–6 unchanged (6 lines)
7use turbo_tasks_fs::FileSystemPath;
8use turbopack_core::{
9 environment::Environment, reference_type::ReferenceType, source::Source,
10 source_transform::SourceTransforms,
11};
12use turbopack_css::CssModuleAssetType;
13use turbopack_ecmascript::{EcmascriptInputTransforms, EcmascriptOptions};
14use turbopack_wasm::source::WebAssemblySourceType;
15
16use crate::module_options::{CustomModuleType, RuleCondition, match_mode::MatchMode};
17
18#[derive(Debug, Clone, TraceRawVcs, PartialEq, Eq, NonLocalValue, Encode, Decode)]
19pub struct ModuleRule {
…lines 20–145 unchanged (126 lines)
146 tag: Option<RcStr>,
147 },
148 StaticUrlCss {
149 /// The tag that is passed to ChunkingContext::asset_url
150 tag: Option<RcStr>,
151 },
152 InlinedBytesJs,
153 WebAssembly {
154 source_ty: WebAssemblySourceType,
155 },
156 Custom(ResolvedVc<Box<dyn CustomModuleType>>),
157}
158
…lines 159–166 unchanged (8 lines)
167 ModuleType::Raw => write!(f, "Raw"),
168 ModuleType::NodeAddon => write!(f, "NodeAddon"),
169 ModuleType::CssModule => write!(f, "CssModule"),
170 ModuleType::Css { .. } => write!(f, "Css"),
171 ModuleType::StaticUrlJs { .. } => write!(f, "StaticUrlJs"),
172 ModuleType::StaticUrlCss { .. } => write!(f, "StaticUrlCss"),
173 ModuleType::InlinedBytesJs => write!(f, "InlinedBytesJs"),
174 ModuleType::WebAssembly { .. } => write!(f, "WebAssembly"),
175 ModuleType::Custom(_) => write!(f, "Custom"),
176 }
177 }
178}
179
180impl ModuleType {
181 /// Creates a ModuleType from a string identifier.
182 /// This is used for user-configured module types in turbopack rules.
183 pub fn from_str_with_defaults(
184 type_str: &str,
185 preprocess: ResolvedVc<EcmascriptInputTransforms>,
186 main: ResolvedVc<EcmascriptInputTransforms>,
187 postprocess: ResolvedVc<EcmascriptInputTransforms>,
188 options: ResolvedVc<EcmascriptOptions>,
189 environment: Option<ResolvedVc<Environment>>,
190 ) -> Result<Self> {
191 Ok(match type_str {
192 "asset" => ModuleType::StaticUrlJs { tag: None },
193 "ecmascript" => ModuleType::Ecmascript {
194 preprocess,
195 main,
196 postprocess,
197 options,
198 },
199 "typescript" => ModuleType::Typescript {
200 preprocess,
201 main,
202 postprocess,
203 tsx: false,
204 analyze_types: false,
205 options,
206 },
207 "css" => ModuleType::Css {
208 ty: CssModuleAssetType::Default,
209 environment,
210 },
211 "css-module" => ModuleType::CssModule,
212 "wasm" => ModuleType::WebAssembly {
213 source_ty: WebAssemblySourceType::Binary,
214 },
215 "raw" => ModuleType::Raw,
216 "node" => ModuleType::NodeAddon,
217 "bytes" => ModuleType::InlinedBytesJs,
218 _ => bail!(
219 "Unknown module type: {type_str:?}. Valid types are: asset, ecmascript, \
220 typescript, css, css-module, wasm, raw, node, bytes"
221 ),
222 })
223 }
224}
225

After

…lines 1–7 unchanged (7 lines)
8use turbopack_core::{
9 environment::Environment, reference_type::ReferenceType, source::Source,
10 source_transform::SourceTransforms,
11};
12use turbopack_css::CssModuleAssetType;
13use turbopack_ecmascript::{
14 EcmascriptInputTransforms, EcmascriptOptions, bytes_source_transform::BytesSourceTransform,
15};
16use turbopack_wasm::source::WebAssemblySourceType;
17
18use crate::module_options::{CustomModuleType, RuleCondition, match_mode::MatchMode};
19
20#[derive(Debug, Clone, TraceRawVcs, PartialEq, Eq, NonLocalValue, Encode, Decode)]
21pub struct ModuleRule {
…lines 22–147 unchanged (126 lines)
148 tag: Option<RcStr>,
149 },
150 StaticUrlCss {
151 /// The tag that is passed to ChunkingContext::asset_url
152 tag: Option<RcStr>,
153 },
154 WebAssembly {
155 source_ty: WebAssemblySourceType,
156 },
157 Custom(ResolvedVc<Box<dyn CustomModuleType>>),
158}
159
160impl Display for ModuleType {
…lines 161–167 unchanged (7 lines)
168 ModuleType::Raw => write!(f, "Raw"),
169 ModuleType::NodeAddon => write!(f, "NodeAddon"),
170 ModuleType::CssModule => write!(f, "CssModule"),
171 ModuleType::Css { .. } => write!(f, "Css"),
172 ModuleType::StaticUrlJs { .. } => write!(f, "StaticUrlJs"),
173 ModuleType::StaticUrlCss { .. } => write!(f, "StaticUrlCss"),
174 ModuleType::WebAssembly { .. } => write!(f, "WebAssembly"),
175 ModuleType::Custom(_) => write!(f, "Custom"),
176 }
177 }
178}
179
180/// User-facing module type names used in configuration.
181///
182/// This enum represents the semantic module types that users can specify in their config
183/// (e.g., next.config.js turbopack rules). Some of these map directly to internal `ModuleType`
184/// variants, while others (like `Bytes`) are implemented via source transforms.
185#[derive(Debug, Clone, PartialEq, Eq)]
186pub enum ConfiguredModuleType {
187 Asset,
188 Ecmascript,
189 Typescript,
190 Css,
191 CssModule,
192 Json,
193 Wasm,
194 Raw,
195 Node,
196 /// Converts any file to an ES module exporting its contents as a Uint8Array.
197 /// Implemented as a source transform, not a ModuleType.
198 Bytes,
199}
200
201impl ConfiguredModuleType {
202 /// Parse a module type string from user configuration.
203 pub fn parse(type_str: &str) -> Result<Self> {
204 Ok(match type_str {
205 "asset" => ConfiguredModuleType::Asset,
206 "ecmascript" => ConfiguredModuleType::Ecmascript,
207 "typescript" => ConfiguredModuleType::Typescript,
208 "css" => ConfiguredModuleType::Css,
209 "css-module" => ConfiguredModuleType::CssModule,
210 "json" => ConfiguredModuleType::Json,
211 "wasm" => ConfiguredModuleType::Wasm,
212 "raw" => ConfiguredModuleType::Raw,
213 "node" => ConfiguredModuleType::Node,
214 "bytes" => ConfiguredModuleType::Bytes,
215 _ => bail!(
216 "Unknown module type: {type_str:?}. Valid types are: asset, ecmascript, \
217 typescript, css, css-module, json, wasm, raw, node, bytes"
218 ),
219 })
220 }
221
222 /// Convert this configured module type into module rule effects.
223 ///
224 /// Some module types (like `Bytes`) are implemented as source transforms rather than
225 /// `ModuleType` variants, allowing them to compose with the standard Ecmascript pipeline.
226 pub async fn into_effect(
227 self,
228 preprocess: ResolvedVc<EcmascriptInputTransforms>,
229 main: ResolvedVc<EcmascriptInputTransforms>,
230 postprocess: ResolvedVc<EcmascriptInputTransforms>,
231 options: ResolvedVc<EcmascriptOptions>,
232 environment: Option<ResolvedVc<Environment>>,
233 ) -> Result<ModuleRuleEffect> {
234 Ok(match self {
235 ConfiguredModuleType::Bytes => {
236 // Use source transform instead of ModuleType - the transform produces .mjs
237 // which gets picked up by the standard Ecmascript rules
238 ModuleRuleEffect::SourceTransforms(ResolvedVc::cell(vec![ResolvedVc::upcast(
239 BytesSourceTransform::new().to_resolved().await?,
240 )]))
241 }
242 ConfiguredModuleType::Asset => {
243 ModuleRuleEffect::ModuleType(ModuleType::StaticUrlJs { tag: None })
244 }
245 ConfiguredModuleType::Ecmascript => {
246 ModuleRuleEffect::ModuleType(ModuleType::Ecmascript {
247 preprocess,
248 main,
249 postprocess,
250 options,
251 })
252 }
253 ConfiguredModuleType::Typescript => {
254 ModuleRuleEffect::ModuleType(ModuleType::Typescript {
255 preprocess,
256 main,
257 postprocess,
258 tsx: false,
259 analyze_types: false,
260 options,
261 })
262 }
263 ConfiguredModuleType::Css => ModuleRuleEffect::ModuleType(ModuleType::Css {
264 ty: CssModuleAssetType::Default,
265 environment,
266 }),
267 ConfiguredModuleType::CssModule => ModuleRuleEffect::ModuleType(ModuleType::CssModule),
268 ConfiguredModuleType::Json => ModuleRuleEffect::ModuleType(ModuleType::Json),
269 ConfiguredModuleType::Wasm => ModuleRuleEffect::ModuleType(ModuleType::WebAssembly {
270 source_ty: WebAssemblySourceType::Binary,
271 }),
272 ConfiguredModuleType::Raw => ModuleRuleEffect::ModuleType(ModuleType::Raw),
273 ConfiguredModuleType::Node => ModuleRuleEffect::ModuleType(ModuleType::NodeAddon),
274 })
275 }
276}
277

Before

source_file
use_declaration
use "use"
scoped_identifier
scoped_identifier
identifier "std"
:: "::"
identifier "fmt"
:: "::"
identifier "Display"
; ";"
use_declaration
use "use"
scoped_use_list
identifier "anyhow"
:: "::"
use_list
{ "{"
identifier "Result"
, ","
identifier "bail"
} "}"
; ";"
use_declaration
use "use"
scoped_use_list
identifier "bincode"
:: "::"
use_list
{ "{"
identifier "Decode"
, ","
identifier "Encode"
} "}"
; ";"
use_declaration
use "use"
scoped_identifier
identifier "turbo_rcstr"
:: "::"
identifier "RcStr"
; ";"
use_declaration
use "use"
scoped_use_list
identifier "turbo_tasks"
:: "::"
use_list
{ "{"
identifier "NonLocalValue"
, ","
identifier "ResolvedVc"
, ","
scoped_identifier
identifier "trace"
:: "::"
identifier "TraceRawVcs"
} "}"
; ";"
use_declaration
use "use"
scoped_identifier
identifier "turbo_tasks_fs"
:: "::"
identifier "FileSystemPath"
; ";"
use_declaration (+29 nodes collapsed)
use_declaration
use "use"
scoped_identifier
identifier "turbopack_css"
:: "::"
identifier "CssModuleAssetType"
; ";"
use_declaration
use "use"
scoped_use_list
identifier "turbopack_ecmascript"
:: "::"
use_list
{ "{"
identifier "EcmascriptInputTransforms"
, ","
identifier "EcmascriptOptions"
} "}"
; ";"
use_declaration
use "use"
scoped_identifier
scoped_identifier
identifier "turbopack_wasm"
:: "::"
identifier "source"
:: "::"
identifier "WebAssemblySourceType"
; ";"
use_declaration
use "use"
scoped_use_list
scoped_identifier
crate "crate"
:: "::"
identifier "module_options"
:: "::"
use_list
{ "{"
identifier "CustomModuleType"
, ","
identifier "RuleCondition"
, ","
scoped_identifier
identifier "match_mode"
:: "::"
identifier "MatchMode"
} "}"
; ";"
attribute_item (+24 nodes collapsed)
struct_item (+28 nodes collapsed)
impl_item (+326 nodes collapsed)
attribute_item
# "#"
[ "["
attribute
scoped_identifier
identifier "turbo_tasks"
:: "::"
identifier "value"
token_tree
( "("
identifier "shared"
) ")"
] "]"
attribute_item
# "#"
[ "["
attribute
identifier "derive"
token_tree
( "("
identifier "Debug"
, ","
identifier "Clone"
) ")"
] "]"
enum_item (+91 nodes collapsed)
attribute_item
# "#"
[ "["
attribute
scoped_identifier
identifier "turbo_tasks"
:: "::"
identifier "value"
token_tree
( "("
identifier "shared"
) ")"
] "]"
attribute_item
# "#"
[ "["
attribute
identifier "derive"
token_tree
( "("
identifier "Hash"
, ","
identifier "Debug"
, ","
identifier "Clone"
) ")"
] "]"
enum_item
visibility_modifier
pub "pub"
enum "enum"
type_identifier "ModuleType"
enum_variant_list
{ "{"
enum_variant (+70 nodes collapsed)
, ","
enum_variant (+84 nodes collapsed)
, ","
enum_variant (+70 nodes collapsed)
, ","
enum_variant (+70 nodes collapsed)
, ","
enum_variant
identifier "Json"
, ","
enum_variant
identifier "Raw"
, ","
enum_variant
identifier "NodeAddon"
, ","
enum_variant
identifier "CssModule"
, ","
enum_variant (+25 nodes collapsed)
, ","
enum_variant
identifier "StaticUrlJs"
field_declaration_list
{ "{"
line_comment
// "//"
outer_doc_comment_marker
/ "/"
doc_comment " The tag that is passed to ChunkingContext::asset_url\n"
field_declaration
field_identifier "tag"
: ":"
generic_type
type_identifier "Option"
type_arguments
< "<"
type_identifier "RcStr"
> ">"
, ","
} "}"
, ","
enum_variant
identifier "StaticUrlCss"
field_declaration_list
{ "{"
line_comment
// "//"
outer_doc_comment_marker
/ "/"
doc_comment " The tag that is passed to ChunkingContext::asset_url\n"
field_declaration
field_identifier "tag"
: ":"
generic_type
type_identifier "Option"
type_arguments
< "<"
type_identifier "RcStr"
> ">"
, ","
} "}"
, ","
enum_variant
identifier "InlinedBytesJs"
, ","
enum_variant
identifier "WebAssembly"
field_declaration_list
{ "{"
field_declaration
field_identifier "source_ty"
: ":"
type_identifier "WebAssemblySourceType"
, ","
} "}"
, ","
enum_variant
identifier "Custom"
ordered_field_declaration_list
( "("
generic_type
type_identifier "ResolvedVc"
type_arguments
< "<"
generic_type
type_identifier "Box"
type_arguments
< "<"
dynamic_type
dyn "dyn"
type_identifier "CustomModuleType"
> ">"
> ">"
) ")"
, ","
} "}"
impl_item
impl "impl"
type_identifier "Display"
for "for"
type_identifier "ModuleType"
declaration_list
{ "{"
function_item
fn "fn"
identifier "fmt"
parameters (+27 nodes collapsed)
-> "->"
scoped_type_identifier
scoped_identifier
identifier "std"
:: "::"
identifier "fmt"
:: "::"
type_identifier "Result"
block
{ "{"
expression_statement
match_expression
match "match"
self "self"
match_block
{ "{"
match_arm (+25 nodes collapsed)
match_arm (+25 nodes collapsed)
match_arm (+25 nodes collapsed)
match_arm (+25 nodes collapsed)
match_arm
match_pattern
scoped_identifier
identifier "ModuleType"
:: "::"
identifier "Json"
=> "=>"
macro_invocation
identifier "write"
! "!"
token_tree
( "("
identifier "f"
, ","
string_literal
" "\""
string_content "Json"
" "\""
) ")"
, ","
match_arm
match_pattern
scoped_identifier
identifier "ModuleType"
:: "::"
identifier "Raw"
=> "=>"
macro_invocation
identifier "write"
! "!"
token_tree
( "("
identifier "f"
, ","
string_literal
" "\""
string_content "Raw"
" "\""
) ")"
, ","
match_arm
match_pattern
scoped_identifier
identifier "ModuleType"
:: "::"
identifier "NodeAddon"
=> "=>"
macro_invocation
identifier "write"
! "!"
token_tree
( "("
identifier "f"
, ","
string_literal
" "\""
string_content "NodeAddon"
" "\""
) ")"
, ","
match_arm
match_pattern
scoped_identifier
identifier "ModuleType"
:: "::"
identifier "CssModule"
=> "=>"
macro_invocation
identifier "write"
! "!"
token_tree
( "("
identifier "f"
, ","
string_literal
" "\""
string_content "CssModule"
" "\""
) ")"
, ","
match_arm (+25 nodes collapsed)
match_arm (+25 nodes collapsed)
match_arm (+25 nodes collapsed)
match_arm
match_pattern
scoped_identifier
identifier "ModuleType"
:: "::"
identifier "InlinedBytesJs"
=> "=>"
macro_invocation
identifier "write"
! "!"
token_tree
( "("
identifier "f"
, ","
string_literal
" "\""
string_content "InlinedBytesJs"
" "\""
) ")"
, ","
match_arm (+25 nodes collapsed)
match_arm (+24 nodes collapsed)
} "}"
} "}"
} "}"
impl_item
impl "impl"
type_identifier "ModuleType"
declaration_list
{ "{"
line_comment
// "//"
outer_doc_comment_marker
/ "/"
doc_comment " Creates a ModuleType from a string identifier.\n"
line_comment
// "//"
outer_doc_comment_marker
/ "/"
doc_comment " This is used for user-configured module types in turbopack "...
function_item
visibility_modifier
pub "pub"
fn "fn"
identifier "from_str_with_defaults"
parameters (+65 nodes collapsed)
-> "->"
generic_type
type_identifier "Result"
type_arguments
< "<"
type_identifier "Self"
> ">"
block
{ "{"
call_expression
identifier "Ok"
arguments
( "("
match_expression
match "match"
identifier "type_str"
match_block
{ "{"
match_arm
match_pattern
string_literal
" "\""
string_content "asset"
" "\""
=> "=>"
struct_expression
scoped_type_identifier
identifier "ModuleType"
:: "::"
type_identifier "StaticUrlJs"
field_initializer_list
{ "{"
field_initializer
field_identifier "tag"
: ":"
identifier "None"
} "}"
, ","
match_arm
match_pattern
string_literal
" "\""
string_content "ecmascript"
" "\""
=> "=>"
struct_expression
scoped_type_identifier
identifier "ModuleType"
:: "::"
type_identifier "Ecmascript"
field_initializer_list
{ "{"
shorthand_field_initializer
identifier "preprocess"
, ","
shorthand_field_initializer
identifier "main"
, ","
shorthand_field_initializer
identifier "postprocess"
, ","
shorthand_field_initializer
identifier "options"
, ","
} "}"
, ","
match_arm
match_pattern
string_literal
" "\""
string_content "typescript"
" "\""
=> "=>"
struct_expression (+32 nodes collapsed)
, ","
match_arm
match_pattern
string_literal
" "\""
string_content "css"
" "\""
=> "=>"
struct_expression
scoped_type_identifier
identifier "ModuleType"
:: "::"
type_identifier "Css"
field_initializer_list
{ "{"
field_initializer
field_identifier "ty"
: ":"
scoped_identifier
identifier "CssModuleAssetType"
:: "::"
identifier "Default"
, ","
shorthand_field_initializer
identifier "environment"
, ","
} "}"
, ","
match_arm
match_pattern
string_literal
" "\""
string_content "css-module"
" "\""
=> "=>"
scoped_identifier
identifier "ModuleType"
:: "::"
identifier "CssModule"
, ","
match_arm
match_pattern
string_literal
" "\""
string_content "wasm"
" "\""
=> "=>"
struct_expression
scoped_type_identifier
identifier "ModuleType"
:: "::"
type_identifier "WebAssembly"
field_initializer_list
{ "{"
field_initializer
field_identifier "source_ty"
: ":"
scoped_identifier
identifier "WebAssemblySourceType"
:: "::"
identifier "Binary"
, ","
} "}"
, ","
match_arm
match_pattern
string_literal
" "\""
string_content "raw"
" "\""
=> "=>"
scoped_identifier
identifier "ModuleType"
:: "::"
identifier "Raw"
, ","
match_arm
match_pattern
string_literal
" "\""
string_content "node"
" "\""
=> "=>"
scoped_identifier
identifier "ModuleType"
:: "::"
identifier "NodeAddon"
, ","
match_arm
match_pattern
string_literal
" "\""
string_content "bytes"
" "\""
=> "=>"
scoped_identifier
identifier "ModuleType"
:: "::"
identifier "InlinedBytesJs"
, ","
match_arm
match_pattern
_ "_"
=> "=>"
macro_invocation
identifier "bail"
! "!"
token_tree
( "("
string_literal
" "\""
string_content "Unknown module type: {type_str:?}. Valid types are: asset, e"...
escape_sequence "\\\n"
string_content " typescript, css, css-module, wasm, raw, nod"...
" "\""
) ")"
, ","
} "}"
) ")"
} "}"
} "}"

After

source_file
use_declaration
use "use"
scoped_identifier
scoped_identifier
identifier "std"
:: "::"
identifier "fmt"
:: "::"
identifier "Display"
; ";"
use_declaration
use "use"
scoped_use_list
identifier "anyhow"
:: "::"
use_list
{ "{"
identifier "Result"
, ","
identifier "bail"
} "}"
; ";"
use_declaration
use "use"
scoped_use_list
identifier "bincode"
:: "::"
use_list
{ "{"
identifier "Decode"
, ","
identifier "Encode"
} "}"
; ";"
use_declaration
use "use"
scoped_identifier
identifier "turbo_rcstr"
:: "::"
identifier "RcStr"
; ";"
use_declaration
use "use"
scoped_use_list
identifier "turbo_tasks"
:: "::"
use_list
{ "{"
identifier "NonLocalValue"
, ","
identifier "ResolvedVc"
, ","
scoped_identifier
identifier "trace"
:: "::"
identifier "TraceRawVcs"
} "}"
; ";"
use_declaration
use "use"
scoped_identifier
identifier "turbo_tasks_fs"
:: "::"
identifier "FileSystemPath"
; ";"
use_declaration (+29 nodes collapsed)
use_declaration
use "use"
scoped_identifier
identifier "turbopack_css"
:: "::"
identifier "CssModuleAssetType"
; ";"
use_declaration
use "use"
scoped_use_list
identifier "turbopack_ecmascript"
:: "::"
use_list
{ "{"
identifier "EcmascriptInputTransforms"
, ","
identifier "EcmascriptOptions"
, ","
scoped_identifier
identifier "bytes_source_transform"
:: "::"
identifier "BytesSourceTransform"
, ","
} "}"
; ";"
use_declaration
use "use"
scoped_identifier
scoped_identifier
identifier "turbopack_wasm"
:: "::"
identifier "source"
:: "::"
identifier "WebAssemblySourceType"
; ";"
use_declaration
use "use"
scoped_use_list
scoped_identifier
crate "crate"
:: "::"
identifier "module_options"
:: "::"
use_list
{ "{"
identifier "CustomModuleType"
, ","
identifier "RuleCondition"
, ","
scoped_identifier
identifier "match_mode"
:: "::"
identifier "MatchMode"
} "}"
; ";"
attribute_item (+24 nodes collapsed)
struct_item (+28 nodes collapsed)
impl_item (+326 nodes collapsed)
attribute_item
# "#"
[ "["
attribute
scoped_identifier
identifier "turbo_tasks"
:: "::"
identifier "value"
token_tree
( "("
identifier "shared"
) ")"
] "]"
attribute_item
# "#"
[ "["
attribute
identifier "derive"
token_tree
( "("
identifier "Debug"
, ","
identifier "Clone"
) ")"
] "]"
enum_item (+91 nodes collapsed)
attribute_item
# "#"
[ "["
attribute
scoped_identifier
identifier "turbo_tasks"
:: "::"
identifier "value"
token_tree
( "("
identifier "shared"
) ")"
] "]"
attribute_item
# "#"
[ "["
attribute
identifier "derive"
token_tree
( "("
identifier "Hash"
, ","
identifier "Debug"
, ","
identifier "Clone"
) ")"
] "]"
enum_item
visibility_modifier
pub "pub"
enum "enum"
type_identifier "ModuleType"
enum_variant_list
{ "{"
enum_variant (+70 nodes collapsed)
, ","
enum_variant (+84 nodes collapsed)
, ","
enum_variant (+70 nodes collapsed)
, ","
enum_variant (+70 nodes collapsed)
, ","
enum_variant
identifier "Json"
, ","
enum_variant
identifier "Raw"
, ","
enum_variant
identifier "NodeAddon"
, ","
enum_variant
identifier "CssModule"
, ","
enum_variant (+25 nodes collapsed)
, ","
enum_variant
identifier "StaticUrlJs"
field_declaration_list
{ "{"
line_comment
// "//"
outer_doc_comment_marker
/ "/"
doc_comment " The tag that is passed to ChunkingContext::asset_url\n"
field_declaration
field_identifier "tag"
: ":"
generic_type
type_identifier "Option"
type_arguments
< "<"
type_identifier "RcStr"
> ">"
, ","
} "}"
, ","
enum_variant
identifier "StaticUrlCss"
field_declaration_list
{ "{"
line_comment
// "//"
outer_doc_comment_marker
/ "/"
doc_comment " The tag that is passed to ChunkingContext::asset_url\n"
field_declaration
field_identifier "tag"
: ":"
generic_type
type_identifier "Option"
type_arguments
< "<"
type_identifier "RcStr"
> ">"
, ","
} "}"
, ","
enum_variant
identifier "WebAssembly"
field_declaration_list
{ "{"
field_declaration
field_identifier "source_ty"
: ":"
type_identifier "WebAssemblySourceType"
, ","
} "}"
, ","
enum_variant
identifier "Custom"
ordered_field_declaration_list
( "("
generic_type
type_identifier "ResolvedVc"
type_arguments
< "<"
generic_type
type_identifier "Box"
type_arguments
< "<"
dynamic_type
dyn "dyn"
type_identifier "CustomModuleType"
> ">"
> ">"
) ")"
, ","
} "}"
impl_item
impl "impl"
type_identifier "Display"
for "for"
type_identifier "ModuleType"
declaration_list
{ "{"
function_item
fn "fn"
identifier "fmt"
parameters (+27 nodes collapsed)
-> "->"
scoped_type_identifier
scoped_identifier
identifier "std"
:: "::"
identifier "fmt"
:: "::"
type_identifier "Result"
block
{ "{"
expression_statement
match_expression
match "match"
self "self"
match_block
{ "{"
match_arm (+25 nodes collapsed)
match_arm (+25 nodes collapsed)
match_arm (+25 nodes collapsed)
match_arm (+25 nodes collapsed)
match_arm
match_pattern
scoped_identifier
identifier "ModuleType"
:: "::"
identifier "Json"
=> "=>"
macro_invocation
identifier "write"
! "!"
token_tree
( "("
identifier "f"
, ","
string_literal
" "\""
string_content "Json"
" "\""
) ")"
, ","
match_arm
match_pattern
scoped_identifier
identifier "ModuleType"
:: "::"
identifier "Raw"
=> "=>"
macro_invocation
identifier "write"
! "!"
token_tree
( "("
identifier "f"
, ","
string_literal
" "\""
string_content "Raw"
" "\""
) ")"
, ","
match_arm
match_pattern
scoped_identifier
identifier "ModuleType"
:: "::"
identifier "NodeAddon"
=> "=>"
macro_invocation
identifier "write"
! "!"
token_tree
( "("
identifier "f"
, ","
string_literal
" "\""
string_content "NodeAddon"
" "\""
) ")"
, ","
match_arm
match_pattern
scoped_identifier
identifier "ModuleType"
:: "::"
identifier "CssModule"
=> "=>"
macro_invocation
identifier "write"
! "!"
token_tree
( "("
identifier "f"
, ","
string_literal
" "\""
string_content "CssModule"
" "\""
) ")"
, ","
match_arm (+25 nodes collapsed)
match_arm (+25 nodes collapsed)
match_arm (+25 nodes collapsed)
match_arm (+25 nodes collapsed)
match_arm (+24 nodes collapsed)
} "}"
} "}"
} "}"
line_comment
// "//"
outer_doc_comment_marker
/ "/"
doc_comment " User-facing module type names used in configuration.\n"
line_comment
// "//"
outer_doc_comment_marker
/ "/"
doc_comment "\n"
line_comment
// "//"
outer_doc_comment_marker
/ "/"
doc_comment " This enum represents the semantic module types that users c"...
line_comment
// "//"
outer_doc_comment_marker
/ "/"
doc_comment " (e.g., next.config.js turbopack rules). Some of these map d"...
line_comment
// "//"
outer_doc_comment_marker
/ "/"
doc_comment " variants, while others (like `Bytes`) are implemented via s"...
attribute_item
# "#"
[ "["
attribute
identifier "derive"
token_tree
( "("
identifier "Debug"
, ","
identifier "Clone"
, ","
identifier "PartialEq"
, ","
identifier "Eq"
) ")"
] "]"
enum_item
visibility_modifier
pub "pub"
enum "enum"
type_identifier "ConfiguredModuleType"
enum_variant_list
{ "{"
enum_variant
identifier "Asset"
, ","
enum_variant
identifier "Ecmascript"
, ","
enum_variant
identifier "Typescript"
, ","
enum_variant
identifier "Css"
, ","
enum_variant
identifier "CssModule"
, ","
enum_variant
identifier "Json"
, ","
enum_variant
identifier "Wasm"
, ","
enum_variant
identifier "Raw"
, ","
enum_variant
identifier "Node"
, ","
line_comment
// "//"
outer_doc_comment_marker
/ "/"
doc_comment " Converts any file to an ES module exporting its contents as"...
line_comment
// "//"
outer_doc_comment_marker
/ "/"
doc_comment " Implemented as a source transform, not a ModuleType.\n"
enum_variant
identifier "Bytes"
, ","
} "}"
impl_item
impl "impl"
type_identifier "ConfiguredModuleType"
declaration_list
{ "{"
line_comment
// "//"
outer_doc_comment_marker
/ "/"
doc_comment " Parse a module type string from user configuration.\n"
function_item
visibility_modifier
pub "pub"
fn "fn"
identifier "parse"
parameters
( "("
parameter
identifier "type_str"
: ":"
reference_type
& "&"
primitive_type "str"
) ")"
-> "->"
generic_type
type_identifier "Result"
type_arguments
< "<"
type_identifier "Self"
> ">"
block
{ "{"
call_expression
identifier "Ok"
arguments
( "("
match_expression
match "match"
identifier "type_str"
match_block
{ "{"
match_arm
match_pattern
string_literal
" "\""
string_content "asset"
" "\""
=> "=>"
scoped_identifier
identifier "ConfiguredModuleType"
:: "::"
identifier "Asset"
, ","
match_arm
match_pattern
string_literal
" "\""
string_content "ecmascript"
" "\""
=> "=>"
scoped_identifier
identifier "ConfiguredModuleType"
:: "::"
identifier "Ecmascript"
, ","
match_arm
match_pattern
string_literal
" "\""
string_content "typescript"
" "\""
=> "=>"
scoped_identifier
identifier "ConfiguredModuleType"
:: "::"
identifier "Typescript"
, ","
match_arm
match_pattern
string_literal
" "\""
string_content "css"
" "\""
=> "=>"
scoped_identifier
identifier "ConfiguredModuleType"
:: "::"
identifier "Css"
, ","
match_arm
match_pattern
string_literal
" "\""
string_content "css-module"
" "\""
=> "=>"
scoped_identifier
identifier "ConfiguredModuleType"
:: "::"
identifier "CssModule"
, ","
match_arm
match_pattern
string_literal
" "\""
string_content "json"
" "\""
=> "=>"
scoped_identifier
identifier "ConfiguredModuleType"
:: "::"
identifier "Json"
, ","
match_arm
match_pattern
string_literal
" "\""
string_content "wasm"
" "\""
=> "=>"
scoped_identifier
identifier "ConfiguredModuleType"
:: "::"
identifier "Wasm"
, ","
match_arm
match_pattern
string_literal
" "\""
string_content "raw"
" "\""
=> "=>"
scoped_identifier
identifier "ConfiguredModuleType"
:: "::"
identifier "Raw"
, ","
match_arm
match_pattern
string_literal
" "\""
string_content "node"
" "\""
=> "=>"
scoped_identifier
identifier "ConfiguredModuleType"
:: "::"
identifier "Node"
, ","
match_arm
match_pattern
string_literal
" "\""
string_content "bytes"
" "\""
=> "=>"
scoped_identifier
identifier "ConfiguredModuleType"
:: "::"
identifier "Bytes"
, ","
match_arm
match_pattern
_ "_"
=> "=>"
macro_invocation
identifier "bail"
! "!"
token_tree
( "("
string_literal
" "\""
string_content "Unknown module type: {type_str:?}. Valid types are: asset, e"...
escape_sequence "\\\n"
string_content " typescript, css, css-module, json, wasm, ra"...
" "\""
) ")"
, ","
} "}"
) ")"
} "}"
line_comment
// "//"
outer_doc_comment_marker
/ "/"
doc_comment " Convert this configured module type into module rule effect"...
line_comment
// "//"
outer_doc_comment_marker
/ "/"
doc_comment "\n"
line_comment
// "//"
outer_doc_comment_marker
/ "/"
doc_comment " Some module types (like `Bytes`) are implemented as source "...
line_comment
// "//"
outer_doc_comment_marker
/ "/"
doc_comment " `ModuleType` variants, allowing them to compose with the st"...
function_item
visibility_modifier
pub "pub"
function_modifiers
async "async"
fn "fn"
identifier "into_effect"
parameters (+61 nodes collapsed)
-> "->"
generic_type
type_identifier "Result"
type_arguments
< "<"
type_identifier "ModuleRuleEffect"
> ">"
block
{ "{"
call_expression
identifier "Ok"
arguments
( "("
match_expression
match "match"
self "self"
match_block
{ "{"
match_arm
match_pattern
scoped_identifier
identifier "ConfiguredModuleType"
:: "::"
identifier "Bytes"
=> "=>"
block
{ "{"
line_comment
// "//"
line_comment
// "//"
call_expression
scoped_identifier
identifier "ModuleRuleEffect"
:: "::"
identifier "SourceTransforms"
arguments
( "("
call_expression
scoped_identifier
identifier "ResolvedVc"
:: "::"
identifier "cell"
arguments
( "("
macro_invocation
identifier "vec"
! "!"
token_tree
[ "["
identifier "ResolvedVc"
:: "::"
identifier "upcast"
token_tree
( "("
identifier "BytesSourceTransform"
:: "::"
identifier "new"
token_tree
( "("
) ")"
. "."
identifier "to_resolved"
token_tree
( "("
) ")"
. "."
await "await"
? "?"
, ","
) ")"
] "]"
) ")"
) ")"
} "}"
match_arm
match_pattern
scoped_identifier
identifier "ConfiguredModuleType"
:: "::"
identifier "Asset"
=> "=>"
block
{ "{"
call_expression
scoped_identifier
identifier "ModuleRuleEffect"
:: "::"
identifier "ModuleType"
arguments
( "("
struct_expression
scoped_type_identifier
identifier "ModuleType"
:: "::"
type_identifier "StaticUrlJs"
field_initializer_list
{ "{"
field_initializer
field_identifier "tag"
: ":"
identifier "None"
} "}"
) ")"
} "}"
match_arm
match_pattern
scoped_identifier
identifier "ConfiguredModuleType"
:: "::"
identifier "Ecmascript"
=> "=>"
block
{ "{"
call_expression
scoped_identifier
identifier "ModuleRuleEffect"
:: "::"
identifier "ModuleType"
arguments
( "("
struct_expression
scoped_type_identifier
identifier "ModuleType"
:: "::"
type_identifier "Ecmascript"
field_initializer_list
{ "{"
shorthand_field_initializer
identifier "preprocess"
, ","
shorthand_field_initializer
identifier "main"
, ","
shorthand_field_initializer
identifier "postprocess"
, ","
shorthand_field_initializer
identifier "options"
, ","
} "}"
) ")"
} "}"
match_arm
match_pattern
scoped_identifier
identifier "ConfiguredModuleType"
:: "::"
identifier "Typescript"
=> "=>"
block
{ "{"
call_expression
scoped_identifier
identifier "ModuleRuleEffect"
:: "::"
identifier "ModuleType"
arguments
( "("
struct_expression (+32 nodes collapsed)
) ")"
} "}"
match_arm
match_pattern
scoped_identifier
identifier "ConfiguredModuleType"
:: "::"
identifier "Css"
=> "=>"
call_expression
scoped_identifier
identifier "ModuleRuleEffect"
:: "::"
identifier "ModuleType"
arguments
( "("
struct_expression
scoped_type_identifier
identifier "ModuleType"
:: "::"
type_identifier "Css"
field_initializer_list
{ "{"
field_initializer
field_identifier "ty"
: ":"
scoped_identifier
identifier "CssModuleAssetType"
:: "::"
identifier "Default"
, ","
shorthand_field_initializer
identifier "environment"
, ","
} "}"
) ")"
, ","
match_arm
match_pattern
scoped_identifier
identifier "ConfiguredModuleType"
:: "::"
identifier "CssModule"
=> "=>"
call_expression
scoped_identifier
identifier "ModuleRuleEffect"
:: "::"
identifier "ModuleType"
arguments
( "("
scoped_identifier
identifier "ModuleType"
:: "::"
identifier "CssModule"
) ")"
, ","
match_arm
match_pattern
scoped_identifier
identifier "ConfiguredModuleType"
:: "::"
identifier "Json"
=> "=>"
call_expression
scoped_identifier
identifier "ModuleRuleEffect"
:: "::"
identifier "ModuleType"
arguments
( "("
scoped_identifier
identifier "ModuleType"
:: "::"
identifier "Json"
) ")"
, ","
match_arm
match_pattern
scoped_identifier
identifier "ConfiguredModuleType"
:: "::"
identifier "Wasm"
=> "=>"
call_expression
scoped_identifier
identifier "ModuleRuleEffect"
:: "::"
identifier "ModuleType"
arguments
( "("
struct_expression
scoped_type_identifier
identifier "ModuleType"
:: "::"
type_identifier "WebAssembly"
field_initializer_list
{ "{"
field_initializer
field_identifier "source_ty"
: ":"
scoped_identifier
identifier "WebAssemblySourceType"
:: "::"
identifier "Binary"
, ","
} "}"
) ")"
, ","
match_arm
match_pattern
scoped_identifier
identifier "ConfiguredModuleType"
:: "::"
identifier "Raw"
=> "=>"
call_expression
scoped_identifier
identifier "ModuleRuleEffect"
:: "::"
identifier "ModuleType"
arguments
( "("
scoped_identifier
identifier "ModuleType"
:: "::"
identifier "Raw"
) ")"
, ","
match_arm
match_pattern
scoped_identifier
identifier "ConfiguredModuleType"
:: "::"
identifier "Node"
=> "=>"
call_expression
scoped_identifier
identifier "ModuleRuleEffect"
:: "::"
identifier "ModuleType"
arguments
( "("
scoped_identifier
identifier "ModuleType"
:: "::"
identifier "NodeAddon"
) ")"
, ","
} "}"
) ")"
} "}"
} "}"