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
a676aa7e
Commit
a676aa7e
authored
Jan 16, 2026
by
Tobias Koppers
Committed by
Tobias Koppers
Mar 24, 2026
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Turbopack: Use operations for global information and module graph
parent
aa3ba7ed
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
18 changed files
with
352 additions
and
296 deletions
+352
-296
analyze.rs
crates/next-api/src/analyze.rs
+2
-2
app.rs
crates/next-api/src/app.rs
+17
-12
instrumentation.rs
crates/next-api/src/instrumentation.rs
+6
-4
middleware.rs
crates/next-api/src/middleware.rs
+6
-7
pages.rs
crates/next-api/src/pages.rs
+83
-70
project.rs
crates/next-api/src/project.rs
+132
-86
route.rs
crates/next-api/src/route.rs
+1
-1
routes_hashes_manifest.rs
crates/next-api/src/routes_hashes_manifest.rs
+2
-2
context.rs
crates/next-core/src/next_client/context.rs
+11
-8
context.rs
crates/next-core/src/next_edge/context.rs
+17
-11
context.rs
crates/next-core/src/next_server/context.rs
+17
-11
chunking_context.rs
turbopack/crates/turbopack-browser/src/chunking_context.rs
+13
-13
mod.rs
turbopack/crates/turbopack-cli/src/build/mod.rs
+5
-11
binding_usage_info.rs
...tes/turbopack-core/src/module_graph/binding_usage_info.rs
+5
-0
chunking_context.rs
turbopack/crates/turbopack-nodejs/src/chunking_context.rs
+13
-13
execution.rs
turbopack/crates/turbopack-tests/tests/execution.rs
+7
-14
snapshot.rs
turbopack/crates/turbopack-tests/tests/snapshot.rs
+11
-27
global_module_ids.rs
turbopack/crates/turbopack/src/global_module_ids.rs
+4
-4
No files found.
crates/next-api/src/analyze.rs
View file @
a676aa7e
...
@@ -437,8 +437,8 @@ pub async fn analyze_module_graphs(module_graphs: Vc<ModuleGraphs>) -> Result<Vc
...
@@ -437,8 +437,8 @@ pub async fn analyze_module_graphs(module_graphs: Vc<ModuleGraphs>) -> Result<Vc
let
mut
all_modules
=
FxIndexSet
::
default
();
let
mut
all_modules
=
FxIndexSet
::
default
();
let
mut
all_edges
=
FxIndexSet
::
default
();
let
mut
all_edges
=
FxIndexSet
::
default
();
let
mut
all_async_edges
=
FxIndexSet
::
default
();
let
mut
all_async_edges
=
FxIndexSet
::
default
();
for
&
module_graph
in
module_graphs
.await
?
{
for
module_graph
in
module_graphs
.await
?
.iter
()
{
let
module_graph
=
module_graph
.await
?
;
let
module_graph
=
module_graph
.
connect
()
.
await
?
;
module_graph
.traverse_edges_unordered
(|
parent
,
node
|
{
module_graph
.traverse_edges_unordered
(|
parent
,
node
|
{
if
let
Some
((
parent_node
,
reference
))
=
parent
{
if
let
Some
((
parent_node
,
reference
))
=
parent
{
all_modules
.insert
(
parent_node
);
all_modules
.insert
(
parent_node
);
...
...
crates/next-api/src/app.rs
View file @
a676aa7e
...
@@ -1008,8 +1008,8 @@ impl AppProject {
...
@@ -1008,8 +1008,8 @@ impl AppProject {
};
};
Ok
(
BaseAndFullModuleGraph
{
Ok
(
BaseAndFullModuleGraph
{
base
:
base
.connect
()
.to_resolved
()
.await
?
,
base
,
full
:
full
.connect
()
.to_resolved
()
.await
?
,
full
,
binding_usage_info
,
binding_usage_info
,
}
}
.cell
())
.cell
())
...
@@ -1287,7 +1287,7 @@ impl AppEndpoint {
...
@@ -1287,7 +1287,7 @@ impl AppEndpoint {
AssetIdent
::
from_path
(
project
.project_path
()
.owned
()
.await
?
)
AssetIdent
::
from_path
(
project
.project_path
()
.owned
()
.await
?
)
.with_modifier
(
rcstr!
(
"client-shared-chunks"
)),
.with_modifier
(
rcstr!
(
"client-shared-chunks"
)),
this
.app_project
.client_runtime_entries
(),
this
.app_project
.client_runtime_entries
(),
*
module_graphs
.full
,
module_graphs
.full
.connect
()
,
*
client_chunking_context
,
*
client_chunking_context
,
);
);
...
@@ -1305,14 +1305,14 @@ impl AppEndpoint {
...
@@ -1305,14 +1305,14 @@ impl AppEndpoint {
let
per_page_module_graph
=
*
project
.per_page_module_graph
()
.await
?
;
let
per_page_module_graph
=
*
project
.per_page_module_graph
()
.await
?
;
let
next_dynamic_imports
=
let
next_dynamic_imports
=
NextDynamicGraphs
::
new
(
*
module_graphs
.base
,
per_page_module_graph
)
NextDynamicGraphs
::
new
(
module_graphs
.base
.connect
()
,
per_page_module_graph
)
.get_next_dynamic_imports_for_endpoint
(
*
rsc_entry
)
.get_next_dynamic_imports_for_endpoint
(
*
rsc_entry
)
.await
?
;
.await
?
;
let
is_production
=
project
.next_mode
()
.await
?
.is_production
();
let
is_production
=
project
.next_mode
()
.await
?
.is_production
();
let
client_references
=
let
client_references
=
ClientReferencesGraphs
::
new
(
*
module_graphs
.base
,
per_page_module_graph
)
ClientReferencesGraphs
::
new
(
module_graphs
.base
.connect
()
,
per_page_module_graph
)
.get_client_references_for_endpoint
(
.get_client_references_for_endpoint
(
*
rsc_entry
,
*
rsc_entry
,
matches!
(
this
.ty
,
AppEndpointType
::
Page
{
..
}),
matches!
(
this
.ty
,
AppEndpointType
::
Page
{
..
}),
...
@@ -1324,7 +1324,7 @@ impl AppEndpoint {
...
@@ -1324,7 +1324,7 @@ impl AppEndpoint {
let
client_references_chunks
=
get_app_client_references_chunks
(
let
client_references_chunks
=
get_app_client_references_chunks
(
*
client_references
,
*
client_references
,
*
module_graphs
.full
,
module_graphs
.full
.connect
()
,
*
client_chunking_context
,
*
client_chunking_context
,
availability_info
,
availability_info
,
ssr_chunking_context
.map
(|
ctx
|
*
ctx
),
ssr_chunking_context
.map
(|
ctx
|
*
ctx
),
...
@@ -1432,7 +1432,7 @@ impl AppEndpoint {
...
@@ -1432,7 +1432,7 @@ impl AppEndpoint {
}
}
}
}
let
actions
=
ServerActionsGraphs
::
new
(
*
module_graphs
.base
,
per_page_module_graph
)
let
actions
=
ServerActionsGraphs
::
new
(
module_graphs
.base
.connect
()
,
per_page_module_graph
)
.get_server_actions_for_endpoint
(
.get_server_actions_for_endpoint
(
*
rsc_entry
,
*
rsc_entry
,
match
runtime
{
match
runtime
{
...
@@ -1451,7 +1451,7 @@ impl AppEndpoint {
...
@@ -1451,7 +1451,7 @@ impl AppEndpoint {
NextRuntime
::
Edge
=>
Vc
::
upcast
(
this
.app_project
.edge_rsc_module_context
()),
NextRuntime
::
Edge
=>
Vc
::
upcast
(
this
.app_project
.edge_rsc_module_context
()),
NextRuntime
::
NodeJs
=>
Vc
::
upcast
(
this
.app_project
.rsc_module_context
()),
NextRuntime
::
NodeJs
=>
Vc
::
upcast
(
this
.app_project
.rsc_module_context
()),
},
},
*
module_graphs
.full
,
module_graphs
.full
.connect
()
,
this
.app_project
this
.app_project
.project
()
.project
()
.runtime_chunking_context
(
process_client_assets
,
runtime
),
.runtime_chunking_context
(
process_client_assets
,
runtime
),
...
@@ -1469,7 +1469,7 @@ impl AppEndpoint {
...
@@ -1469,7 +1469,7 @@ impl AppEndpoint {
*
server_action_manifest_loader
,
*
server_action_manifest_loader
,
server_path
.clone
(),
server_path
.clone
(),
process_client_assets
,
process_client_assets
,
*
module_graphs
.full
,
module_graphs
.full
.connect
()
,
)
)
.to_resolved
()
.to_resolved
()
.await
?
;
.await
?
;
...
@@ -1491,7 +1491,12 @@ impl AppEndpoint {
...
@@ -1491,7 +1491,12 @@ impl AppEndpoint {
client_references_chunks
,
client_references_chunks
,
client_chunking_context
,
client_chunking_context
,
ssr_chunking_context
,
ssr_chunking_context
,
async_module_info
:
module_graphs
.full
.async_module_info
()
.to_resolved
()
.await
?
,
async_module_info
:
module_graphs
.full
.connect
()
.async_module_info
()
.to_resolved
()
.await
?
,
next_config
:
project
.next_config
()
.to_resolved
()
.await
?
,
next_config
:
project
.next_config
()
.to_resolved
()
.await
?
,
runtime
,
runtime
,
mode
:
*
project
.next_mode
()
.await
?
,
mode
:
*
project
.next_mode
()
.await
?
,
...
@@ -1574,7 +1579,7 @@ impl AppEndpoint {
...
@@ -1574,7 +1579,7 @@ impl AppEndpoint {
if
emit_manifests
==
EmitManifests
::
Full
{
if
emit_manifests
==
EmitManifests
::
Full
{
let
dynamic_import_entries
=
collect_next_dynamic_chunks
(
let
dynamic_import_entries
=
collect_next_dynamic_chunks
(
*
module_graphs
.full
,
module_graphs
.full
.connect
()
,
*
client_chunking_context
,
*
client_chunking_context
,
next_dynamic_imports
,
next_dynamic_imports
,
NextDynamicChunkAvailability
::
ClientReferences
(
NextDynamicChunkAvailability
::
ClientReferences
(
...
@@ -1698,7 +1703,7 @@ impl AppEndpoint {
...
@@ -1698,7 +1703,7 @@ impl AppEndpoint {
let
loadable_manifest_output
=
if
emit_manifests
==
EmitManifests
::
Full
{
let
loadable_manifest_output
=
if
emit_manifests
==
EmitManifests
::
Full
{
// create react-loadable-manifest for next/dynamic
// create react-loadable-manifest for next/dynamic
let
dynamic_import_entries
=
collect_next_dynamic_chunks
(
let
dynamic_import_entries
=
collect_next_dynamic_chunks
(
*
module_graphs
.full
,
module_graphs
.full
.connect
()
,
*
client_chunking_context
,
*
client_chunking_context
,
next_dynamic_imports
,
next_dynamic_imports
,
NextDynamicChunkAvailability
::
ClientReferences
(
NextDynamicChunkAvailability
::
ClientReferences
(
...
...
crates/next-api/src/instrumentation.rs
View file @
a676aa7e
...
@@ -30,7 +30,7 @@ use crate::{
...
@@ -30,7 +30,7 @@ use crate::{
paths
::{
paths
::{
all_asset_paths
,
get_js_paths_from_root
,
get_wasm_paths_from_root
,
wasm_paths_to_bindings
,
all_asset_paths
,
get_js_paths_from_root
,
get_wasm_paths_from_root
,
wasm_paths_to_bindings
,
},
},
project
::
Project
,
project
::
{
Project
,
get_module_graph_operation
}
,
route
::{
Endpoint
,
EndpointOutput
,
EndpointOutputPaths
,
ModuleGraphs
},
route
::{
Endpoint
,
EndpointOutput
,
EndpointOutputPaths
,
ModuleGraphs
},
};
};
...
@@ -247,9 +247,11 @@ impl Endpoint for InstrumentationEndpoint {
...
@@ -247,9 +247,11 @@ impl Endpoint for InstrumentationEndpoint {
#[turbo_tasks
::
function]
#[turbo_tasks
::
function]
async
fn
module_graphs
(
self
:
Vc
<
Self
>
)
->
Result
<
Vc
<
ModuleGraphs
>>
{
async
fn
module_graphs
(
self
:
Vc
<
Self
>
)
->
Result
<
Vc
<
ModuleGraphs
>>
{
let
this
=
self
.await
?
;
let
this
=
self
.await
?
;
let
module
=
self
.entry_module
();
let
module
=
self
.entry_module
()
.to_resolved
()
.await
?
;
let
module_graph
=
this
.project
.module_graph
(
module
)
.to_resolved
()
.await
?
;
Ok
(
Vc
::
cell
(
vec!
[
get_module_graph_operation
(
Ok
(
Vc
::
cell
(
vec!
[
module_graph
]))
this
.project
,
module
,
)]))
}
}
#[turbo_tasks
::
function]
#[turbo_tasks
::
function]
...
...
crates/next-api/src/middleware.rs
View file @
a676aa7e
...
@@ -33,7 +33,7 @@ use crate::{
...
@@ -33,7 +33,7 @@ use crate::{
all_asset_paths
,
all_paths_in_root
,
get_asset_paths_from_root
,
get_js_paths_from_root
,
all_asset_paths
,
all_paths_in_root
,
get_asset_paths_from_root
,
get_js_paths_from_root
,
get_wasm_paths_from_root
,
paths_to_bindings
,
wasm_paths_to_bindings
,
get_wasm_paths_from_root
,
paths_to_bindings
,
wasm_paths_to_bindings
,
},
},
project
::
Project
,
project
::
{
Project
,
get_module_graph_operation
}
,
route
::{
Endpoint
,
EndpointOutput
,
EndpointOutputPaths
,
ModuleGraphs
},
route
::{
Endpoint
,
EndpointOutput
,
EndpointOutputPaths
,
ModuleGraphs
},
};
};
...
@@ -394,12 +394,11 @@ impl Endpoint for MiddlewareEndpoint {
...
@@ -394,12 +394,11 @@ impl Endpoint for MiddlewareEndpoint {
#[turbo_tasks
::
function]
#[turbo_tasks
::
function]
async
fn
module_graphs
(
self
:
Vc
<
Self
>
)
->
Result
<
Vc
<
ModuleGraphs
>>
{
async
fn
module_graphs
(
self
:
Vc
<
Self
>
)
->
Result
<
Vc
<
ModuleGraphs
>>
{
let
this
=
self
.await
?
;
let
this
=
self
.await
?
;
let
module_graph
=
this
let
module
=
self
.entry_module
()
.to_resolved
()
.await
?
;
.project
Ok
(
Vc
::
cell
(
vec!
[
get_module_graph_operation
(
.module_graph
(
self
.entry_module
())
this
.project
,
.to_resolved
()
module
,
.await
?
;
)]))
Ok
(
Vc
::
cell
(
vec!
[
module_graph
]))
}
}
#[turbo_tasks
::
function]
#[turbo_tasks
::
function]
...
...
crates/next-api/src/pages.rs
View file @
a676aa7e
...
@@ -78,7 +78,7 @@ use crate::{
...
@@ -78,7 +78,7 @@ use crate::{
all_asset_paths
,
all_paths_in_root
,
get_asset_paths_from_root
,
get_js_paths_from_root
,
all_asset_paths
,
all_paths_in_root
,
get_asset_paths_from_root
,
get_js_paths_from_root
,
get_wasm_paths_from_root
,
paths_to_bindings
,
wasm_paths_to_bindings
,
get_wasm_paths_from_root
,
paths_to_bindings
,
wasm_paths_to_bindings
,
},
},
project
::
Project
,
project
::
{
Project
,
get_module_graph_for_modules_operation
}
,
route
::{
Endpoint
,
EndpointOutput
,
EndpointOutputPaths
,
ModuleGraphs
,
Route
,
Routes
},
route
::{
Endpoint
,
EndpointOutput
,
EndpointOutputPaths
,
ModuleGraphs
,
Route
,
Routes
},
sri_manifest
::
get_sri_manifest_asset
,
sri_manifest
::
get_sri_manifest_asset
,
};
};
...
@@ -699,71 +699,13 @@ impl PageEndpoint {
...
@@ -699,71 +699,13 @@ impl PageEndpoint {
}
}
#[turbo_tasks
::
function]
#[turbo_tasks
::
function]
async
fn
client_module_graph
(
self
:
Vc
<
Self
>
)
->
Result
<
Vc
<
ModuleGraph
>>
{
async
fn
client_module_graph
(
self
:
ResolvedVc
<
Self
>
)
->
Result
<
Vc
<
ModuleGraph
>>
{
let
this
=
self
.await
?
;
Ok
(
get_pages_client_module_graph_operation
(
self
)
.connect
())
let
project
=
this
.pages_project
.project
();
let
evaluatable_assets
=
self
.client_evaluatable_assets
();
Ok
(
project
.module_graph_for_modules
(
evaluatable_assets
))
}
}
#[turbo_tasks
::
function]
#[turbo_tasks
::
function]
async
fn
ssr_module_graph
(
self
:
Vc
<
Self
>
)
->
Result
<
Vc
<
ModuleGraph
>>
{
async
fn
ssr_module_graph
(
self
:
ResolvedVc
<
Self
>
)
->
Result
<
Vc
<
ModuleGraph
>>
{
let
this
=
self
.await
?
;
Ok
(
get_pages_ssr_module_graph_operation
(
self
)
.connect
())
let
project
=
this
.pages_project
.project
();
if
*
project
.per_page_module_graph
()
.await
?
{
let
next_mode
=
project
.next_mode
();
let
next_mode_ref
=
next_mode
.await
?
;
let
should_trace
=
next_mode_ref
.is_production
();
let
should_read_binding_usage
=
next_mode_ref
.is_production
();
let
ssr_chunk_module
=
self
.internal_ssr_chunk_module
()
.await
?
;
// Implements layout segment optimization to compute a graph "chain" for document, app,
// page
let
mut
graphs
=
vec!
[];
let
mut
visited_modules
=
VisitedModules
::
empty
();
for
module
in
[
ssr_chunk_module
.document_module
,
ssr_chunk_module
.app_module
,
]
.into_iter
()
.flatten
()
{
let
graph
=
SingleModuleGraph
::
new_with_entries_visited_intern
(
vec!
[
ChunkGroupEntry
::
Shared
(
module
)],
visited_modules
,
should_trace
,
should_read_binding_usage
,
);
graphs
.push
(
graph
);
visited_modules
=
VisitedModules
::
concatenate
(
visited_modules
,
graph
);
}
let
graph
=
SingleModuleGraph
::
new_with_entries_visited_intern
(
vec!
[
ChunkGroupEntry
::
Entry
(
vec!
[
ssr_chunk_module
.ssr_module
])],
visited_modules
,
should_trace
,
should_read_binding_usage
,
);
graphs
.push
(
graph
);
let
remove_unused_imports
=
*
project
.next_config
()
.turbopack_remove_unused_imports
(
next_mode
)
.await
?
;
let
graph
=
if
remove_unused_imports
{
let
graph
=
ModuleGraph
::
from_graphs
(
graphs
.clone
());
let
binding_usage_info
=
compute_binding_usage_info
(
graph
,
true
);
ModuleGraph
::
from_graphs_without_unused_references
(
graphs
,
binding_usage_info
)
}
else
{
ModuleGraph
::
from_graphs
(
graphs
)
};
Ok
(
graph
.connect
())
}
else
{
Ok
(
*
project
.whole_app_module_graphs
()
.await
?
.full
)
}
}
}
#[turbo_tasks
::
function]
#[turbo_tasks
::
function]
...
@@ -1712,13 +1654,12 @@ impl Endpoint for PageEndpoint {
...
@@ -1712,13 +1654,12 @@ impl Endpoint for PageEndpoint {
#[turbo_tasks
::
function]
#[turbo_tasks
::
function]
async
fn
module_graphs
(
self
:
Vc
<
Self
>
)
->
Result
<
Vc
<
ModuleGraphs
>>
{
async
fn
module_graphs
(
self
:
Vc
<
Self
>
)
->
Result
<
Vc
<
ModuleGraphs
>>
{
let
client_module_graph
=
self
.client_module_graph
()
.to_resolved
()
.await
?
;
let
this
=
self
.to_resolved
()
.await
?
;
let
ssr_module_graph
=
self
.ssr_module_graph
()
.to_resolved
()
.await
?
;
let
client_module_graph
=
get_pages_client_module_graph_operation
(
this
);
Ok
(
Vc
::
cell
(
if
client_module_graph
!=
ssr_module_graph
{
let
ssr_module_graph
=
get_pages_ssr_module_graph_operation
(
this
);
vec!
[
client_module_graph
,
ssr_module_graph
]
// Note: We can't easily deduplicate these anymore since OperationVc
}
else
{
// doesn't implement Eq, but that's fine - they're operation references
vec!
[
ssr_module_graph
]
Ok
(
Vc
::
cell
(
vec!
[
client_module_graph
,
ssr_module_graph
]))
}))
}
}
#[turbo_tasks
::
function]
#[turbo_tasks
::
function]
...
@@ -1787,3 +1728,75 @@ pub enum SsrChunk {
...
@@ -1787,3 +1728,75 @@ pub enum SsrChunk {
regions
:
Option
<
Vec
<
RcStr
>>
,
regions
:
Option
<
Vec
<
RcStr
>>
,
},
},
}
}
#[turbo_tasks
::
function(operation)]
async
fn
get_pages_client_module_graph_operation
(
endpoint
:
ResolvedVc
<
PageEndpoint
>
,
)
->
Result
<
Vc
<
ModuleGraph
>>
{
let
this
=
endpoint
.await
?
;
let
project
=
this
.pages_project
.project
()
.to_resolved
()
.await
?
;
let
evaluatable_assets
=
endpoint
.client_evaluatable_assets
()
.to_resolved
()
.await
?
;
Ok
(
get_module_graph_for_modules_operation
(
project
,
evaluatable_assets
)
.connect
())
}
#[turbo_tasks
::
function(operation)]
async
fn
get_pages_ssr_module_graph_operation
(
endpoint
:
ResolvedVc
<
PageEndpoint
>
,
)
->
Result
<
Vc
<
ModuleGraph
>>
{
let
this
=
endpoint
.await
?
;
let
project
=
this
.pages_project
.project
();
if
*
project
.per_page_module_graph
()
.await
?
{
let
next_mode
=
project
.next_mode
();
let
next_mode_ref
=
next_mode
.await
?
;
let
should_trace
=
next_mode_ref
.is_production
();
let
should_read_binding_usage
=
next_mode_ref
.is_production
();
let
ssr_chunk_module
=
endpoint
.internal_ssr_chunk_module
()
.await
?
;
// Implements layout segment optimization to compute a graph "chain" for document, app,
// page
let
mut
graphs
=
vec!
[];
let
mut
visited_modules
=
VisitedModules
::
empty
();
for
module
in
[
ssr_chunk_module
.document_module
,
ssr_chunk_module
.app_module
,
]
.into_iter
()
.flatten
()
{
let
graph
=
SingleModuleGraph
::
new_with_entries_visited_intern
(
vec!
[
ChunkGroupEntry
::
Shared
(
module
)],
visited_modules
,
should_trace
,
should_read_binding_usage
,
);
graphs
.push
(
graph
);
visited_modules
=
VisitedModules
::
concatenate
(
visited_modules
,
graph
);
}
let
graph
=
SingleModuleGraph
::
new_with_entries_visited_intern
(
vec!
[
ChunkGroupEntry
::
Entry
(
vec!
[
ssr_chunk_module
.ssr_module
])],
visited_modules
,
should_trace
,
should_read_binding_usage
,
);
graphs
.push
(
graph
);
let
remove_unused_imports
=
*
project
.next_config
()
.turbopack_remove_unused_imports
(
next_mode
)
.await
?
;
let
graph
=
if
remove_unused_imports
{
let
graph
=
ModuleGraph
::
from_graphs
(
graphs
.clone
());
let
binding_usage_info
=
compute_binding_usage_info
(
graph
,
true
);
ModuleGraph
::
from_graphs_without_unused_references
(
graphs
,
binding_usage_info
)
}
else
{
ModuleGraph
::
from_graphs
(
graphs
)
};
Ok
(
graph
.connect
())
}
else
{
Ok
(
project
.whole_app_module_graphs
()
.await
?
.full
.connect
())
}
}
crates/next-api/src/project.rs
View file @
a676aa7e
This diff is collapsed.
Click to expand it.
crates/next-api/src/route.rs
View file @
a676aa7e
...
@@ -42,7 +42,7 @@ pub enum Route {
...
@@ -42,7 +42,7 @@ pub enum Route {
}
}
#[turbo_tasks
::
value(transparent)]
#[turbo_tasks
::
value(transparent)]
pub
struct
ModuleGraphs
(
Vec
<
Resolved
Vc
<
ModuleGraph
>>
);
pub
struct
ModuleGraphs
(
Vec
<
Operation
Vc
<
ModuleGraph
>>
);
#[turbo_tasks
::
value_trait]
#[turbo_tasks
::
value_trait]
pub
trait
Endpoint
{
pub
trait
Endpoint
{
...
...
crates/next-api/src/routes_hashes_manifest.rs
View file @
a676aa7e
...
@@ -205,8 +205,8 @@ impl Asset for RoutesHashesManifestAsset {
...
@@ -205,8 +205,8 @@ impl Asset for RoutesHashesManifestAsset {
#[turbo_tasks
::
function]
#[turbo_tasks
::
function]
async
fn
content
(
&
self
)
->
Result
<
Vc
<
AssetContent
>>
{
async
fn
content
(
&
self
)
->
Result
<
Vc
<
AssetContent
>>
{
let
module_graphs
=
self
.project
.whole_app_module_graphs
()
.await
?
;
let
module_graphs
=
self
.project
.whole_app_module_graphs
()
.await
?
;
let
base_module_graph
=
*
module_graphs
.base
;
let
base_module_graph
=
module_graphs
.base
.connect
()
;
let
full_module_graph
=
*
module_graphs
.full
;
let
full_module_graph
=
module_graphs
.full
.connect
()
;
let
mut
entrypoint_hashes
=
FxIndexMap
::
default
();
let
mut
entrypoint_hashes
=
FxIndexMap
::
default
();
...
...
crates/next-core/src/next_client/context.rs
View file @
a676aa7e
...
@@ -3,7 +3,7 @@ use std::collections::BTreeSet;
...
@@ -3,7 +3,7 @@ use std::collections::BTreeSet;
use
anyhow
::
Result
;
use
anyhow
::
Result
;
use
bincode
::{
Decode
,
Encode
};
use
bincode
::{
Decode
,
Encode
};
use
turbo_rcstr
::{
RcStr
,
rcstr
};
use
turbo_rcstr
::{
RcStr
,
rcstr
};
use
turbo_tasks
::{
ResolvedVc
,
TaskInput
,
Vc
,
trace
::
TraceRawVcs
};
use
turbo_tasks
::{
OperationVc
,
ResolvedVc
,
TaskInput
,
Vc
,
trace
::
TraceRawVcs
};
use
turbo_tasks_fs
::
FileSystemPath
;
use
turbo_tasks_fs
::
FileSystemPath
;
use
turbopack
::
module_options
::{
use
turbopack
::
module_options
::{
CssOptionsContext
,
EcmascriptOptionsContext
,
JsxTransformOptions
,
ModuleRule
,
CssOptionsContext
,
EcmascriptOptionsContext
,
JsxTransformOptions
,
ModuleRule
,
...
@@ -23,7 +23,7 @@ use turbopack_core::{
...
@@ -23,7 +23,7 @@ use turbopack_core::{
environment
::{
BrowserEnvironment
,
Environment
,
ExecutionEnvironment
},
environment
::{
BrowserEnvironment
,
Environment
,
ExecutionEnvironment
},
free_var_references
,
free_var_references
,
issue
::
IssueSeverity
,
issue
::
IssueSeverity
,
module_graph
::
binding_usage_info
::
Option
BindingUsageInfo
,
module_graph
::
binding_usage_info
::
BindingUsageInfo
,
resolve
::{
parse
::
Request
,
pattern
::
Pattern
},
resolve
::{
parse
::
Request
,
pattern
::
Pattern
},
};
};
use
turbopack_css
::
chunk
::
CssChunkType
;
use
turbopack_css
::
chunk
::
CssChunkType
;
...
@@ -434,9 +434,9 @@ pub struct ClientChunkingContextOptions {
...
@@ -434,9 +434,9 @@ pub struct ClientChunkingContextOptions {
pub
client_root_to_root_path
:
RcStr
,
pub
client_root_to_root_path
:
RcStr
,
pub
asset_prefix
:
Vc
<
RcStr
>
,
pub
asset_prefix
:
Vc
<
RcStr
>
,
pub
environment
:
Vc
<
Environment
>
,
pub
environment
:
Vc
<
Environment
>
,
pub
module_id_strategy
:
Vc
<
ModuleIdStrategy
>
,
pub
module_id_strategy
:
Operation
Vc
<
ModuleIdStrategy
>
,
pub
export_usage
:
Vc
<
OptionBindingUsageInfo
>
,
pub
export_usage
:
Option
<
OperationVc
<
BindingUsageInfo
>
>
,
pub
unused_references
:
Vc
<
UnusedReferences
>
,
pub
unused_references
:
Operation
Vc
<
UnusedReferences
>
,
pub
minify
:
Vc
<
bool
>
,
pub
minify
:
Vc
<
bool
>
,
pub
source_maps
:
Vc
<
SourceMapsType
>
,
pub
source_maps
:
Vc
<
SourceMapsType
>
,
pub
no_mangling
:
Vc
<
bool
>
,
pub
no_mangling
:
Vc
<
bool
>
,
...
@@ -495,9 +495,8 @@ pub async fn get_client_chunking_context(
...
@@ -495,9 +495,8 @@ pub async fn get_client_chunking_context(
.source_maps
(
*
source_maps
.await
?
)
.source_maps
(
*
source_maps
.await
?
)
.asset_base_path
(
Some
(
asset_prefix
))
.asset_base_path
(
Some
(
asset_prefix
))
.current_chunk_method
(
CurrentChunkMethod
::
DocumentCurrentScript
)
.current_chunk_method
(
CurrentChunkMethod
::
DocumentCurrentScript
)
.export_usage
(
*
export_usage
.await
?
)
.unused_references
(
unused_references
)
.unused_references
(
unused_references
.to_resolved
()
.await
?
)
.module_id_strategy
(
module_id_strategy
)
.module_id_strategy
(
module_id_strategy
.to_resolved
()
.await
?
)
.debug_ids
(
*
debug_ids
.await
?
)
.debug_ids
(
*
debug_ids
.await
?
)
.should_use_absolute_url_references
(
*
should_use_absolute_url_references
.await
?
)
.should_use_absolute_url_references
(
*
should_use_absolute_url_references
.await
?
)
.nested_async_availability
(
*
nested_async_chunking
.await
?
)
.nested_async_availability
(
*
nested_async_chunking
.await
?
)
...
@@ -507,6 +506,10 @@ pub async fn get_client_chunking_context(
...
@@ -507,6 +506,10 @@ pub async fn get_client_chunking_context(
static_suffix
:
css_url_suffix
.to_resolved
()
.await
?
,
static_suffix
:
css_url_suffix
.to_resolved
()
.await
?
,
});
});
if
let
Some
(
export_usage
)
=
export_usage
{
builder
=
builder
.export_usage
(
export_usage
);
}
if
next_mode
.is_development
()
{
if
next_mode
.is_development
()
{
builder
=
builder
builder
=
builder
.hot_module_replacement
()
.hot_module_replacement
()
...
...
crates/next-core/src/next_edge/context.rs
View file @
a676aa7e
use
anyhow
::
Result
;
use
anyhow
::
Result
;
use
bincode
::{
Decode
,
Encode
};
use
bincode
::{
Decode
,
Encode
};
use
turbo_rcstr
::{
RcStr
,
rcstr
};
use
turbo_rcstr
::{
RcStr
,
rcstr
};
use
turbo_tasks
::{
ResolvedVc
,
TaskInput
,
Vc
,
trace
::
TraceRawVcs
};
use
turbo_tasks
::{
OperationVc
,
ResolvedVc
,
TaskInput
,
Vc
,
trace
::
TraceRawVcs
};
use
turbo_tasks_fs
::
FileSystemPath
;
use
turbo_tasks_fs
::
FileSystemPath
;
use
turbopack_browser
::
BrowserChunkingContext
;
use
turbopack_browser
::
BrowserChunkingContext
;
use
turbopack_core
::{
use
turbopack_core
::{
...
@@ -13,7 +13,7 @@ use turbopack_core::{
...
@@ -13,7 +13,7 @@ use turbopack_core::{
environment
::{
EdgeWorkerEnvironment
,
Environment
,
ExecutionEnvironment
,
NodeJsVersion
},
environment
::{
EdgeWorkerEnvironment
,
Environment
,
ExecutionEnvironment
,
NodeJsVersion
},
free_var_references
,
free_var_references
,
issue
::
IssueSeverity
,
issue
::
IssueSeverity
,
module_graph
::
binding_usage_info
::
Option
BindingUsageInfo
,
module_graph
::
binding_usage_info
::
BindingUsageInfo
,
};
};
use
turbopack_css
::
chunk
::
CssChunkType
;
use
turbopack_css
::
chunk
::
CssChunkType
;
use
turbopack_ecmascript
::
chunk
::
EcmascriptChunkType
;
use
turbopack_ecmascript
::
chunk
::
EcmascriptChunkType
;
...
@@ -191,9 +191,9 @@ pub struct EdgeChunkingContextOptions {
...
@@ -191,9 +191,9 @@ pub struct EdgeChunkingContextOptions {
pub
node_root
:
FileSystemPath
,
pub
node_root
:
FileSystemPath
,
pub
output_root_to_root_path
:
Vc
<
RcStr
>
,
pub
output_root_to_root_path
:
Vc
<
RcStr
>
,
pub
environment
:
Vc
<
Environment
>
,
pub
environment
:
Vc
<
Environment
>
,
pub
module_id_strategy
:
Vc
<
ModuleIdStrategy
>
,
pub
module_id_strategy
:
Operation
Vc
<
ModuleIdStrategy
>
,
pub
export_usage
:
Vc
<
OptionBindingUsageInfo
>
,
pub
export_usage
:
Option
<
OperationVc
<
BindingUsageInfo
>
>
,
pub
unused_references
:
Vc
<
UnusedReferences
>
,
pub
unused_references
:
Operation
Vc
<
UnusedReferences
>
,
pub
turbo_minify
:
Vc
<
bool
>
,
pub
turbo_minify
:
Vc
<
bool
>
,
pub
turbo_source_maps
:
Vc
<
SourceMapsType
>
,
pub
turbo_source_maps
:
Vc
<
SourceMapsType
>
,
pub
no_mangling
:
Vc
<
bool
>
,
pub
no_mangling
:
Vc
<
bool
>
,
...
@@ -253,12 +253,15 @@ pub async fn get_edge_chunking_context_with_client_assets(
...
@@ -253,12 +253,15 @@ pub async fn get_edge_chunking_context_with_client_assets(
MinifyType
::
NoMinify
MinifyType
::
NoMinify
})
})
.source_maps
(
*
turbo_source_maps
.await
?
)
.source_maps
(
*
turbo_source_maps
.await
?
)
.module_id_strategy
(
module_id_strategy
.to_resolved
()
.await
?
)
.module_id_strategy
(
module_id_strategy
)
.export_usage
(
*
export_usage
.await
?
)
.unused_references
(
unused_references
)
.unused_references
(
unused_references
.to_resolved
()
.await
?
)
.nested_async_availability
(
*
nested_async_chunking
.await
?
)
.nested_async_availability
(
*
nested_async_chunking
.await
?
)
.worker_forwarded_globals
(
worker_forwarded_globals
());
.worker_forwarded_globals
(
worker_forwarded_globals
());
if
let
Some
(
export_usage
)
=
export_usage
{
builder
=
builder
.export_usage
(
export_usage
);
}
if
!
next_mode
.is_development
()
{
if
!
next_mode
.is_development
()
{
builder
=
builder
builder
=
builder
.chunking_config
(
.chunking_config
(
...
@@ -344,12 +347,15 @@ pub async fn get_edge_chunking_context(
...
@@ -344,12 +347,15 @@ pub async fn get_edge_chunking_context(
MinifyType
::
NoMinify
MinifyType
::
NoMinify
})
})
.source_maps
(
*
turbo_source_maps
.await
?
)
.source_maps
(
*
turbo_source_maps
.await
?
)
.module_id_strategy
(
module_id_strategy
.to_resolved
()
.await
?
)
.module_id_strategy
(
module_id_strategy
)
.export_usage
(
*
export_usage
.await
?
)
.unused_references
(
unused_references
)
.unused_references
(
unused_references
.to_resolved
()
.await
?
)
.nested_async_availability
(
*
nested_async_chunking
.await
?
)
.nested_async_availability
(
*
nested_async_chunking
.await
?
)
.worker_forwarded_globals
(
worker_forwarded_globals
());
.worker_forwarded_globals
(
worker_forwarded_globals
());
if
let
Some
(
export_usage
)
=
export_usage
{
builder
=
builder
.export_usage
(
export_usage
);
}
if
!
next_mode
.is_development
()
{
if
!
next_mode
.is_development
()
{
builder
=
builder
builder
=
builder
.chunking_config
(
.chunking_config
(
...
...
crates/next-core/src/next_server/context.rs
View file @
a676aa7e
...
@@ -3,7 +3,7 @@ use std::collections::BTreeSet;
...
@@ -3,7 +3,7 @@ use std::collections::BTreeSet;
use
anyhow
::{
Result
,
bail
};
use
anyhow
::{
Result
,
bail
};
use
bincode
::{
Decode
,
Encode
};
use
bincode
::{
Decode
,
Encode
};
use
turbo_rcstr
::{
RcStr
,
rcstr
};
use
turbo_rcstr
::{
RcStr
,
rcstr
};
use
turbo_tasks
::{
ResolvedVc
,
TaskInput
,
Vc
,
trace
::
TraceRawVcs
};
use
turbo_tasks
::{
OperationVc
,
ResolvedVc
,
TaskInput
,
Vc
,
trace
::
TraceRawVcs
};
use
turbo_tasks_fs
::
FileSystemPath
;
use
turbo_tasks_fs
::
FileSystemPath
;
use
turbopack
::{
use
turbopack
::{
module_options
::{
module_options
::{
...
@@ -22,7 +22,7 @@ use turbopack_core::{
...
@@ -22,7 +22,7 @@ use turbopack_core::{
compile_time_info
::{
CompileTimeDefines
,
CompileTimeInfo
,
FreeVarReferences
},
compile_time_info
::{
CompileTimeDefines
,
CompileTimeInfo
,
FreeVarReferences
},
environment
::{
Environment
,
ExecutionEnvironment
,
NodeJsEnvironment
,
NodeJsVersion
},
environment
::{
Environment
,
ExecutionEnvironment
,
NodeJsEnvironment
,
NodeJsVersion
},
issue
::
IssueSeverity
,
issue
::
IssueSeverity
,
module_graph
::
binding_usage_info
::
Option
BindingUsageInfo
,
module_graph
::
binding_usage_info
::
BindingUsageInfo
,
target
::
CompileTarget
,
target
::
CompileTarget
,
};
};
use
turbopack_css
::
chunk
::
CssChunkType
;
use
turbopack_css
::
chunk
::
CssChunkType
;
...
@@ -992,9 +992,9 @@ pub struct ServerChunkingContextOptions {
...
@@ -992,9 +992,9 @@ pub struct ServerChunkingContextOptions {
pub
node_root
:
FileSystemPath
,
pub
node_root
:
FileSystemPath
,
pub
node_root_to_root_path
:
RcStr
,
pub
node_root_to_root_path
:
RcStr
,
pub
environment
:
Vc
<
Environment
>
,
pub
environment
:
Vc
<
Environment
>
,
pub
module_id_strategy
:
Vc
<
ModuleIdStrategy
>
,
pub
module_id_strategy
:
Operation
Vc
<
ModuleIdStrategy
>
,
pub
export_usage
:
Vc
<
OptionBindingUsageInfo
>
,
pub
export_usage
:
Option
<
OperationVc
<
BindingUsageInfo
>
>
,
pub
unused_references
:
Vc
<
UnusedReferences
>
,
pub
unused_references
:
Operation
Vc
<
UnusedReferences
>
,
pub
minify
:
Vc
<
bool
>
,
pub
minify
:
Vc
<
bool
>
,
pub
source_maps
:
Vc
<
SourceMapsType
>
,
pub
source_maps
:
Vc
<
SourceMapsType
>
,
pub
no_mangling
:
Vc
<
bool
>
,
pub
no_mangling
:
Vc
<
bool
>
,
...
@@ -1067,14 +1067,17 @@ pub async fn get_server_chunking_context_with_client_assets(
...
@@ -1067,14 +1067,17 @@ pub async fn get_server_chunking_context_with_client_assets(
MinifyType
::
NoMinify
MinifyType
::
NoMinify
})
})
.source_maps
(
*
source_maps
.await
?
)
.source_maps
(
*
source_maps
.await
?
)
.module_id_strategy
(
module_id_strategy
.to_resolved
()
.await
?
)
.module_id_strategy
(
module_id_strategy
)
.export_usage
(
*
export_usage
.await
?
)
.unused_references
(
unused_references
)
.unused_references
(
unused_references
.to_resolved
()
.await
?
)
.file_tracing
(
next_mode
.is_production
())
.file_tracing
(
next_mode
.is_production
())
.debug_ids
(
*
debug_ids
.await
?
)
.debug_ids
(
*
debug_ids
.await
?
)
.nested_async_availability
(
*
nested_async_chunking
.await
?
)
.nested_async_availability
(
*
nested_async_chunking
.await
?
)
.worker_forwarded_globals
(
worker_forwarded_globals
());
.worker_forwarded_globals
(
worker_forwarded_globals
());
if
let
Some
(
export_usage
)
=
export_usage
{
builder
=
builder
.export_usage
(
export_usage
);
}
builder
=
builder
.source_map_source_type
(
if
next_mode
.is_development
()
{
builder
=
builder
.source_map_source_type
(
if
next_mode
.is_development
()
{
SourceMapSourceType
::
AbsoluteFileUri
SourceMapSourceType
::
AbsoluteFileUri
}
else
{
}
else
{
...
@@ -1165,14 +1168,17 @@ pub async fn get_server_chunking_context(
...
@@ -1165,14 +1168,17 @@ pub async fn get_server_chunking_context(
MinifyType
::
NoMinify
MinifyType
::
NoMinify
})
})
.source_maps
(
*
source_maps
.await
?
)
.source_maps
(
*
source_maps
.await
?
)
.module_id_strategy
(
module_id_strategy
.to_resolved
()
.await
?
)
.module_id_strategy
(
module_id_strategy
)
.export_usage
(
*
export_usage
.await
?
)
.unused_references
(
unused_references
)
.unused_references
(
unused_references
.to_resolved
()
.await
?
)
.file_tracing
(
next_mode
.is_production
())
.file_tracing
(
next_mode
.is_production
())
.debug_ids
(
*
debug_ids
.await
?
)
.debug_ids
(
*
debug_ids
.await
?
)
.nested_async_availability
(
*
nested_async_chunking
.await
?
)
.nested_async_availability
(
*
nested_async_chunking
.await
?
)
.worker_forwarded_globals
(
worker_forwarded_globals
());
.worker_forwarded_globals
(
worker_forwarded_globals
());
if
let
Some
(
export_usage
)
=
export_usage
{
builder
=
builder
.export_usage
(
export_usage
);
}
if
next_mode
.is_development
()
{
if
next_mode
.is_development
()
{
builder
=
builder
.source_map_source_type
(
SourceMapSourceType
::
AbsoluteFileUri
);
builder
=
builder
.source_map_source_type
(
SourceMapSourceType
::
AbsoluteFileUri
);
}
else
{
}
else
{
...
...
turbopack/crates/turbopack-browser/src/chunking_context.rs
View file @
a676aa7e
use
anyhow
::{
Context
,
Result
,
bail
};
use
anyhow
::{
Context
,
Result
,
bail
};
use
tracing
::
Instrument
;
use
tracing
::
Instrument
;
use
turbo_rcstr
::{
RcStr
,
rcstr
};
use
turbo_rcstr
::{
RcStr
,
rcstr
};
use
turbo_tasks
::{
FxIndexMap
,
ResolvedVc
,
TaskInput
,
TryJoinIterExt
,
Upcast
,
ValueToString
,
Vc
};
use
turbo_tasks
::{
FxIndexMap
,
OperationVc
,
ResolvedVc
,
TaskInput
,
TryJoinIterExt
,
Upcast
,
ValueToString
,
Vc
};
use
turbo_tasks_fs
::
FileSystemPath
;
use
turbo_tasks_fs
::
FileSystemPath
;
use
turbo_tasks_hash
::
HashAlgorithm
;
use
turbo_tasks_hash
::
HashAlgorithm
;
use
turbopack_core
::{
use
turbopack_core
::{
...
@@ -133,17 +133,17 @@ impl BrowserChunkingContextBuilder {
...
@@ -133,17 +133,17 @@ impl BrowserChunkingContextBuilder {
self
self
}
}
pub
fn
module_id_strategy
(
mut
self
,
module_id_strategy
:
Resolved
Vc
<
ModuleIdStrategy
>
)
->
Self
{
pub
fn
module_id_strategy
(
mut
self
,
module_id_strategy
:
Operation
Vc
<
ModuleIdStrategy
>
)
->
Self
{
self
.chunking_context.module_id_strategy
=
Some
(
module_id_strategy
);
self
.chunking_context.module_id_strategy
=
Some
(
module_id_strategy
);
self
self
}
}
pub
fn
export_usage
(
mut
self
,
export_usage
:
Op
tion
<
ResolvedVc
<
BindingUsageInfo
>
>
)
->
Self
{
pub
fn
export_usage
(
mut
self
,
export_usage
:
Op
erationVc
<
BindingUsageInfo
>
)
->
Self
{
self
.chunking_context.export_usage
=
export_usage
;
self
.chunking_context.export_usage
=
Some
(
export_usage
)
;
self
self
}
}
pub
fn
unused_references
(
mut
self
,
unused_references
:
Resolved
Vc
<
UnusedReferences
>
)
->
Self
{
pub
fn
unused_references
(
mut
self
,
unused_references
:
Operation
Vc
<
UnusedReferences
>
)
->
Self
{
self
.chunking_context.unused_references
=
Some
(
unused_references
);
self
.chunking_context.unused_references
=
Some
(
unused_references
);
self
self
}
}
...
@@ -301,11 +301,11 @@ pub struct BrowserChunkingContext {
...
@@ -301,11 +301,11 @@ pub struct BrowserChunkingContext {
/// Whether to use manifest chunks for lazy compilation
/// Whether to use manifest chunks for lazy compilation
manifest_chunks
:
bool
,
manifest_chunks
:
bool
,
/// The module id strategy to use
/// The module id strategy to use
module_id_strategy
:
Option
<
Resolved
Vc
<
ModuleIdStrategy
>>
,
module_id_strategy
:
Option
<
Operation
Vc
<
ModuleIdStrategy
>>
,
/// The module export usage info, if available.
/// The module export usage info, if available.
export_usage
:
Option
<
Resolved
Vc
<
BindingUsageInfo
>>
,
export_usage
:
Option
<
Operation
Vc
<
BindingUsageInfo
>>
,
/// Which references are unused and should be skipped (e.g. during codegen).
/// Which references are unused and should be skipped (e.g. during codegen).
unused_references
:
Option
<
Resolved
Vc
<
UnusedReferences
>>
,
unused_references
:
Option
<
Operation
Vc
<
UnusedReferences
>>
,
/// The chunking configs
/// The chunking configs
chunking_configs
:
Vec
<
(
ResolvedVc
<
Box
<
dyn
ChunkType
>>
,
ChunkingConfig
)
>
,
chunking_configs
:
Vec
<
(
ResolvedVc
<
Box
<
dyn
ChunkType
>>
,
ChunkingConfig
)
>
,
/// Whether to use absolute URLs for static assets (e.g. in CSS: `url("/absolute/path")`)
/// Whether to use absolute URLs for static assets (e.g. in CSS: `url("/absolute/path")`)
...
@@ -868,9 +868,9 @@ impl ChunkingContext for BrowserChunkingContext {
...
@@ -868,9 +868,9 @@ impl ChunkingContext for BrowserChunkingContext {
#[turbo_tasks
::
function]
#[turbo_tasks
::
function]
fn
chunk_item_id_strategy
(
&
self
)
->
Vc
<
ModuleIdStrategy
>
{
fn
chunk_item_id_strategy
(
&
self
)
->
Vc
<
ModuleIdStrategy
>
{
*
self
self
.module_id_strategy
.m
odule_id_strategy
.m
ap
(|
v
|
v
.connect
())
.unwrap_or_else
(||
ModuleIdStrategy
::
default
()
.
resolved_
cell
())
.unwrap_or_else
(||
ModuleIdStrategy
::
default
()
.cell
())
}
}
#[turbo_tasks
::
function]
#[turbo_tasks
::
function]
...
@@ -914,7 +914,7 @@ impl ChunkingContext for BrowserChunkingContext {
...
@@ -914,7 +914,7 @@ impl ChunkingContext for BrowserChunkingContext {
module
:
ResolvedVc
<
Box
<
dyn
Module
>>
,
module
:
ResolvedVc
<
Box
<
dyn
Module
>>
,
)
->
Result
<
Vc
<
ModuleExportUsage
>>
{
)
->
Result
<
Vc
<
ModuleExportUsage
>>
{
if
let
Some
(
export_usage
)
=
self
.export_usage
{
if
let
Some
(
export_usage
)
=
self
.export_usage
{
Ok
(
export_usage
.await
?
.used_exports
(
module
)
.await
?
)
Ok
(
export_usage
.
connect
()
.
await
?
.used_exports
(
module
)
.await
?
)
}
else
{
}
else
{
Ok
(
ModuleExportUsage
::
all
())
Ok
(
ModuleExportUsage
::
all
())
}
}
...
@@ -923,7 +923,7 @@ impl ChunkingContext for BrowserChunkingContext {
...
@@ -923,7 +923,7 @@ impl ChunkingContext for BrowserChunkingContext {
#[turbo_tasks
::
function]
#[turbo_tasks
::
function]
fn
unused_references
(
&
self
)
->
Vc
<
UnusedReferences
>
{
fn
unused_references
(
&
self
)
->
Vc
<
UnusedReferences
>
{
if
let
Some
(
unused_references
)
=
self
.unused_references
{
if
let
Some
(
unused_references
)
=
self
.unused_references
{
*
unused_references
unused_references
.connect
()
}
else
{
}
else
{
Vc
::
cell
(
Default
::
default
())
Vc
::
cell
(
Default
::
default
())
}
}
...
...
turbopack/crates/turbopack-cli/src/build/mod.rs
View file @
a676aa7e
...
@@ -32,7 +32,7 @@ use turbopack_core::{
...
@@ -32,7 +32,7 @@ use turbopack_core::{
module
::
Module
,
module
::
Module
,
module_graph
::{
module_graph
::{
ModuleGraph
,
SingleModuleGraph
,
ModuleGraph
,
SingleModuleGraph
,
binding_usage_info
::
compute_binding_usage_info
,
binding_usage_info
::
{
compute_binding_usage_info
,
get_unused_references
}
,
chunk_group_info
::{
ChunkGroup
,
ChunkGroupEntry
},
chunk_group_info
::{
ChunkGroup
,
ChunkGroupEntry
},
},
},
output
::{
OutputAsset
,
OutputAssets
,
OutputAssetsWithReferenced
},
output
::{
OutputAsset
,
OutputAssets
,
OutputAssetsWithReferenced
},
...
@@ -316,17 +316,11 @@ async fn build_internal(
...
@@ -316,17 +316,11 @@ async fn build_internal(
);
);
let
mut
module_graph
=
ModuleGraph
::
from_single_graph
(
single_graph
);
let
mut
module_graph
=
ModuleGraph
::
from_single_graph
(
single_graph
);
let
binding_usage
=
compute_binding_usage_info
(
module_graph
,
true
);
let
binding_usage
=
compute_binding_usage_info
(
module_graph
,
true
);
let
unused_references
=
binding_usage
let
unused_references
=
get_unused_references
(
binding_usage
);
.connect
()
.unused_references
()
.to_resolved
()
.await
?
;
module_graph
=
module_graph
=
ModuleGraph
::
from_single_graph_without_unused_references
(
single_graph
,
binding_usage
);
ModuleGraph
::
from_single_graph_without_unused_references
(
single_graph
,
binding_usage
);
let
module_id_strategy
=
get_global_module_id_strategy
(
module_graph
);
let
module_graph
=
module_graph
.connect
();
let
module_graph
=
module_graph
.connect
();
let
module_id_strategy
=
get_global_module_id_strategy
(
module_graph
)
.to_resolved
()
.await
?
;
let
chunking_context
:
Vc
<
Box
<
dyn
ChunkingContext
>>
=
match
target
{
let
chunking_context
:
Vc
<
Box
<
dyn
ChunkingContext
>>
=
match
target
{
Target
::
Browser
=>
{
Target
::
Browser
=>
{
...
@@ -352,7 +346,7 @@ async fn build_internal(
...
@@ -352,7 +346,7 @@ async fn build_internal(
)
)
.source_maps
(
source_maps_type
)
.source_maps
(
source_maps_type
)
.module_id_strategy
(
module_id_strategy
)
.module_id_strategy
(
module_id_strategy
)
.export_usage
(
Some
(
binding_usage
.connect
()
.to_resolved
()
.await
?
)
)
.export_usage
(
binding_usage
)
.unused_references
(
unused_references
)
.unused_references
(
unused_references
)
.current_chunk_method
(
CurrentChunkMethod
::
DocumentCurrentScript
)
.current_chunk_method
(
CurrentChunkMethod
::
DocumentCurrentScript
)
.minify_type
(
minify_type
);
.minify_type
(
minify_type
);
...
@@ -403,7 +397,7 @@ async fn build_internal(
...
@@ -403,7 +397,7 @@ async fn build_internal(
)
)
.source_maps
(
source_maps_type
)
.source_maps
(
source_maps_type
)
.module_id_strategy
(
module_id_strategy
)
.module_id_strategy
(
module_id_strategy
)
.export_usage
(
Some
(
binding_usage
.connect
()
.to_resolved
()
.await
?
)
)
.export_usage
(
binding_usage
)
.unused_references
(
unused_references
)
.unused_references
(
unused_references
)
.minify_type
(
minify_type
);
.minify_type
(
minify_type
);
...
...
turbopack/crates/turbopack-core/src/module_graph/binding_usage_info.rs
View file @
a676aa7e
...
@@ -94,6 +94,11 @@ impl BindingUsageInfo {
...
@@ -94,6 +94,11 @@ impl BindingUsageInfo {
}
}
}
}
#[turbo_tasks
::
function(operation)]
pub
fn
get_unused_references
(
binding_usage
:
OperationVc
<
BindingUsageInfo
>
)
->
Vc
<
UnusedReferences
>
{
binding_usage
.connect
()
.unused_references
()
}
#[turbo_tasks
::
function(operation)]
#[turbo_tasks
::
function(operation)]
pub
async
fn
compute_binding_usage_info
(
pub
async
fn
compute_binding_usage_info
(
graph
:
OperationVc
<
ModuleGraph
>
,
graph
:
OperationVc
<
ModuleGraph
>
,
...
...
turbopack/crates/turbopack-nodejs/src/chunking_context.rs
View file @
a676aa7e
use
anyhow
::{
Context
,
Result
,
bail
};
use
anyhow
::{
Context
,
Result
,
bail
};
use
tracing
::
Instrument
;
use
tracing
::
Instrument
;
use
turbo_rcstr
::{
RcStr
,
rcstr
};
use
turbo_rcstr
::{
RcStr
,
rcstr
};
use
turbo_tasks
::{
FxIndexMap
,
ResolvedVc
,
TryJoinIterExt
,
Upcast
,
ValueToString
,
Vc
};
use
turbo_tasks
::{
FxIndexMap
,
OperationVc
,
ResolvedVc
,
TryJoinIterExt
,
Upcast
,
ValueToString
,
Vc
};
use
turbo_tasks_fs
::
FileSystemPath
;
use
turbo_tasks_fs
::
FileSystemPath
;
use
turbopack_core
::{
use
turbopack_core
::{
asset
::
Asset
,
asset
::
Asset
,
...
@@ -120,17 +120,17 @@ impl NodeJsChunkingContextBuilder {
...
@@ -120,17 +120,17 @@ impl NodeJsChunkingContextBuilder {
self
self
}
}
pub
fn
module_id_strategy
(
mut
self
,
module_id_strategy
:
Resolved
Vc
<
ModuleIdStrategy
>
)
->
Self
{
pub
fn
module_id_strategy
(
mut
self
,
module_id_strategy
:
Operation
Vc
<
ModuleIdStrategy
>
)
->
Self
{
self
.chunking_context.module_id_strategy
=
Some
(
module_id_strategy
);
self
.chunking_context.module_id_strategy
=
Some
(
module_id_strategy
);
self
self
}
}
pub
fn
export_usage
(
mut
self
,
export_usage
:
Op
tion
<
ResolvedVc
<
BindingUsageInfo
>
>
)
->
Self
{
pub
fn
export_usage
(
mut
self
,
export_usage
:
Op
erationVc
<
BindingUsageInfo
>
)
->
Self
{
self
.chunking_context.export_usage
=
export_usage
;
self
.chunking_context.export_usage
=
Some
(
export_usage
)
;
self
self
}
}
pub
fn
unused_references
(
mut
self
,
unused_references
:
Resolved
Vc
<
UnusedReferences
>
)
->
Self
{
pub
fn
unused_references
(
mut
self
,
unused_references
:
Operation
Vc
<
UnusedReferences
>
)
->
Self
{
self
.chunking_context.unused_references
=
Some
(
unused_references
);
self
.chunking_context.unused_references
=
Some
(
unused_references
);
self
self
}
}
...
@@ -219,11 +219,11 @@ pub struct NodeJsChunkingContext {
...
@@ -219,11 +219,11 @@ pub struct NodeJsChunkingContext {
/// Whether to use manifest chunks for lazy compilation
/// Whether to use manifest chunks for lazy compilation
manifest_chunks
:
bool
,
manifest_chunks
:
bool
,
/// The strategy to use for generating module ids
/// The strategy to use for generating module ids
module_id_strategy
:
Option
<
Resolved
Vc
<
ModuleIdStrategy
>>
,
module_id_strategy
:
Option
<
Operation
Vc
<
ModuleIdStrategy
>>
,
/// The module export usage info, if available.
/// The module export usage info, if available.
export_usage
:
Option
<
Resolved
Vc
<
BindingUsageInfo
>>
,
export_usage
:
Option
<
Operation
Vc
<
BindingUsageInfo
>>
,
/// Which references are unused and should be skipped (e.g. during codegen).
/// Which references are unused and should be skipped (e.g. during codegen).
unused_references
:
Option
<
Resolved
Vc
<
UnusedReferences
>>
,
unused_references
:
Option
<
Operation
Vc
<
UnusedReferences
>>
,
/// The strategy to use for generating source map source uris
/// The strategy to use for generating source map source uris
source_map_source_type
:
SourceMapSourceType
,
source_map_source_type
:
SourceMapSourceType
,
/// The chunking configs
/// The chunking configs
...
@@ -638,9 +638,9 @@ impl ChunkingContext for NodeJsChunkingContext {
...
@@ -638,9 +638,9 @@ impl ChunkingContext for NodeJsChunkingContext {
#[turbo_tasks
::
function]
#[turbo_tasks
::
function]
fn
chunk_item_id_strategy
(
&
self
)
->
Vc
<
ModuleIdStrategy
>
{
fn
chunk_item_id_strategy
(
&
self
)
->
Vc
<
ModuleIdStrategy
>
{
*
self
self
.module_id_strategy
.m
odule_id_strategy
.m
ap
(|
v
|
v
.connect
())
.unwrap_or_else
(||
ModuleIdStrategy
::
default
()
.
resolved_
cell
())
.unwrap_or_else
(||
ModuleIdStrategy
::
default
()
.cell
())
}
}
#[turbo_tasks
::
function]
#[turbo_tasks
::
function]
...
@@ -689,7 +689,7 @@ impl ChunkingContext for NodeJsChunkingContext {
...
@@ -689,7 +689,7 @@ impl ChunkingContext for NodeJsChunkingContext {
module
:
ResolvedVc
<
Box
<
dyn
Module
>>
,
module
:
ResolvedVc
<
Box
<
dyn
Module
>>
,
)
->
Result
<
Vc
<
ModuleExportUsage
>>
{
)
->
Result
<
Vc
<
ModuleExportUsage
>>
{
if
let
Some
(
export_usage
)
=
self
.export_usage
{
if
let
Some
(
export_usage
)
=
self
.export_usage
{
Ok
(
export_usage
.await
?
.used_exports
(
module
)
.await
?
)
Ok
(
export_usage
.
connect
()
.
await
?
.used_exports
(
module
)
.await
?
)
}
else
{
}
else
{
Ok
(
ModuleExportUsage
::
all
())
Ok
(
ModuleExportUsage
::
all
())
}
}
...
@@ -698,7 +698,7 @@ impl ChunkingContext for NodeJsChunkingContext {
...
@@ -698,7 +698,7 @@ impl ChunkingContext for NodeJsChunkingContext {
#[turbo_tasks
::
function]
#[turbo_tasks
::
function]
fn
unused_references
(
&
self
)
->
Vc
<
UnusedReferences
>
{
fn
unused_references
(
&
self
)
->
Vc
<
UnusedReferences
>
{
if
let
Some
(
unused_references
)
=
self
.unused_references
{
if
let
Some
(
unused_references
)
=
self
.unused_references
{
*
unused_references
unused_references
.connect
()
}
else
{
}
else
{
Vc
::
cell
(
Default
::
default
())
Vc
::
cell
(
Default
::
default
())
}
}
...
...
turbopack/crates/turbopack-tests/tests/execution.rs
View file @
a676aa7e
...
@@ -39,7 +39,8 @@ use turbopack_core::{
...
@@ -39,7 +39,8 @@ use turbopack_core::{
ident
::
Layer
,
ident
::
Layer
,
issue
::{
CollectibleIssuesExt
,
IssueFilter
},
issue
::{
CollectibleIssuesExt
,
IssueFilter
},
module_graph
::{
module_graph
::{
ModuleGraph
,
SingleModuleGraph
,
binding_usage_info
::
compute_binding_usage_info
,
ModuleGraph
,
SingleModuleGraph
,
binding_usage_info
::{
compute_binding_usage_info
,
get_unused_references
},
},
},
reference_type
::{
InnerAssets
,
ReferenceType
},
reference_type
::{
InnerAssets
,
ReferenceType
},
resolve
::{
resolve
::{
...
@@ -530,22 +531,14 @@ async fn run_test_operation(prepared_test: ResolvedVc<PreparedTest>) -> Result<V
...
@@ -530,22 +531,14 @@ async fn run_test_operation(prepared_test: ResolvedVc<PreparedTest>) -> Result<V
}
}
}
else
{
}
else
{
MinifyType
::
NoMinify
MinifyType
::
NoMinify
})
.export_usage
(
if
options
.remove_unused_exports
{
Some
(
binding_usage
.unwrap
()
.connect
()
.to_resolved
()
.await
?
)
}
else
{
None
});
});
if
options
.remove_unused_exports
{
builder
=
builder
.export_usage
(
binding_usage
.unwrap
());
}
if
options
.remove_unused_imports
{
if
options
.remove_unused_imports
{
builder
=
builder
.unused_references
(
builder
=
builder
.unused_references
(
get_unused_references
(
binding_usage
.unwrap
()));
binding_usage
.unwrap
()
.connect
()
.unused_references
()
.to_resolved
()
.await
?
,
);
}
}
if
options
.production_chunking
{
if
options
.production_chunking
{
...
...
turbopack/crates/turbopack-tests/tests/snapshot.rs
View file @
a676aa7e
...
@@ -46,7 +46,7 @@ use turbopack_core::{
...
@@ -46,7 +46,7 @@ use turbopack_core::{
module
::
Module
,
module
::
Module
,
module_graph
::{
module_graph
::{
ModuleGraph
,
SingleModuleGraph
,
ModuleGraph
,
SingleModuleGraph
,
binding_usage_info
::
compute_binding_usage_info
,
binding_usage_info
::
{
compute_binding_usage_info
,
get_unused_references
}
,
chunk_group_info
::{
ChunkGroup
,
ChunkGroupEntry
},
chunk_group_info
::{
ChunkGroup
,
ChunkGroupEntry
},
},
},
output
::{
OutputAsset
,
OutputAssets
,
OutputAssetsReference
,
OutputAssetsWithReferenced
},
output
::{
OutputAsset
,
OutputAssets
,
OutputAssetsReference
,
OutputAssetsWithReferenced
},
...
@@ -497,24 +497,16 @@ async fn run_test_operation(resource: RcStr) -> Result<Vc<FileSystemPath>> {
...
@@ -497,24 +497,16 @@ async fn run_test_operation(resource: RcStr) -> Result<Vc<FileSystemPath>> {
)
)
.minify_type
(
options
.minify_type
)
.minify_type
(
options
.minify_type
)
.module_merging
(
options
.scope_hoisting
)
.module_merging
(
options
.scope_hoisting
)
.export_usage
(
if
options
.remove_unused_exports
{
Some
(
binding_usage
.unwrap
()
.connect
()
.to_resolved
()
.await
?
)
}
else
{
None
})
.debug_ids
(
options
.enable_debug_ids
)
.debug_ids
(
options
.enable_debug_ids
)
.source_map_source_type
(
options
.source_map_source_type
)
.source_map_source_type
(
options
.source_map_source_type
)
.chunk_loading_global
(
options
.chunk_loading_global
.into
());
.chunk_loading_global
(
options
.chunk_loading_global
.into
());
if
options
.remove_unused_exports
{
builder
=
builder
.export_usage
(
binding_usage
.unwrap
());
}
if
options
.remove_unused_imports
{
if
options
.remove_unused_imports
{
builder
=
builder
.unused_references
(
builder
=
builder
.unused_references
(
get_unused_references
(
binding_usage
.unwrap
()));
binding_usage
.unwrap
()
.connect
()
.unused_references
()
.to_resolved
()
.await
?
,
);
}
}
if
options
.production_chunking
{
if
options
.production_chunking
{
...
@@ -545,23 +537,15 @@ async fn run_test_operation(resource: RcStr) -> Result<Vc<FileSystemPath>> {
...
@@ -545,23 +537,15 @@ async fn run_test_operation(resource: RcStr) -> Result<Vc<FileSystemPath>> {
)
)
.minify_type
(
options
.minify_type
)
.minify_type
(
options
.minify_type
)
.module_merging
(
options
.scope_hoisting
)
.module_merging
(
options
.scope_hoisting
)
.export_usage
(
if
options
.remove_unused_exports
{
Some
(
binding_usage
.unwrap
()
.connect
()
.to_resolved
()
.await
?
)
}
else
{
None
})
.debug_ids
(
options
.enable_debug_ids
)
.debug_ids
(
options
.enable_debug_ids
)
.source_map_source_type
(
options
.source_map_source_type
);
.source_map_source_type
(
options
.source_map_source_type
);
if
options
.remove_unused_exports
{
builder
=
builder
.export_usage
(
binding_usage
.unwrap
());
}
if
options
.remove_unused_imports
{
if
options
.remove_unused_imports
{
builder
=
builder
.unused_references
(
builder
=
builder
.unused_references
(
get_unused_references
(
binding_usage
.unwrap
()));
binding_usage
.unwrap
()
.connect
()
.unused_references
()
.to_resolved
()
.await
?
,
);
}
}
if
options
.production_chunking
{
if
options
.production_chunking
{
...
...
turbopack/crates/turbopack/src/global_module_ids.rs
View file @
a676aa7e
...
@@ -3,7 +3,7 @@ use rustc_hash::FxHashMap;
...
@@ -3,7 +3,7 @@ use rustc_hash::FxHashMap;
use
smallvec
::
SmallVec
;
use
smallvec
::
SmallVec
;
use
tracing
::
Instrument
;
use
tracing
::
Instrument
;
use
turbo_rcstr
::
RcStr
;
use
turbo_rcstr
::
RcStr
;
use
turbo_tasks
::{
ReadRef
,
ResolvedVc
,
TryJoinIterExt
,
ValueToString
,
Vc
};
use
turbo_tasks
::{
OperationVc
,
ReadRef
,
ResolvedVc
,
TryJoinIterExt
,
ValueToString
,
Vc
};
use
turbo_tasks_hash
::
hash_xxh3_hash64
;
use
turbo_tasks_hash
::
hash_xxh3_hash64
;
use
turbopack_core
::{
use
turbopack_core
::{
chunk
::{
chunk
::{
...
@@ -16,13 +16,13 @@ use turbopack_core::{
...
@@ -16,13 +16,13 @@ use turbopack_core::{
};
};
use
turbopack_ecmascript
::
async_chunk
::
module
::
AsyncLoaderModule
;
use
turbopack_ecmascript
::
async_chunk
::
module
::
AsyncLoaderModule
;
#[turbo_tasks
::
function]
#[turbo_tasks
::
function
(operation)
]
pub
async
fn
get_global_module_id_strategy
(
pub
async
fn
get_global_module_id_strategy
(
module_graph
:
Resolved
Vc
<
ModuleGraph
>
,
module_graph
:
Operation
Vc
<
ModuleGraph
>
,
)
->
Result
<
Vc
<
ModuleIdStrategy
>>
{
)
->
Result
<
Vc
<
ModuleIdStrategy
>>
{
let
span
=
tracing
::
info_span!
(
"compute module id map"
);
let
span
=
tracing
::
info_span!
(
"compute module id map"
);
async
move
{
async
move
{
let
module_graph
=
module_graph
.await
?
;
let
module_graph
=
module_graph
.
connect
()
.
await
?
;
let
graphs
=
&
module_graph
.graphs
;
let
graphs
=
&
module_graph
.graphs
;
// All modules in the graph
// All modules in the graph
...
...
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