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
8a2c5e01
Unverified
Commit
8a2c5e01
authored
Apr 15, 2026
by
Benjamin Woodruff
Committed by
GitHub
Apr 15, 2026
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Turbopack: Use FrozenMap for module export information (#92802)
parent
836fa63f
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
64 additions
and
70 deletions
+64
-70
Cargo.lock
Cargo.lock
+1
-0
Cargo.toml
turbopack/crates/turbopack-ecmascript/Cargo.toml
+1
-0
export.rs
.../crates/turbopack-ecmascript/src/references/esm/export.rs
+17
-14
mod.rs
turbopack/crates/turbopack-ecmascript/src/references/mod.rs
+13
-13
module.rs
turbopack/crates/turbopack-ecmascript/src/rename/module.rs
+16
-22
module.rs
...-ecmascript/src/side_effect_optimization/facade/module.rs
+10
-14
module.rs
...-ecmascript/src/side_effect_optimization/locals/module.rs
+6
-7
No files found.
Cargo.lock
View file @
8a2c5e01
...
@@ -10481,6 +10481,7 @@ dependencies = [
...
@@ -10481,6 +10481,7 @@ dependencies = [
"tracing",
"tracing",
"turbo-bincode",
"turbo-bincode",
"turbo-esregex",
"turbo-esregex",
"turbo-frozenmap",
"turbo-rcstr",
"turbo-rcstr",
"turbo-tasks",
"turbo-tasks",
"turbo-tasks-backend",
"turbo-tasks-backend",
...
...
turbopack/crates/turbopack-ecmascript/Cargo.toml
View file @
8a2c5e01
...
@@ -49,6 +49,7 @@ tokio = { workspace = true }
...
@@ -49,6 +49,7 @@ tokio = { workspace = true }
tracing
=
{
workspace
=
true
}
tracing
=
{
workspace
=
true
}
turbo-bincode
=
{
workspace
=
true
}
turbo-bincode
=
{
workspace
=
true
}
turbo-esregex
=
{
workspace
=
true
}
turbo-esregex
=
{
workspace
=
true
}
turbo-frozenmap
=
{
workspace
=
true
}
turbo-rcstr
=
{
workspace
=
true
}
turbo-rcstr
=
{
workspace
=
true
}
turbo-tasks
=
{
workspace
=
true
}
turbo-tasks
=
{
workspace
=
true
}
turbo-tasks-fs
=
{
workspace
=
true
}
turbo-tasks-fs
=
{
workspace
=
true
}
...
...
turbopack/crates/turbopack-ecmascript/src/references/esm/export.rs
View file @
8a2c5e01
...
@@ -11,6 +11,7 @@ use swc_core::{
...
@@ -11,6 +11,7 @@ use swc_core::{
},
},
quote
,
quote_expr
,
quote
,
quote_expr
,
};
};
use
turbo_frozenmap
::
FrozenMap
;
use
turbo_rcstr
::{
RcStr
,
rcstr
};
use
turbo_rcstr
::{
RcStr
,
rcstr
};
use
turbo_tasks
::{
use
turbo_tasks
::{
FxIndexMap
,
NonLocalValue
,
ResolvedVc
,
TryFlatJoinIterExt
,
Vc
,
trace
::
TraceRawVcs
,
turbofmt
,
FxIndexMap
,
NonLocalValue
,
ResolvedVc
,
TryFlatJoinIterExt
,
Vc
,
trace
::
TraceRawVcs
,
turbofmt
,
...
@@ -529,7 +530,7 @@ async fn emit_star_exports_issue(source_ident: Vc<AssetIdent>, message: RcStr) -
...
@@ -529,7 +530,7 @@ async fn emit_star_exports_issue(source_ident: Vc<AssetIdent>, message: RcStr) -
#[derive(Hash,
Debug)]
#[derive(Hash,
Debug)]
pub
struct
EsmExports
{
pub
struct
EsmExports
{
/// Explicit exports
/// Explicit exports
pub
exports
:
BTree
Map
<
RcStr
,
EsmExport
>
,
pub
exports
:
Frozen
Map
<
RcStr
,
EsmExport
>
,
/// Unexpanded `export * from ...` statements (expanded in `expand_star_exports`)
/// Unexpanded `export * from ...` statements (expanded in `expand_star_exports`)
pub
star_exports
:
Vec
<
ResolvedVc
<
Box
<
dyn
ModuleReference
>>>
,
pub
star_exports
:
Vec
<
ResolvedVc
<
Box
<
dyn
ModuleReference
>>>
,
}
}
...
@@ -541,7 +542,7 @@ pub struct EsmExports {
...
@@ -541,7 +542,7 @@ pub struct EsmExports {
#[turbo_tasks
::
value(shared)]
#[turbo_tasks
::
value(shared)]
#[derive(Hash,
Debug)]
#[derive(Hash,
Debug)]
pub
struct
ExpandedExports
{
pub
struct
ExpandedExports
{
pub
exports
:
BTree
Map
<
RcStr
,
EsmExport
>
,
pub
exports
:
Frozen
Map
<
RcStr
,
EsmExport
>
,
/// Modules we couldn't analyze all exports of.
/// Modules we couldn't analyze all exports of.
pub
dynamic_exports
:
Vec
<
ResolvedVc
<
Box
<
dyn
EcmascriptChunkPlaceable
>>>
,
pub
dynamic_exports
:
Vec
<
ResolvedVc
<
Box
<
dyn
EcmascriptChunkPlaceable
>>>
,
}
}
...
@@ -559,16 +560,16 @@ impl EsmExports {
...
@@ -559,16 +560,16 @@ impl EsmExports {
module_reference
:
Vc
<
Box
<
dyn
ModuleReference
>>
,
module_reference
:
Vc
<
Box
<
dyn
ModuleReference
>>
,
)
->
Result
<
Vc
<
EcmascriptExports
>>
{
)
->
Result
<
Vc
<
EcmascriptExports
>>
{
let
module_reference
=
module_reference
.to_resolved
()
.await
?
;
let
module_reference
=
module_reference
.to_resolved
()
.await
?
;
let
mut
exports
=
BTreeMap
::
new
();
let
mut
exports
=
Vec
::
new
();
let
default
=
rcstr!
(
"default"
);
let
default
=
rcstr!
(
"default"
);
exports
.
insert
(
exports
.
push
(
(
default
.clone
(),
default
.clone
(),
EsmExport
::
ImportedBinding
(
module_reference
,
default
,
false
),
EsmExport
::
ImportedBinding
(
module_reference
,
default
,
false
),
);
)
)
;
Ok
(
EcmascriptExports
::
EsmExports
(
Ok
(
EcmascriptExports
::
EsmExports
(
EsmExports
{
EsmExports
{
exports
,
exports
:
FrozenMap
::
from
(
exports
)
,
star_exports
:
vec!
[
module_reference
],
star_exports
:
vec!
[
module_reference
],
}
}
.resolved_cell
(),
.resolved_cell
(),
...
@@ -581,7 +582,11 @@ impl EsmExports {
...
@@ -581,7 +582,11 @@ impl EsmExports {
&
self
,
&
self
,
export_usage_info
:
Vc
<
ModuleExportUsageInfo
>
,
export_usage_info
:
Vc
<
ModuleExportUsageInfo
>
,
)
->
Result
<
Vc
<
ExpandedExports
>>
{
)
->
Result
<
Vc
<
ExpandedExports
>>
{
let
mut
exports
:
BTreeMap
<
RcStr
,
EsmExport
>
=
self
.exports
.clone
();
let
mut
exports
:
BTreeMap
<
_
,
_
>
=
self
.exports
.iter
()
.map
(|(
k
,
v
)|
(
k
.clone
(),
v
.clone
()))
.collect
();
let
mut
dynamic_exports
=
vec!
[];
let
mut
dynamic_exports
=
vec!
[];
let
export_usage_info
=
export_usage_info
.await
?
;
let
export_usage_info
=
export_usage_info
.await
?
;
...
@@ -608,12 +613,10 @@ impl EsmExports {
...
@@ -608,12 +613,10 @@ impl EsmExports {
continue
;
continue
;
}
}
if
!
exports
.contains_key
(
export
)
{
// the spec indicates first-one-wins: https://tc39.es/ecma262/#_ref_9060
exports
.insert
(
exports
export
.clone
(),
.entry
(
export
.clone
())
EsmExport
::
ImportedBinding
(
esm_ref
,
export
.clone
(),
false
),
.or_insert_with
(||
EsmExport
::
ImportedBinding
(
esm_ref
,
export
.clone
(),
false
));
);
}
}
}
if
!
export_info
.dynamic_exporting_modules
.is_empty
()
{
if
!
export_info
.dynamic_exporting_modules
.is_empty
()
{
...
@@ -622,7 +625,7 @@ impl EsmExports {
...
@@ -622,7 +625,7 @@ impl EsmExports {
}
}
Ok
(
ExpandedExports
{
Ok
(
ExpandedExports
{
exports
,
exports
:
FrozenMap
::
from
(
exports
)
,
dynamic_exports
,
dynamic_exports
,
}
}
.cell
())
.cell
())
...
...
turbopack/crates/turbopack-ecmascript/src/references/mod.rs
View file @
8a2c5e01
...
@@ -22,7 +22,6 @@ pub mod util;
...
@@ -22,7 +22,6 @@ pub mod util;
pub
mod
worker
;
pub
mod
worker
;
use
std
::{
use
std
::{
collections
::
BTreeMap
,
future
::
Future
,
future
::
Future
,
mem
::
take
,
mem
::
take
,
ops
::
Deref
,
ops
::
Deref
,
...
@@ -62,6 +61,7 @@ use swc_core::{
...
@@ -62,6 +61,7 @@ use swc_core::{
};
};
use
tokio
::
sync
::
OnceCell
;
use
tokio
::
sync
::
OnceCell
;
use
tracing
::
Instrument
;
use
tracing
::
Instrument
;
use
turbo_frozenmap
::
FrozenMap
;
use
turbo_rcstr
::{
RcStr
,
rcstr
};
use
turbo_rcstr
::{
RcStr
,
rcstr
};
use
turbo_tasks
::{
use
turbo_tasks
::{
FxIndexMap
,
FxIndexSet
,
NonLocalValue
,
PrettyPrintError
,
ReadRef
,
ResolvedVc
,
TaskInput
,
FxIndexMap
,
FxIndexSet
,
NonLocalValue
,
PrettyPrintError
,
ReadRef
,
ResolvedVc
,
TaskInput
,
...
@@ -907,21 +907,21 @@ async fn analyze_ecmascript_module_internal(
...
@@ -907,21 +907,21 @@ async fn analyze_ecmascript_module_internal(
analysis
.add_esm_reexport_reference
(
i
);
analysis
.add_esm_reexport_reference
(
i
);
}
}
Reexport
::
Namespace
{
exported
:
n
}
=>
{
Reexport
::
Namespace
{
exported
:
n
}
=>
{
esm_exports
.
insert
(
esm_exports
.
push
(
(
n
.as_str
()
.into
(),
n
.as_str
()
.into
(),
EsmExport
::
ImportedNamespace
(
ResolvedVc
::
upcast
(
reference
)),
EsmExport
::
ImportedNamespace
(
ResolvedVc
::
upcast
(
reference
)),
);
)
)
;
analysis
.add_esm_reexport_reference
(
i
);
analysis
.add_esm_reexport_reference
(
i
);
}
}
Reexport
::
Named
{
imported
,
exported
}
=>
{
Reexport
::
Named
{
imported
,
exported
}
=>
{
esm_exports
.
insert
(
esm_exports
.
push
(
(
exported
.as_str
()
.into
(),
exported
.as_str
()
.into
(),
EsmExport
::
ImportedBinding
(
EsmExport
::
ImportedBinding
(
ResolvedVc
::
upcast
(
reference
),
ResolvedVc
::
upcast
(
reference
),
imported
.to_string
()
.into
(),
imported
.to_string
()
.into
(),
false
,
false
,
),
),
);
)
)
;
analysis
.add_esm_reexport_reference
(
i
);
analysis
.add_esm_reexport_reference
(
i
);
}
}
}
}
...
@@ -939,7 +939,7 @@ async fn analyze_ecmascript_module_internal(
...
@@ -939,7 +939,7 @@ async fn analyze_ecmascript_module_internal(
}
}
let
esm_exports
=
EsmExports
{
let
esm_exports
=
EsmExports
{
exports
:
esm_exports
,
exports
:
FrozenMap
::
from
(
esm_exports
)
,
star_exports
:
esm_star_exports
,
star_exports
:
esm_star_exports
,
}
}
.cell
();
.cell
();
...
@@ -4003,7 +4003,7 @@ struct ModuleReferencesVisitor<'a> {
...
@@ -4003,7 +4003,7 @@ struct ModuleReferencesVisitor<'a> {
old_analyzer
:
StaticAnalyser
,
old_analyzer
:
StaticAnalyser
,
import_references
:
&
'a
[
ResolvedVc
<
EsmAssetReference
>
],
import_references
:
&
'a
[
ResolvedVc
<
EsmAssetReference
>
],
analysis
:
&
'a
mut
AnalyzeEcmascriptModuleResultBuilder
,
analysis
:
&
'a
mut
AnalyzeEcmascriptModuleResultBuilder
,
esm_exports
:
BTreeMap
<
RcStr
,
EsmExport
>
,
esm_exports
:
Vec
<
(
RcStr
,
EsmExport
)
>
,
webpack_runtime
:
Option
<
(
RcStr
,
Span
)
>
,
webpack_runtime
:
Option
<
(
RcStr
,
Span
)
>
,
webpack_entry
:
bool
,
webpack_entry
:
bool
,
webpack_chunks
:
Vec
<
Lit
>
,
webpack_chunks
:
Vec
<
Lit
>
,
...
@@ -4026,7 +4026,7 @@ impl<'a> ModuleReferencesVisitor<'a> {
...
@@ -4026,7 +4026,7 @@ impl<'a> ModuleReferencesVisitor<'a> {
old_analyzer
:
StaticAnalyser
::
default
(),
old_analyzer
:
StaticAnalyser
::
default
(),
import_references
,
import_references
,
analysis
,
analysis
,
esm_exports
:
BTreeMap
::
new
(),
esm_exports
:
Vec
::
new
(),
webpack_runtime
:
None
,
webpack_runtime
:
None
,
webpack_entry
:
false
,
webpack_entry
:
false
,
webpack_chunks
:
Vec
::
new
(),
webpack_chunks
:
Vec
::
new
(),
...
@@ -4186,7 +4186,7 @@ impl VisitAstPath for ModuleReferencesVisitor<'_> {
...
@@ -4186,7 +4186,7 @@ impl VisitAstPath for ModuleReferencesVisitor<'_> {
)
)
}
}
};
};
self
.esm_exports
.
insert
(
key
,
export
);
self
.esm_exports
.
push
((
key
,
export
)
);
}
}
}
}
}
}
...
@@ -4212,7 +4212,7 @@ impl VisitAstPath for ModuleReferencesVisitor<'_> {
...
@@ -4212,7 +4212,7 @@ impl VisitAstPath for ModuleReferencesVisitor<'_> {
let
liveness
=
self
.get_export_ident_liveness
((
id
.clone
(),
ctx
));
let
liveness
=
self
.get_export_ident_liveness
((
id
.clone
(),
ctx
));
let
name
:
RcStr
=
id
.as_str
()
.into
();
let
name
:
RcStr
=
id
.as_str
()
.into
();
self
.esm_exports
self
.esm_exports
.
insert
(
name
.clone
(),
EsmExport
::
LocalBinding
(
name
,
liveness
));
.
push
((
name
.clone
(),
EsmExport
::
LocalBinding
(
name
,
liveness
)
));
};
};
match
decl
{
match
decl
{
Decl
::
Class
(
ClassDecl
{
ident
,
..
})
|
Decl
::
Fn
(
FnDecl
{
ident
,
..
})
=>
{
Decl
::
Class
(
ClassDecl
{
ident
,
..
})
|
Decl
::
Fn
(
FnDecl
{
ident
,
..
})
=>
{
...
@@ -4252,14 +4252,14 @@ impl VisitAstPath for ModuleReferencesVisitor<'_> {
...
@@ -4252,14 +4252,14 @@ impl VisitAstPath for ModuleReferencesVisitor<'_> {
export
:
&
'ast
ExportDefaultExpr
,
export
:
&
'ast
ExportDefaultExpr
,
ast_path
:
&
mut
AstNodePath
<
AstParentNodeRef
<
'r
>>
,
ast_path
:
&
mut
AstNodePath
<
AstParentNodeRef
<
'r
>>
,
)
{
)
{
self
.esm_exports
.
insert
(
self
.esm_exports
.
push
(
(
rcstr!
(
"default"
),
rcstr!
(
"default"
),
EsmExport
::
LocalBinding
(
EsmExport
::
LocalBinding
(
magic_identifier
::
mangle
(
"default export"
)
.into
(),
magic_identifier
::
mangle
(
"default export"
)
.into
(),
// The expression passed to `export default` cannot be mutated
// The expression passed to `export default` cannot be mutated
Liveness
::
Constant
,
Liveness
::
Constant
,
),
),
);
)
)
;
if
self
.analyze_mode
.is_code_gen
()
{
if
self
.analyze_mode
.is_code_gen
()
{
self
.analysis
.add_code_gen
(
EsmModuleItem
::
new
(
self
.analysis
.add_code_gen
(
EsmModuleItem
::
new
(
as_parent_path
(
ast_path
)
.into
(),
as_parent_path
(
ast_path
)
.into
(),
...
@@ -4287,7 +4287,7 @@ impl VisitAstPath for ModuleReferencesVisitor<'_> {
...
@@ -4287,7 +4287,7 @@ impl VisitAstPath for ModuleReferencesVisitor<'_> {
Liveness
::
Constant
,
Liveness
::
Constant
,
),
),
};
};
self
.esm_exports
.
insert
(
rcstr!
(
"default"
),
export
);
self
.esm_exports
.
push
((
rcstr!
(
"default"
),
export
)
);
}
}
DefaultDecl
::
TsInterfaceDecl
(
..
)
=>
{
DefaultDecl
::
TsInterfaceDecl
(
..
)
=>
{
// ignore
// ignore
...
...
turbopack/crates/turbopack-ecmascript/src/rename/module.rs
View file @
8a2c5e01
use
std
::
collections
::
BTreeMap
;
use
anyhow
::{
Result
,
bail
};
use
anyhow
::{
Result
,
bail
};
use
turbo_frozenmap
::
FrozenMap
;
use
turbo_tasks
::{
ResolvedVc
,
Vc
};
use
turbo_tasks
::{
ResolvedVc
,
Vc
};
use
turbo_tasks_fs
::{
File
,
FileContent
};
use
turbo_tasks_fs
::{
File
,
FileContent
};
use
turbopack_core
::{
use
turbopack_core
::{
...
@@ -208,33 +207,28 @@ impl EcmascriptChunkPlaceable for EcmascriptModuleRenameModule {
...
@@ -208,33 +207,28 @@ impl EcmascriptChunkPlaceable for EcmascriptModuleRenameModule {
#[turbo_tasks
::
function]
#[turbo_tasks
::
function]
async
fn
get_exports
(
&
self
)
->
Result
<
Vc
<
EcmascriptExports
>>
{
async
fn
get_exports
(
&
self
)
->
Result
<
Vc
<
EcmascriptExports
>>
{
let
reference
=
self
.module_reference
()
.await
?
;
let
reference
=
self
.module_reference
()
.await
?
;
let
mut
exports
=
BTreeMap
::
new
();
match
&
self
.part
{
let
export
=
match
&
self
.part
{
ModulePart
::
RenamedExport
{
ModulePart
::
RenamedExport
{
original_export
,
original_export
,
export
,
export
,
}
=>
{
}
=>
(
exports
.insert
(
export
.clone
(),
export
.clone
(),
EsmExport
::
ImportedBinding
(
EsmExport
::
ImportedBinding
(
ResolvedVc
::
upcast
(
reference
),
ResolvedVc
::
upcast
(
reference
),
original_export
.clone
(),
original_export
.clone
(),
false
,
false
,
),
),
),
);
ModulePart
::
RenamedNamespace
{
export
}
=>
(
}
export
.clone
(),
ModulePart
::
RenamedNamespace
{
export
}
=>
{
EsmExport
::
ImportedNamespace
(
ResolvedVc
::
upcast
(
reference
)),
exports
.insert
(
),
export
.clone
(),
EsmExport
::
ImportedNamespace
(
ResolvedVc
::
upcast
(
reference
)),
);
}
_
=>
bail!
(
"Unexpected ModulePart for EcmascriptModuleRenameModule"
),
_
=>
bail!
(
"Unexpected ModulePart for EcmascriptModuleRenameModule"
),
}
}
;
let
exports
=
EsmExports
{
let
exports
=
EsmExports
{
exports
,
exports
:
FrozenMap
::
from_unique_sorted_box
(
Box
::
new
([
export
]))
,
star_exports
:
Vec
::
new
(),
star_exports
:
Vec
::
new
(),
}
}
.resolved_cell
();
.resolved_cell
();
...
...
turbopack/crates/turbopack-ecmascript/src/side_effect_optimization/facade/module.rs
View file @
8a2c5e01
use
std
::
collections
::
BTreeMap
;
use
anyhow
::{
Result
,
bail
};
use
anyhow
::{
Result
,
bail
};
use
turbo_frozenmap
::
FrozenMap
;
use
turbo_tasks
::{
ResolvedVc
,
Vc
};
use
turbo_tasks
::{
ResolvedVc
,
Vc
};
use
turbopack_core
::{
use
turbopack_core
::{
chunk
::{
chunk
::{
...
@@ -189,18 +188,16 @@ impl EcmascriptAnalyzable for EcmascriptModuleFacadeModule {
...
@@ -189,18 +188,16 @@ impl EcmascriptAnalyzable for EcmascriptModuleFacadeModule {
impl
EcmascriptChunkPlaceable
for
EcmascriptModuleFacadeModule
{
impl
EcmascriptChunkPlaceable
for
EcmascriptModuleFacadeModule
{
#[turbo_tasks
::
function]
#[turbo_tasks
::
function]
async
fn
get_exports
(
&
self
)
->
Result
<
Vc
<
EcmascriptExports
>>
{
async
fn
get_exports
(
&
self
)
->
Result
<
Vc
<
EcmascriptExports
>>
{
let
mut
exports
=
BTreeMap
::
new
();
let
mut
star_exports
=
Vec
::
new
();
let
EcmascriptExports
::
EsmExports
(
esm_exports
)
=
&*
self
.module
.get_exports
()
.await
?
else
{
let
EcmascriptExports
::
EsmExports
(
esm_exports
)
=
&*
self
.module
.get_exports
()
.await
?
else
{
bail!
(
"EcmascriptModuleFacadeModule must only be used on modules with EsmExports"
);
bail!
(
"EcmascriptModuleFacadeModule must only be used on modules with EsmExports"
);
};
};
let
esm_exports
=
esm_exports
.await
?
;
let
esm_exports
=
esm_exports
.await
?
;
let
mut
exports
=
Vec
::
with_capacity
(
esm_exports
.exports
.len
());
for
(
name
,
export
)
in
&
esm_exports
.exports
{
for
(
name
,
export
)
in
&
esm_exports
.exports
{
let
name
=
name
.clone
();
let
name
=
name
.clone
();
match
export
{
match
export
{
EsmExport
::
LocalBinding
(
_
,
liveness
)
=>
{
EsmExport
::
LocalBinding
(
_
,
liveness
)
=>
{
exports
.
insert
(
exports
.
push
(
(
name
.clone
(),
name
.clone
(),
EsmExport
::
ImportedBinding
(
EsmExport
::
ImportedBinding
(
ResolvedVc
::
upcast
(
ResolvedVc
::
upcast
(
...
@@ -215,27 +212,26 @@ impl EcmascriptChunkPlaceable for EcmascriptModuleFacadeModule {
...
@@ -215,27 +212,26 @@ impl EcmascriptChunkPlaceable for EcmascriptModuleFacadeModule {
name
,
name
,
*
liveness
==
Liveness
::
Mutable
,
*
liveness
==
Liveness
::
Mutable
,
),
),
);
)
)
;
}
}
EsmExport
::
ImportedNamespace
(
reference
)
=>
{
EsmExport
::
ImportedNamespace
(
reference
)
=>
{
exports
.
insert
(
name
,
EsmExport
::
ImportedNamespace
(
*
reference
));
exports
.
push
((
name
,
EsmExport
::
ImportedNamespace
(
*
reference
)
));
}
}
EsmExport
::
ImportedBinding
(
reference
,
imported_name
,
mutable
)
=>
{
EsmExport
::
ImportedBinding
(
reference
,
imported_name
,
mutable
)
=>
{
exports
.
insert
(
exports
.
push
(
(
name
,
name
,
EsmExport
::
ImportedBinding
(
*
reference
,
imported_name
.clone
(),
*
mutable
),
EsmExport
::
ImportedBinding
(
*
reference
,
imported_name
.clone
(),
*
mutable
),
);
)
)
;
}
}
EsmExport
::
Error
=>
{
EsmExport
::
Error
=>
{
exports
.
insert
(
name
,
EsmExport
::
Error
);
exports
.
push
((
name
,
EsmExport
::
Error
)
);
}
}
}
}
}
}
star_exports
.extend
(
esm_exports
.star_exports
.iter
()
.copied
());
let
exports
=
EsmExports
{
let
exports
=
EsmExports
{
exports
,
exports
:
FrozenMap
::
from_unique_sorted_box
(
exports
.into_boxed_slice
())
,
star_exports
,
star_exports
:
esm_exports
.star_exports
.clone
()
,
}
}
.resolved_cell
();
.resolved_cell
();
Ok
(
EcmascriptExports
::
EsmExports
(
exports
)
.cell
())
Ok
(
EcmascriptExports
::
EsmExports
(
exports
)
.cell
())
...
...
turbopack/crates/turbopack-ecmascript/src/side_effect_optimization/locals/module.rs
View file @
8a2c5e01
use
std
::
collections
::
BTreeMap
;
use
anyhow
::{
Result
,
bail
};
use
anyhow
::{
Result
,
bail
};
use
turbo_frozenmap
::
FrozenMap
;
use
turbo_tasks
::{
ResolvedVc
,
Vc
};
use
turbo_tasks
::{
ResolvedVc
,
Vc
};
use
turbopack_core
::{
use
turbopack_core
::{
chunk
::{
chunk
::{
...
@@ -142,7 +141,7 @@ impl EcmascriptChunkPlaceable for EcmascriptModuleLocalsModule {
...
@@ -142,7 +141,7 @@ impl EcmascriptChunkPlaceable for EcmascriptModuleLocalsModule {
bail!
(
"EcmascriptModuleLocalsModule must only be used on modules with EsmExports"
);
bail!
(
"EcmascriptModuleLocalsModule must only be used on modules with EsmExports"
);
};
};
let
esm_exports
=
exports
.await
?
;
let
esm_exports
=
exports
.await
?
;
let
mut
exports
=
BTreeMap
::
new
();
let
mut
exports
=
Vec
::
new
();
for
(
name
,
export
)
in
&
esm_exports
.exports
{
for
(
name
,
export
)
in
&
esm_exports
.exports
{
match
export
{
match
export
{
...
@@ -150,19 +149,19 @@ impl EcmascriptChunkPlaceable for EcmascriptModuleLocalsModule {
...
@@ -150,19 +149,19 @@ impl EcmascriptChunkPlaceable for EcmascriptModuleLocalsModule {
// not included in locals module
// not included in locals module
}
}
EsmExport
::
LocalBinding
(
local_name
,
liveness
)
=>
{
EsmExport
::
LocalBinding
(
local_name
,
liveness
)
=>
{
exports
.
insert
(
exports
.
push
(
(
name
.clone
(),
name
.clone
(),
EsmExport
::
LocalBinding
(
local_name
.clone
(),
*
liveness
),
EsmExport
::
LocalBinding
(
local_name
.clone
(),
*
liveness
),
);
)
)
;
}
}
EsmExport
::
Error
=>
{
EsmExport
::
Error
=>
{
exports
.
insert
(
name
.clone
(),
EsmExport
::
Error
);
exports
.
push
((
name
.clone
(),
EsmExport
::
Error
)
);
}
}
}
}
}
}
let
exports
=
EsmExports
{
let
exports
=
EsmExports
{
exports
,
exports
:
FrozenMap
::
from_unique_sorted_box
(
exports
.into_boxed_slice
())
,
star_exports
:
vec!
[],
star_exports
:
vec!
[],
}
}
.resolved_cell
();
.resolved_cell
();
...
...
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