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
a7107d5b
Commit
a7107d5b
authored
Aug 13, 2025
by
Tobias Koppers
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Turbopack: convert EcmascriptExports to a struct to be able to add more fields
parent
a7f3836e
Hide whitespace changes
Inline
Side-by-side
Showing
21 changed files
with
156 additions
and
104 deletions
+156
-104
hmr_entry.rs
crates/next-core/src/hmr_entry.rs
+5
-2
image.rs
crates/next-core/src/next_app/metadata/image.rs
+2
-2
ecmascript_client_reference_module.rs
...pt_client_reference/ecmascript_client_reference_module.rs
+4
-2
dynamic_module.rs
crates/next-core/src/next_dynamic/dynamic_module.rs
+10
-8
server_component_module.rs
...core/src/next_server_component/server_component_module.rs
+10
-8
server_utility_module.rs
...ext-core/src/next_server_utility/server_utility_module.rs
+10
-8
module_asset.rs
turbopack/crates/turbopack-css/src/module_asset.rs
+5
-2
mod.rs
turbopack/crates/turbopack-ecmascript/src/chunk/mod.rs
+1
-1
placeable.rs
turbopack/crates/turbopack-ecmascript/src/chunk/placeable.rs
+10
-4
lib.rs
turbopack/crates/turbopack-ecmascript/src/lib.rs
+8
-6
chunk_asset.rs
...k/crates/turbopack-ecmascript/src/manifest/chunk_asset.rs
+5
-2
base.rs
...ck/crates/turbopack-ecmascript/src/references/esm/base.rs
+3
-2
export.rs
.../crates/turbopack-ecmascript/src/references/esm/export.rs
+26
-26
external_module.rs
...es/turbopack-ecmascript/src/references/external_module.rs
+9
-3
mod.rs
turbopack/crates/turbopack-ecmascript/src/references/mod.rs
+15
-15
require_context.rs
...es/turbopack-ecmascript/src/references/require_context.rs
+5
-1
module.rs
...-ecmascript/src/side_effect_optimization/facade/module.rs
+7
-3
module.rs
...-ecmascript/src/side_effect_optimization/locals/module.rs
+6
-3
lib.rs
turbopack/crates/turbopack-json/src/lib.rs
+5
-2
ecma.rs
turbopack/crates/turbopack-static/src/ecma.rs
+5
-2
raw.rs
turbopack/crates/turbopack-wasm/src/raw.rs
+5
-2
No files found.
crates/next-core/src/hmr_entry.rs
View file @
a7107d5b
...
...
@@ -19,7 +19,7 @@ use turbopack_core::{
use
turbopack_ecmascript
::{
chunk
::{
EcmascriptChunkItem
,
EcmascriptChunkItemContent
,
EcmascriptChunkItemOptions
,
EcmascriptChunkPlaceable
,
EcmascriptChunkType
,
EcmascriptExports
,
EcmascriptChunkPlaceable
,
EcmascriptChunkType
,
EcmascriptExports
,
EcmascriptExportsType
,
},
runtime_functions
::
TURBOPACK_REQUIRE
,
utils
::
StringifyJs
,
...
...
@@ -102,7 +102,10 @@ impl Asset for HmrEntryModule {
impl
EcmascriptChunkPlaceable
for
HmrEntryModule
{
#[turbo_tasks
::
function]
fn
get_exports
(
self
:
Vc
<
Self
>
)
->
Vc
<
EcmascriptExports
>
{
EcmascriptExports
::
None
.cell
()
EcmascriptExports
{
ty
:
EcmascriptExportsType
::
None
,
}
.cell
()
}
#[turbo_tasks
::
function]
...
...
crates/next-core/src/next_app/metadata/image.rs
View file @
a7107d5b
...
...
@@ -18,7 +18,7 @@ use turbopack_core::{
virtual_source
::
VirtualSource
,
};
use
turbopack_ecmascript
::{
chunk
::{
EcmascriptChunkPlaceable
,
EcmascriptExports
},
chunk
::{
EcmascriptChunkPlaceable
,
EcmascriptExports
Type
},
utils
::
StringifyJs
,
};
...
...
@@ -234,7 +234,7 @@ async fn collect_direct_exports(module: Vc<Box<dyn Module>>) -> Result<Vc<Vec<Rc
return
Ok
(
Default
::
default
());
};
if
let
EcmascriptExports
::
EsmExports
(
exports
)
=
&*
ecmascript_asset
.get_exports
()
.await
?
{
if
let
EcmascriptExports
Type
::
EsmExports
(
exports
)
=
&
ecmascript_asset
.get_exports
()
.await
?
.ty
{
let
exports
=
&*
exports
.await
?
;
return
Ok
(
Vc
::
cell
(
exports
.exports
.keys
()
.cloned
()
.collect
()));
}
...
...
crates/next-core/src/next_client_reference/ecmascript_client_reference/ecmascript_client_reference_module.rs
View file @
a7107d5b
...
...
@@ -24,7 +24,7 @@ use turbopack_core::{
use
turbopack_ecmascript
::{
chunk
::{
EcmascriptChunkItem
,
EcmascriptChunkItemContent
,
EcmascriptChunkPlaceable
,
EcmascriptChunkType
,
EcmascriptExports
,
EcmascriptChunkType
,
EcmascriptExports
,
EcmascriptExportsType
,
},
runtime_functions
::
TURBOPACK_EXPORT_NAMESPACE
,
utils
::
StringifyJs
,
...
...
@@ -74,7 +74,9 @@ impl EcmascriptClientReferenceModule {
let
server_module_path
=
&*
self
.server_ident
.to_string
()
.await
?
;
// Adapted from https://github.com/facebook/react/blob/c5b9375767e2c4102d7e5559d383523736f1c902/packages/react-server-dom-webpack/src/ReactFlightWebpackNodeLoader.js#L323-L354
if
let
EcmascriptExports
::
EsmExports
(
exports
)
=
&*
self
.client_module
.get_exports
()
.await
?
{
if
let
EcmascriptExportsType
::
EsmExports
(
exports
)
=
&
self
.client_module
.get_exports
()
.await
?
.ty
{
is_esm
=
true
;
let
exports
=
exports
.expand_exports
(
ModuleExportUsageInfo
::
all
())
.await
?
;
...
...
crates/next-core/src/next_dynamic/dynamic_module.rs
View file @
a7107d5b
...
...
@@ -16,7 +16,7 @@ use turbopack_core::{
use
turbopack_ecmascript
::{
chunk
::{
EcmascriptChunkItem
,
EcmascriptChunkItemContent
,
EcmascriptChunkPlaceable
,
EcmascriptChunkType
,
EcmascriptExports
,
EcmascriptChunkType
,
EcmascriptExports
,
EcmascriptExportsType
,
},
references
::
esm
::{
EsmExport
,
EsmExports
},
runtime_functions
::{
TURBOPACK_EXPORT_NAMESPACE
,
TURBOPACK_IMPORT
},
...
...
@@ -113,13 +113,15 @@ impl EcmascriptChunkPlaceable for NextDynamicEntryModule {
EsmExport
::
ImportedBinding
(
module_reference
,
default
,
false
),
);
Ok
(
EcmascriptExports
::
EsmExports
(
EsmExports
{
exports
,
star_exports
:
vec!
[
module_reference
],
}
.resolved_cell
(),
)
Ok
(
EcmascriptExports
{
ty
:
EcmascriptExportsType
::
EsmExports
(
EsmExports
{
exports
,
star_exports
:
vec!
[
module_reference
],
}
.resolved_cell
(),
),
}
.cell
())
}
}
...
...
crates/next-core/src/next_server_component/server_component_module.rs
View file @
a7107d5b
...
...
@@ -16,7 +16,7 @@ use turbopack_core::{
use
turbopack_ecmascript
::{
chunk
::{
EcmascriptChunkItem
,
EcmascriptChunkItemContent
,
EcmascriptChunkPlaceable
,
EcmascriptChunkType
,
EcmascriptExports
,
EcmascriptChunkType
,
EcmascriptExports
,
EcmascriptExportsType
,
},
references
::
esm
::{
EsmExport
,
EsmExports
},
runtime_functions
::{
TURBOPACK_EXPORT_NAMESPACE
,
TURBOPACK_IMPORT
},
...
...
@@ -106,13 +106,15 @@ impl EcmascriptChunkPlaceable for NextServerComponentModule {
EsmExport
::
ImportedBinding
(
module_reference
,
default
,
false
),
);
Ok
(
EcmascriptExports
::
EsmExports
(
EsmExports
{
exports
,
star_exports
:
vec!
[
module_reference
],
}
.resolved_cell
(),
)
Ok
(
EcmascriptExports
{
ty
:
EcmascriptExportsType
::
EsmExports
(
EsmExports
{
exports
,
star_exports
:
vec!
[
module_reference
],
}
.resolved_cell
(),
),
}
.cell
())
}
}
...
...
crates/next-core/src/next_server_utility/server_utility_module.rs
View file @
a7107d5b
...
...
@@ -16,7 +16,7 @@ use turbopack_core::{
use
turbopack_ecmascript
::{
chunk
::{
EcmascriptChunkItem
,
EcmascriptChunkItemContent
,
EcmascriptChunkPlaceable
,
EcmascriptChunkType
,
EcmascriptExports
,
EcmascriptChunkType
,
EcmascriptExports
,
EcmascriptExportsType
,
},
references
::
esm
::{
EsmExport
,
EsmExports
},
runtime_functions
::{
TURBOPACK_EXPORT_NAMESPACE
,
TURBOPACK_IMPORT
},
...
...
@@ -106,13 +106,15 @@ impl EcmascriptChunkPlaceable for NextServerUtilityModule {
EsmExport
::
ImportedBinding
(
module_reference
,
default
,
false
),
);
Ok
(
EcmascriptExports
::
EsmExports
(
EsmExports
{
exports
,
star_exports
:
vec!
[
module_reference
],
}
.resolved_cell
(),
)
Ok
(
EcmascriptExports
{
ty
:
EcmascriptExportsType
::
EsmExports
(
EsmExports
{
exports
,
star_exports
:
vec!
[
module_reference
],
}
.resolved_cell
(),
),
}
.cell
())
}
}
...
...
turbopack/crates/turbopack-css/src/module_asset.rs
View file @
a7107d5b
...
...
@@ -26,7 +26,7 @@ use turbopack_core::{
use
turbopack_ecmascript
::{
chunk
::{
EcmascriptChunkItem
,
EcmascriptChunkItemContent
,
EcmascriptChunkPlaceable
,
EcmascriptChunkType
,
EcmascriptExports
,
EcmascriptChunkType
,
EcmascriptExports
,
EcmascriptExportsType
,
},
parse
::
generate_js_source_map
,
runtime_functions
::{
TURBOPACK_EXPORT_VALUE
,
TURBOPACK_IMPORT
},
...
...
@@ -263,7 +263,10 @@ impl ChunkableModule for ModuleCssAsset {
impl
EcmascriptChunkPlaceable
for
ModuleCssAsset
{
#[turbo_tasks
::
function]
fn
get_exports
(
&
self
)
->
Vc
<
EcmascriptExports
>
{
EcmascriptExports
::
Value
.cell
()
EcmascriptExports
{
ty
:
EcmascriptExportsType
::
Value
,
}
.cell
()
}
}
...
...
turbopack/crates/turbopack-ecmascript/src/chunk/mod.rs
View file @
a7107d5b
...
...
@@ -36,7 +36,7 @@ pub use self::{
EcmascriptChunkItem
,
EcmascriptChunkItemContent
,
EcmascriptChunkItemExt
,
EcmascriptChunkItemOptions
,
EcmascriptChunkItemWithAsyncInfo
,
},
placeable
::{
EcmascriptChunkPlaceable
,
EcmascriptExports
},
placeable
::{
EcmascriptChunkPlaceable
,
EcmascriptExports
,
EcmascriptExportsType
},
};
#[turbo_tasks
::
value]
...
...
turbopack/crates/turbopack-ecmascript/src/chunk/placeable.rs
View file @
a7107d5b
use
anyhow
::
Result
;
use
serde
::{
Deserialize
,
Serialize
};
use
turbo_rcstr
::
rcstr
;
use
turbo_tasks
::{
ResolvedVc
,
TryFlatJoinIterExt
,
Vc
};
use
turbo_tasks
::{
NonLocalValue
,
ResolvedVc
,
TryFlatJoinIterExt
,
Vc
,
trace
::
TraceRawVcs
};
use
turbo_tasks_fs
::{
FileJsonContent
,
FileSystemPath
,
glob
::{
Glob
,
GlobOptions
},
...
...
@@ -217,7 +218,12 @@ pub async fn is_marked_as_side_effect_free(
}
#[turbo_tasks
::
value(shared)]
pub
enum
EcmascriptExports
{
pub
struct
EcmascriptExports
{
pub
ty
:
EcmascriptExportsType
,
}
#[derive(Debug,
Clone,
Eq,
PartialEq,
Serialize,
Deserialize,
TraceRawVcs,
NonLocalValue)]
pub
enum
EcmascriptExportsType
{
/// A module using ESM exports.
EsmExports
(
ResolvedVc
<
EsmExports
>
),
/// A module using `__turbopack_export_namespace__`, used by custom module types.
...
...
@@ -238,8 +244,8 @@ pub enum EcmascriptExports {
impl
EcmascriptExports
{
#[turbo_tasks
::
function]
pub
async
fn
split_locals_and_reexports
(
&
self
)
->
Result
<
Vc
<
bool
>>
{
Ok
(
match
self
{
EcmascriptExports
::
EsmExports
(
exports
)
=>
{
Ok
(
match
self
.ty
{
EcmascriptExports
Type
::
EsmExports
(
exports
)
=>
{
let
exports
=
exports
.await
?
;
let
has_reexports
=
!
exports
.star_exports
.is_empty
()
||
exports
.exports
.iter
()
.any
(|(
_
,
export
)|
{
...
...
turbopack/crates/turbopack-ecmascript/src/lib.rs
View file @
a7107d5b
...
...
@@ -112,7 +112,9 @@ use turbopack_core::{
// TODO remove this
pub
use
turbopack_resolve
::
ecmascript
as
resolve
;
use
self
::
chunk
::{
EcmascriptChunkItemContent
,
EcmascriptChunkType
,
EcmascriptExports
};
use
self
::
chunk
::{
EcmascriptChunkItemContent
,
EcmascriptChunkType
,
EcmascriptExports
,
EcmascriptExportsType
,
};
use
crate
::{
analyzer
::
graph
::
EvalContext
,
chunk
::{
EcmascriptChunkPlaceable
,
placeable
::
is_marked_as_side_effect_free
},
...
...
@@ -749,8 +751,8 @@ impl MergeableModule for EcmascriptModuleAsset {
#[turbo_tasks
::
function]
async
fn
is_mergeable
(
self
:
ResolvedVc
<
Self
>
)
->
Result
<
Vc
<
bool
>>
{
if
matches!
(
&*
self
.get_exports
()
.await
?
,
EcmascriptExports
::
EsmExports
(
_
)
self
.get_exports
()
.await
?
.ty
,
EcmascriptExports
Type
::
EsmExports
(
_
)
)
{
return
Ok
(
Vc
::
cell
(
true
));
}
...
...
@@ -936,7 +938,7 @@ impl EcmascriptModuleContentOptions {
}
else
{
None
},
if
let
EcmascriptExports
::
EsmExports
(
exports
)
=
*
exports
.await
?
{
if
let
EcmascriptExports
Type
::
EsmExports
(
exports
)
=
exports
.await
?
.ty
{
Some
(
exports
.code_generation
(
...
...
@@ -1719,8 +1721,8 @@ async fn process_parse_result(
)
.into_inner
();
let
preserved_exports
=
match
&
*
scope_hoisting_options
.module
.get_exports
()
.await
?
{
EcmascriptExports
::
EsmExports
(
exports
)
=>
exports
match
&
scope_hoisting_options
.module
.get_exports
()
.await
?
.ty
{
EcmascriptExports
Type
::
EsmExports
(
exports
)
=>
exports
.await
?
.exports
.iter
()
...
...
turbopack/crates/turbopack-ecmascript/src/manifest/chunk_asset.rs
View file @
a7107d5b
...
...
@@ -16,7 +16,7 @@ use turbopack_core::{
};
use
super
::
chunk_item
::
ManifestChunkItem
;
use
crate
::
chunk
::{
EcmascriptChunkPlaceable
,
EcmascriptExports
};
use
crate
::
chunk
::{
EcmascriptChunkPlaceable
,
EcmascriptExports
,
EcmascriptExportsType
};
/// The manifest module is deferred until requested by the manifest loader
/// item when the dynamic `import()` expression is reached.
...
...
@@ -172,6 +172,9 @@ impl ChunkableModule for ManifestAsyncModule {
impl
EcmascriptChunkPlaceable
for
ManifestAsyncModule
{
#[turbo_tasks
::
function]
fn
get_exports
(
&
self
)
->
Vc
<
EcmascriptExports
>
{
EcmascriptExports
::
Value
.cell
()
EcmascriptExports
{
ty
:
EcmascriptExportsType
::
Value
,
}
.cell
()
}
}
turbopack/crates/turbopack-ecmascript/src/references/esm/base.rs
View file @
a7107d5b
...
...
@@ -39,7 +39,7 @@ use super::export::{all_known_export_names, is_export_missing};
use
crate
::{
ScopeHoistingContext
,
TreeShakingMode
,
analyzer
::
imports
::
ImportAnnotations
,
chunk
::{
EcmascriptChunkPlaceable
,
EcmascriptExports
},
chunk
::{
EcmascriptChunkPlaceable
,
EcmascriptExports
Type
},
code_gen
::{
CodeGeneration
,
CodeGenerationHoistedStmt
},
export
::
Liveness
,
magic_identifier
,
...
...
@@ -170,7 +170,8 @@ impl ReferencedAsset {
ReferencedAsset
::
Some
(
asset
)
=>
{
if
let
Some
(
ctxt
)
=
scope_hoisting_context
.get_module_syntax_context
(
*
asset
)
&&
let
Some
(
export
)
=
&
export
&&
let
EcmascriptExports
::
EsmExports
(
exports
)
=
*
asset
.get_exports
()
.await
?
&&
let
EcmascriptExportsType
::
EsmExports
(
exports
)
=
asset
.get_exports
()
.await
?
.ty
{
let
exports
=
exports
.expand_exports
(
ModuleExportUsageInfo
::
all
())
.await
?
;
let
esm_export
=
exports
.exports
.get
(
export
);
...
...
turbopack/crates/turbopack-ecmascript/src/references/esm/export.rs
View file @
a7107d5b
...
...
@@ -31,7 +31,7 @@ use super::base::ReferencedAsset;
use
crate
::{
EcmascriptModuleAsset
,
ScopeHoistingContext
,
analyzer
::
graph
::
EvalContext
,
chunk
::{
EcmascriptChunkPlaceable
,
EcmascriptExports
},
chunk
::{
EcmascriptChunkPlaceable
,
EcmascriptExports
Type
},
code_gen
::{
CodeGeneration
,
CodeGenerationHoistedStmt
},
magic_identifier
,
runtime_functions
::{
TURBOPACK_DYNAMIC
,
TURBOPACK_ESM
},
...
...
@@ -82,14 +82,14 @@ pub async fn is_export_missing(
}
let
exports
=
module
.get_exports
()
.await
?
;
let
exports
=
match
&
*
exports
{
EcmascriptExports
::
None
=>
return
Ok
(
Vc
::
cell
(
true
)),
EcmascriptExports
::
Unknown
=>
return
Ok
(
Vc
::
cell
(
false
)),
EcmascriptExports
::
Value
=>
return
Ok
(
Vc
::
cell
(
false
)),
EcmascriptExports
::
CommonJs
=>
return
Ok
(
Vc
::
cell
(
false
)),
EcmascriptExports
::
EmptyCommonJs
=>
return
Ok
(
Vc
::
cell
(
export_name
!=
"default"
)),
EcmascriptExports
::
DynamicNamespace
=>
return
Ok
(
Vc
::
cell
(
false
)),
EcmascriptExports
::
EsmExports
(
exports
)
=>
*
exports
,
let
exports
=
match
&
exports
.ty
{
EcmascriptExports
Type
::
None
=>
return
Ok
(
Vc
::
cell
(
true
)),
EcmascriptExports
Type
::
Unknown
=>
return
Ok
(
Vc
::
cell
(
false
)),
EcmascriptExports
Type
::
Value
=>
return
Ok
(
Vc
::
cell
(
false
)),
EcmascriptExports
Type
::
CommonJs
=>
return
Ok
(
Vc
::
cell
(
false
)),
EcmascriptExports
Type
::
EmptyCommonJs
=>
return
Ok
(
Vc
::
cell
(
export_name
!=
"default"
)),
EcmascriptExports
Type
::
DynamicNamespace
=>
return
Ok
(
Vc
::
cell
(
false
)),
EcmascriptExports
Type
::
EsmExports
(
exports
)
=>
*
exports
,
};
let
exports
=
exports
.await
?
;
...
...
@@ -111,16 +111,16 @@ pub async fn is_export_missing(
for
&
dynamic_module
in
&
all_export_names
.dynamic_exporting_modules
{
let
exports
=
dynamic_module
.get_exports
()
.await
?
;
match
&
*
exports
{
EcmascriptExports
::
Value
|
EcmascriptExports
::
CommonJs
|
EcmascriptExports
::
DynamicNamespace
|
EcmascriptExports
::
Unknown
=>
{
match
&
exports
.ty
{
EcmascriptExports
Type
::
Value
|
EcmascriptExports
Type
::
CommonJs
|
EcmascriptExports
Type
::
DynamicNamespace
|
EcmascriptExports
Type
::
Unknown
=>
{
return
Ok
(
Vc
::
cell
(
false
));
}
EcmascriptExports
::
None
|
EcmascriptExports
::
EmptyCommonJs
|
EcmascriptExports
::
EsmExports
(
_
)
=>
{}
EcmascriptExports
Type
::
None
|
EcmascriptExports
Type
::
EmptyCommonJs
|
EcmascriptExports
Type
::
EsmExports
(
_
)
=>
{}
}
}
...
...
@@ -164,7 +164,7 @@ pub async fn follow_reexports(
let
mut
export_name
=
export_name
;
loop
{
let
exports
=
module
.get_exports
()
.await
?
;
let
EcmascriptExports
::
EsmExports
(
exports
)
=
&*
exports
else
{
let
EcmascriptExports
Type
::
EsmExports
(
exports
)
=
&
exports
.ty
else
{
return
Ok
(
FollowExportsResult
::
cell
(
FollowExportsResult
{
module
,
export_name
:
Some
(
export_name
),
...
...
@@ -356,7 +356,7 @@ async fn get_all_export_names(
module
:
ResolvedVc
<
Box
<
dyn
EcmascriptChunkPlaceable
>>
,
)
->
Result
<
Vc
<
AllExportNamesResult
>>
{
let
exports
=
module
.get_exports
()
.await
?
;
let
EcmascriptExports
::
EsmExports
(
exports
)
=
&*
exports
else
{
let
EcmascriptExports
Type
::
EsmExports
(
exports
)
=
&
exports
.ty
else
{
return
Ok
(
AllExportNamesResult
{
esm_exports
:
FxIndexMap
::
default
(),
dynamic_exporting_modules
:
vec!
[
module
],
...
...
@@ -425,8 +425,8 @@ pub async fn expand_star_exports(
checked_modules
.insert
(
root_module
);
let
mut
queue
=
vec!
[(
root_reference
,
root_module
,
root_module
.get_exports
())];
while
let
Some
((
reference
,
asset
,
exports
))
=
queue
.pop
()
{
match
&
*
exports
.await
?
{
EcmascriptExports
::
EsmExports
(
exports
)
=>
{
match
&
exports
.await
?
.ty
{
EcmascriptExports
Type
::
EsmExports
(
exports
)
=>
{
let
exports
=
exports
.await
?
;
for
(
key
,
esm_export
)
in
exports
.exports
.iter
()
{
if
key
==
"default"
{
...
...
@@ -452,7 +452,7 @@ pub async fn expand_star_exports(
}
}
}
EcmascriptExports
::
None
|
EcmascriptExports
::
EmptyCommonJs
=>
{
EcmascriptExports
Type
::
None
|
EcmascriptExportsType
::
EmptyCommonJs
=>
{
emit_star_exports_issue
(
asset
.ident
(),
format!
(
...
...
@@ -466,7 +466,7 @@ pub async fn expand_star_exports(
)
.await
?
}
EcmascriptExports
::
Value
=>
{
EcmascriptExports
Type
::
Value
=>
{
emit_star_exports_issue
(
asset
.ident
(),
format!
(
...
...
@@ -479,7 +479,7 @@ pub async fn expand_star_exports(
)
.await
?
}
EcmascriptExports
::
CommonJs
=>
{
EcmascriptExports
Type
::
CommonJs
=>
{
dynamic_exporting_modules
.push
(
asset
);
emit_star_exports_issue
(
asset
.ident
(),
...
...
@@ -494,10 +494,10 @@ pub async fn expand_star_exports(
)
.await
?
;
}
EcmascriptExports
::
DynamicNamespace
=>
{
EcmascriptExports
Type
::
DynamicNamespace
=>
{
dynamic_exporting_modules
.push
(
asset
);
}
EcmascriptExports
::
Unknown
=>
{
EcmascriptExports
Type
::
Unknown
=>
{
// Propagate the Unknown export type to a certain extent.
dynamic_exporting_modules
.push
(
asset
);
}
...
...
turbopack/crates/turbopack-ecmascript/src/references/external_module.rs
View file @
a7107d5b
...
...
@@ -24,7 +24,7 @@ use crate::{
EcmascriptModuleContent
,
chunk
::{
EcmascriptChunkItem
,
EcmascriptChunkItemContent
,
EcmascriptChunkPlaceable
,
EcmascriptChunkType
,
EcmascriptExports
,
EcmascriptChunkType
,
EcmascriptExports
,
EcmascriptExportsType
,
},
references
::
async_module
::{
AsyncModule
,
OptionAsyncModule
},
runtime_functions
::{
...
...
@@ -319,9 +319,15 @@ impl EcmascriptChunkPlaceable for CachedExternalModule {
#[turbo_tasks
::
function]
fn
get_exports
(
&
self
)
->
Vc
<
EcmascriptExports
>
{
if
self
.external_type
==
CachedExternalType
::
CommonJs
{
EcmascriptExports
::
CommonJs
.cell
()
EcmascriptExports
{
ty
:
EcmascriptExportsType
::
CommonJs
,
}
.cell
()
}
else
{
EcmascriptExports
::
DynamicNamespace
.cell
()
EcmascriptExports
{
ty
:
EcmascriptExportsType
::
DynamicNamespace
,
}
.cell
()
}
}
...
...
turbopack/crates/turbopack-ecmascript/src/references/mod.rs
View file @
a7107d5b
...
...
@@ -138,7 +138,7 @@ use crate::{
parse_require_context
,
top_level_await
::
has_top_level_await
,
},
chunk
::
EcmascriptExports
,
chunk
::
{
EcmascriptExports
,
EcmascriptExportsType
}
,
code_gen
::{
CodeGen
,
CodeGens
,
IntoCodeGenReference
},
export
::
Liveness
,
magic_identifier
,
...
...
@@ -226,7 +226,7 @@ pub struct AnalyzeEcmascriptModuleResultBuilder {
esm_references_rewritten
:
FxHashMap
<
usize
,
FxIndexMap
<
RcStr
,
ResolvedVc
<
EsmAssetReference
>>>
,
code_gens
:
Vec
<
CodeGen
>
,
exports
:
EcmascriptExports
,
exports
:
EcmascriptExports
Type
,
async_module
:
ResolvedVc
<
OptionAsyncModule
>
,
successful
:
bool
,
source_map
:
Option
<
ResolvedVc
<
Box
<
dyn
GenerateSourceMap
>>>
,
...
...
@@ -244,7 +244,7 @@ impl AnalyzeEcmascriptModuleResultBuilder {
esm_references_rewritten
:
Default
::
default
(),
esm_references_free_var
:
Default
::
default
(),
code_gens
:
Default
::
default
(),
exports
:
EcmascriptExports
::
Unknown
,
exports
:
EcmascriptExports
Type
::
Unknown
,
async_module
:
ResolvedVc
::
cell
(
None
),
successful
:
false
,
source_map
:
None
,
...
...
@@ -301,7 +301,7 @@ impl AnalyzeEcmascriptModuleResultBuilder {
}
/// Sets the analysis result ES export.
pub
fn
set_exports
(
&
mut
self
,
exports
:
EcmascriptExports
)
{
pub
fn
set_exports
(
&
mut
self
,
exports
:
EcmascriptExports
Type
)
{
self
.exports
=
exports
;
}
...
...
@@ -411,7 +411,7 @@ impl AnalyzeEcmascriptModuleResultBuilder {
esm_reexport_references
.unwrap_or_default
(),
),
code_generation
:
ResolvedVc
::
cell
(
self
.code_gens
),
exports
:
self
.exports
.resolved_cell
(),
exports
:
EcmascriptExports
{
ty
:
self
.exports
}
.resolved_cell
(),
async_module
:
self
.async_module
,
has_side_effect_free_directive
:
self
.has_side_effect_free_directive
,
successful
:
self
.successful
,
...
...
@@ -812,7 +812,7 @@ pub async fn analyse_ecmascript_module_internal(
}
.cell
();
EcmascriptExports
::
EsmExports
(
esm_exports
.to_resolved
()
.await
?
)
EcmascriptExports
Type
::
EsmExports
(
esm_exports
.to_resolved
()
.await
?
)
}
else
if
specified_type
==
SpecifiedModuleType
::
EcmaScript
{
match
detect_dynamic_export
(
program
)
{
DetectedDynamicExportType
::
CommonJs
=>
{
...
...
@@ -825,7 +825,7 @@ pub async fn analyse_ecmascript_module_internal(
.resolved_cell
()
.emit
();
EcmascriptExports
::
EsmExports
(
EcmascriptExports
Type
::
EsmExports
(
EsmExports
{
exports
:
Default
::
default
(),
star_exports
:
Default
::
default
(),
...
...
@@ -833,10 +833,10 @@ pub async fn analyse_ecmascript_module_internal(
.resolved_cell
(),
)
}
DetectedDynamicExportType
::
Namespace
=>
EcmascriptExports
::
DynamicNamespace
,
DetectedDynamicExportType
::
Value
=>
EcmascriptExports
::
Value
,
DetectedDynamicExportType
::
Namespace
=>
EcmascriptExports
Type
::
DynamicNamespace
,
DetectedDynamicExportType
::
Value
=>
EcmascriptExports
Type
::
Value
,
DetectedDynamicExportType
::
UsingModuleDeclarations
|
DetectedDynamicExportType
::
None
=>
EcmascriptExports
::
EsmExports
(
|
DetectedDynamicExportType
::
None
=>
EcmascriptExports
Type
::
EsmExports
(
EsmExports
{
exports
:
Default
::
default
(),
star_exports
:
Default
::
default
(),
...
...
@@ -846,11 +846,11 @@ pub async fn analyse_ecmascript_module_internal(
}
}
else
{
match
detect_dynamic_export
(
program
)
{
DetectedDynamicExportType
::
CommonJs
=>
EcmascriptExports
::
CommonJs
,
DetectedDynamicExportType
::
Namespace
=>
EcmascriptExports
::
DynamicNamespace
,
DetectedDynamicExportType
::
Value
=>
EcmascriptExports
::
Value
,
DetectedDynamicExportType
::
CommonJs
=>
EcmascriptExports
Type
::
CommonJs
,
DetectedDynamicExportType
::
Namespace
=>
EcmascriptExports
Type
::
DynamicNamespace
,
DetectedDynamicExportType
::
Value
=>
EcmascriptExports
Type
::
Value
,
DetectedDynamicExportType
::
UsingModuleDeclarations
=>
{
EcmascriptExports
::
EsmExports
(
EcmascriptExports
Type
::
EsmExports
(
EsmExports
{
exports
:
Default
::
default
(),
star_exports
:
Default
::
default
(),
...
...
@@ -858,7 +858,7 @@ pub async fn analyse_ecmascript_module_internal(
.resolved_cell
(),
)
}
DetectedDynamicExportType
::
None
=>
EcmascriptExports
::
EmptyCommonJs
,
DetectedDynamicExportType
::
None
=>
EcmascriptExports
Type
::
EmptyCommonJs
,
}
};
analysis
.set_exports
(
exports
);
...
...
turbopack/crates/turbopack-ecmascript/src/references/require_context.rs
View file @
a7107d5b
...
...
@@ -41,6 +41,7 @@ use crate::{
EcmascriptChunkPlaceable
,
chunk
::{
EcmascriptChunkItem
,
EcmascriptChunkItemContent
,
EcmascriptChunkType
,
EcmascriptExports
,
EcmascriptExportsType
,
},
code_gen
::{
CodeGen
,
CodeGeneration
,
IntoCodeGenReference
},
create_visitor
,
...
...
@@ -455,7 +456,10 @@ impl ChunkableModule for RequireContextAsset {
impl
EcmascriptChunkPlaceable
for
RequireContextAsset
{
#[turbo_tasks
::
function]
fn
get_exports
(
&
self
)
->
Vc
<
EcmascriptExports
>
{
EcmascriptExports
::
Value
.cell
()
EcmascriptExports
{
ty
:
EcmascriptExportsType
::
Value
,
}
.cell
()
}
}
...
...
turbopack/crates/turbopack-ecmascript/src/side_effect_optimization/facade/module.rs
View file @
a7107d5b
...
...
@@ -20,7 +20,7 @@ use super::chunk_item::EcmascriptModuleFacadeChunkItem;
use
crate
::{
AnalyzeEcmascriptModuleResult
,
EcmascriptAnalyzable
,
EcmascriptModuleContent
,
EcmascriptModuleContentOptions
,
EcmascriptOptions
,
MergedEcmascriptModule
,
SpecifiedModuleType
,
chunk
::{
EcmascriptChunkPlaceable
,
EcmascriptExports
},
chunk
::{
EcmascriptChunkPlaceable
,
EcmascriptExports
,
EcmascriptExportsType
},
code_gen
::
CodeGens
,
export
::
Liveness
,
references
::{
...
...
@@ -241,7 +241,8 @@ impl EcmascriptChunkPlaceable for EcmascriptModuleFacadeModule {
match
&
self
.part
{
ModulePart
::
Facade
=>
{
let
EcmascriptExports
::
EsmExports
(
esm_exports
)
=
*
self
.module
.get_exports
()
.await
?
let
EcmascriptExportsType
::
EsmExports
(
esm_exports
)
=
self
.module
.get_exports
()
.await
?
.ty
else
{
bail!
(
"EcmascriptModuleFacadeModule must only be used on modules with EsmExports"
...
...
@@ -332,7 +333,10 @@ impl EcmascriptChunkPlaceable for EcmascriptModuleFacadeModule {
star_exports
,
}
.resolved_cell
();
Ok
(
EcmascriptExports
::
EsmExports
(
exports
)
.cell
())
Ok
(
EcmascriptExports
{
ty
:
EcmascriptExportsType
::
EsmExports
(
exports
),
}
.cell
())
}
#[turbo_tasks
::
function]
...
...
turbopack/crates/turbopack-ecmascript/src/side_effect_optimization/locals/module.rs
View file @
a7107d5b
...
...
@@ -20,7 +20,7 @@ use super::chunk_item::EcmascriptModuleLocalsChunkItem;
use
crate
::{
AnalyzeEcmascriptModuleResult
,
EcmascriptAnalyzable
,
EcmascriptModuleAsset
,
EcmascriptModuleContent
,
EcmascriptModuleContentOptions
,
MergedEcmascriptModule
,
chunk
::{
EcmascriptChunkPlaceable
,
EcmascriptExports
},
chunk
::{
EcmascriptChunkPlaceable
,
EcmascriptExports
,
EcmascriptExportsType
},
references
::{
async_module
::
OptionAsyncModule
,
esm
::{
EsmExport
,
EsmExports
},
...
...
@@ -133,7 +133,7 @@ impl EcmascriptAnalyzable for EcmascriptModuleLocalsModule {
impl
EcmascriptChunkPlaceable
for
EcmascriptModuleLocalsModule
{
#[turbo_tasks
::
function]
async
fn
get_exports
(
&
self
)
->
Result
<
Vc
<
EcmascriptExports
>>
{
let
EcmascriptExports
::
EsmExports
(
exports
)
=
*
self
.module
.get_exports
()
.await
?
else
{
let
EcmascriptExports
Type
::
EsmExports
(
exports
)
=
self
.module
.get_exports
()
.await
?
.ty
else
{
bail!
(
"EcmascriptModuleLocalsModule must only be used on modules with EsmExports"
);
};
let
esm_exports
=
exports
.await
?
;
...
...
@@ -161,7 +161,10 @@ impl EcmascriptChunkPlaceable for EcmascriptModuleLocalsModule {
star_exports
:
vec!
[],
}
.resolved_cell
();
Ok
(
EcmascriptExports
::
EsmExports
(
exports
)
.cell
())
Ok
(
EcmascriptExports
{
ty
:
EcmascriptExportsType
::
EsmExports
(
exports
),
}
.cell
())
}
#[turbo_tasks
::
function]
...
...
turbopack/crates/turbopack-json/src/lib.rs
View file @
a7107d5b
...
...
@@ -26,7 +26,7 @@ use turbopack_core::{
use
turbopack_ecmascript
::{
chunk
::{
EcmascriptChunkItem
,
EcmascriptChunkItemContent
,
EcmascriptChunkPlaceable
,
EcmascriptChunkType
,
EcmascriptExports
,
EcmascriptChunkType
,
EcmascriptExports
,
EcmascriptExportsType
,
},
runtime_functions
::
TURBOPACK_EXPORT_VALUE
,
};
...
...
@@ -79,7 +79,10 @@ impl ChunkableModule for JsonModuleAsset {
impl
EcmascriptChunkPlaceable
for
JsonModuleAsset
{
#[turbo_tasks
::
function]
fn
get_exports
(
&
self
)
->
Vc
<
EcmascriptExports
>
{
EcmascriptExports
::
Value
.cell
()
EcmascriptExports
{
ty
:
EcmascriptExportsType
::
Value
,
}
.cell
()
}
#[turbo_tasks
::
function]
...
...
turbopack/crates/turbopack-static/src/ecma.rs
View file @
a7107d5b
...
...
@@ -13,7 +13,7 @@ use turbopack_core::{
use
turbopack_ecmascript
::{
chunk
::{
EcmascriptChunkItem
,
EcmascriptChunkItemContent
,
EcmascriptChunkPlaceable
,
EcmascriptChunkType
,
EcmascriptExports
,
EcmascriptChunkType
,
EcmascriptExports
,
EcmascriptExportsType
,
},
runtime_functions
::
TURBOPACK_EXPORT_VALUE
,
utils
::
StringifyJs
,
...
...
@@ -86,7 +86,10 @@ impl ChunkableModule for StaticUrlJsModule {
impl
EcmascriptChunkPlaceable
for
StaticUrlJsModule
{
#[turbo_tasks
::
function]
fn
get_exports
(
&
self
)
->
Vc
<
EcmascriptExports
>
{
EcmascriptExports
::
Value
.into
()
EcmascriptExports
{
ty
:
EcmascriptExportsType
::
Value
,
}
.cell
()
}
}
...
...
turbopack/crates/turbopack-wasm/src/raw.rs
View file @
a7107d5b
...
...
@@ -14,7 +14,7 @@ use turbopack_core::{
use
turbopack_ecmascript
::{
chunk
::{
EcmascriptChunkItem
,
EcmascriptChunkItemContent
,
EcmascriptChunkPlaceable
,
EcmascriptChunkType
,
EcmascriptExports
,
EcmascriptChunkType
,
EcmascriptExports
,
EcmascriptExportsType
,
},
runtime_functions
::
TURBOPACK_EXPORT_VALUE
,
utils
::
StringifyJs
,
...
...
@@ -92,7 +92,10 @@ impl ChunkableModule for RawWebAssemblyModuleAsset {
impl
EcmascriptChunkPlaceable
for
RawWebAssemblyModuleAsset
{
#[turbo_tasks
::
function]
fn
get_exports
(
self
:
Vc
<
Self
>
)
->
Vc
<
EcmascriptExports
>
{
EcmascriptExports
::
Value
.cell
()
EcmascriptExports
{
ty
:
EcmascriptExportsType
::
Value
,
}
.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