Skip to content

Commit 4f25a16

Browse files
committed
merge upstream/canary
2 parents b4f96c8 + 77f60a6 commit 4f25a16

File tree

377 files changed

+6475
-2053
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

377 files changed

+6475
-2053
lines changed

Cargo.lock

Lines changed: 8 additions & 8 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -337,7 +337,7 @@ turbopack-trace-utils = { path = "turbopack/crates/turbopack-trace-utils" }
337337
turbopack-wasm = { path = "turbopack/crates/turbopack-wasm" }
338338

339339
# SWC crates
340-
swc_core = { version = "48.0.1", features = [
340+
swc_core = { version = "48.0.4", features = [
341341
"ecma_loader_lru",
342342
"ecma_loader_parking_lot",
343343
"parallel_rayon",

apps/bundle-analyzer/.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
/next-env.d.ts

apps/bundle-analyzer/next-env.d.ts

Lines changed: 0 additions & 6 deletions
This file was deleted.

apps/bundle-analyzer/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@next/bundle-analyzer-ui",
3-
"version": "16.0.2-canary.16",
3+
"version": "0.0.1",
44
"private": true,
55
"scripts": {
66
"build": "cross-env NEXT_TEST_NATIVE_DIR=no next build --no-mangling",

crates/napi/src/next_api/project.rs

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ use turbopack_core::{
5151
error::PrettyPrintError,
5252
issue::PlainIssue,
5353
output::{OutputAsset, OutputAssets},
54-
source_map::{OptionStringifiedSourceMap, SourceMap, Token},
54+
source_map::{SourceMap, Token},
5555
version::{PartialUpdate, TotalUpdate, Update, VersionState},
5656
};
5757
use turbopack_ecmascript_hmr_protocol::{ClientUpdateInstruction, Issue, ResourceIdentifier};
@@ -1550,7 +1550,7 @@ pub struct OptionStackFrame(Option<StackFrame>);
15501550
pub async fn get_source_map_rope(
15511551
container: Vc<ProjectContainer>,
15521552
source_url: RcStr,
1553-
) -> Result<Vc<OptionStringifiedSourceMap>> {
1553+
) -> Result<Vc<FileContent>> {
15541554
let (file_path_sys, module) = match Url::parse(&source_url) {
15551555
Ok(url) => match url.scheme() {
15561556
"file" => {
@@ -1579,7 +1579,7 @@ pub async fn get_source_map_rope(
15791579
Some(relative_path) => sys_to_unix(relative_path),
15801580
None => {
15811581
// File doesn't exist within the dist dir
1582-
return Ok(OptionStringifiedSourceMap::none());
1582+
return Ok(FileContent::NotFound.cell());
15831583
}
15841584
};
15851585

@@ -1597,13 +1597,13 @@ pub async fn get_source_map_rope(
15971597

15981598
let mut map = container.get_source_map(server_path, module.clone());
15991599

1600-
if map.await?.is_none() {
1600+
if !map.await?.is_content() {
16011601
// If the chunk doesn't exist as a server chunk, try a client chunk.
16021602
// TODO: Properly tag all server chunks and use the `isServer` query param.
16031603
// Currently, this is inaccurate as it does not cover RSC server
16041604
// chunks.
16051605
map = container.get_source_map(client_path, module);
1606-
if map.await?.is_none() {
1606+
if !map.await?.is_content() {
16071607
bail!("chunk/module '{}' is missing a sourcemap", source_url);
16081608
}
16091609
}
@@ -1615,7 +1615,7 @@ pub async fn get_source_map_rope(
16151615
pub fn get_source_map_rope_operation(
16161616
container: ResolvedVc<ProjectContainer>,
16171617
file_path: RcStr,
1618-
) -> Vc<OptionStringifiedSourceMap> {
1618+
) -> Vc<FileContent> {
16191619
get_source_map_rope(*container, file_path)
16201620
}
16211621

@@ -1782,13 +1782,13 @@ pub async fn project_get_source_map(
17821782
let ctx = &project.turbopack_ctx;
17831783
ctx.turbo_tasks()
17841784
.run(async move {
1785-
let Some(map) = &*get_source_map_rope_operation(container, file_path)
1785+
let source_map = get_source_map_rope_operation(container, file_path)
17861786
.read_strongly_consistent()
1787-
.await?
1788-
else {
1787+
.await?;
1788+
let Some(map) = source_map.as_content() else {
17891789
return Ok(None);
17901790
};
1791-
Ok(Some(map.to_str()?.to_string()))
1791+
Ok(Some(map.content().to_str()?.to_string()))
17921792
})
17931793
// HACK: Don't use `TurbopackInternalError`, this function is race-condition prone (the
17941794
// source files may have changed or been deleted), so these probably aren't internal errors?

crates/next-api/src/analyze.rs

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -430,15 +430,17 @@ pub async fn analyze_module_graphs(module_graphs: Vc<ModuleGraphs>) -> Result<Vc
430430
let mut all_async_edges = FxIndexSet::default();
431431
for &module_graph in module_graphs.await? {
432432
let module_graph = module_graph.read_graphs().await?;
433-
module_graph.traverse_all_edges_unordered(|(parent_node, reference), node| {
434-
all_modules.insert(parent_node);
435-
all_modules.insert(node);
436-
match reference.chunking_type {
437-
ChunkingType::Async => {
438-
all_async_edges.insert((parent_node, node));
439-
}
440-
_ => {
441-
all_edges.insert((parent_node, node));
433+
module_graph.traverse_all_edges_unordered(|parent, node| {
434+
if let Some((parent_node, reference)) = parent {
435+
all_modules.insert(parent_node);
436+
all_modules.insert(node);
437+
match reference.chunking_type {
438+
ChunkingType::Async => {
439+
all_async_edges.insert((parent_node, node));
440+
}
441+
_ => {
442+
all_edges.insert((parent_node, node));
443+
}
442444
}
443445
}
444446
Ok(())

crates/next-api/src/app.rs

Lines changed: 34 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@ use turbopack_core::{
5959
module::Module,
6060
module_graph::{
6161
GraphEntries, ModuleGraph, SingleModuleGraph, VisitedModules,
62+
binding_usage_info::compute_binding_usage_info,
6263
chunk_group_info::{ChunkGroup, ChunkGroupEntry},
6364
},
6465
output::{OutputAsset, OutputAssets, OutputAssetsWithReferenced},
@@ -856,7 +857,8 @@ impl AppProject {
856857
has_layout_segments: bool,
857858
) -> Result<Vc<BaseAndFullModuleGraph>> {
858859
if *self.project.per_page_module_graph().await? {
859-
let should_trace = self.project.next_mode().await?.is_production();
860+
let next_mode = self.project.next_mode();
861+
let should_trace = next_mode.await?.is_production();
860862
let client_shared_entries = client_shared_entries
861863
.await?
862864
.into_iter()
@@ -949,10 +951,31 @@ impl AppProject {
949951
);
950952
graphs.push(additional_module_graph);
951953

952-
let full = ModuleGraph::from_graphs(graphs);
954+
let full_with_unused_references =
955+
ModuleGraph::from_graphs(graphs).to_resolved().await?;
956+
957+
let full = if *self
958+
.project
959+
.next_config()
960+
.turbopack_remove_unused_imports(next_mode)
961+
.await?
962+
{
963+
full_with_unused_references
964+
.without_unused_references(
965+
*compute_binding_usage_info(full_with_unused_references, true)
966+
.resolve_strongly_consistent()
967+
.await?,
968+
)
969+
.to_resolved()
970+
.await?
971+
} else {
972+
full_with_unused_references
973+
};
974+
953975
Ok(BaseAndFullModuleGraph {
954976
base: base.to_resolved().await?,
955-
full: full.to_resolved().await?,
977+
full_with_unused_references,
978+
full,
956979
}
957980
.cell())
958981
}
@@ -1357,7 +1380,10 @@ impl AppEndpoint {
13571380
"server/app{manifest_path_prefix}/webpack-stats.json",
13581381
))?,
13591382
AssetContent::file(
1360-
File::from(serde_json::to_string_pretty(&webpack_stats)?).into(),
1383+
FileContent::Content(File::from(serde_json::to_string_pretty(
1384+
&webpack_stats,
1385+
)?))
1386+
.cell(),
13611387
),
13621388
)
13631389
.to_resolved()
@@ -1886,7 +1912,10 @@ async fn create_app_paths_manifest(
18861912
VirtualOutputAsset::new(
18871913
path,
18881914
AssetContent::file(
1889-
File::from(serde_json::to_string_pretty(&app_paths_manifest)?).into(),
1915+
FileContent::Content(File::from(serde_json::to_string_pretty(
1916+
&app_paths_manifest,
1917+
)?))
1918+
.cell(),
18901919
),
18911920
)
18921921
.to_resolved()

crates/next-api/src/font.rs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ use anyhow::Result;
22
use next_core::next_manifests::NextFontManifest;
33
use turbo_rcstr::RcStr;
44
use turbo_tasks::{ResolvedVc, Vc};
5-
use turbo_tasks_fs::{File, FileSystemPath};
5+
use turbo_tasks_fs::{File, FileContent, FileSystemPath};
66
use turbopack_core::{
77
asset::{Asset, AssetContent},
88
output::{OutputAsset, OutputAssets, OutputAssetsReference},
@@ -94,7 +94,10 @@ impl Asset for FontManifest {
9494
};
9595

9696
Ok(AssetContent::file(
97-
File::from(serde_json::to_string_pretty(&next_font_manifest)?).into(),
97+
FileContent::Content(File::from(serde_json::to_string_pretty(
98+
&next_font_manifest,
99+
)?))
100+
.cell(),
98101
))
99102
}
100103
}

0 commit comments

Comments
 (0)