Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 3 additions & 1 deletion apps/bundle-analyzer/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,9 @@
"**/*.ts",
"**/*.tsx",
".next/types/**/*.ts",
".next/dev/types/**/*.ts"
".next/dev/types/**/*.ts",
"dist/types/**/*.ts",
"dist/dev/types/**/*.ts"
],
"exclude": ["node_modules"]
}
1 change: 1 addition & 0 deletions crates/next-api/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ turbopack-ecmascript = { workspace = true }
turbopack-node = { workspace = true }
turbopack-nodejs = { workspace = true }
turbopack-wasm = { workspace = true }
urlencoding = { workspace = true }

[dev-dependencies]
turbo-tasks-malloc = { workspace = true }
Expand Down
31 changes: 17 additions & 14 deletions crates/next-api/src/analyze.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use std::io::Write;
use std::{borrow::Cow, io::Write};

use anyhow::Result;
use byteorder::{BE, WriteBytesExt};
Expand All @@ -23,7 +23,7 @@ use turbopack_core::{
reference::all_assets_from_entries,
};

use crate::route::{Endpoint, ModuleGraphs};
use crate::route::ModuleGraphs;

#[derive(
Default, Clone, Debug, Deserialize, Eq, NonLocalValue, PartialEq, Serialize, TraceRawVcs,
Expand Down Expand Up @@ -371,9 +371,16 @@ pub async fn analyze_output_assets(output_assets: Vc<OutputAssets>) -> Result<Vc
let output_file_index = builder.add_output_file(AnalyzeOutputFile { filename });
let chunk_parts = split_output_asset_into_parts(*asset).await?;
for chunk_part in chunk_parts {
let source_index = builder
.ensure_source(chunk_part.source.trim_start_matches(&prefix))
.1;
let decoded_source = urlencoding::decode(&chunk_part.source)?;
let source = if let Some(stripped) = decoded_source.strip_prefix(&prefix) {
Cow::Borrowed(stripped)
} else {
Cow::Owned(format!(
"[project]/{}",
decoded_source.trim_start_matches("../")
))
};
let source_index = builder.ensure_source(&source).1;
let chunk_part_index = builder.add_chunk_part(AnalyzeChunkPart {
source_index,
output_file_index,
Expand Down Expand Up @@ -533,13 +540,6 @@ pub async fn analyze_module_graphs(module_graphs: Vc<ModuleGraphs>) -> Result<Vc
Ok(FileContent::Content(File::from(rope)).cell())
}

#[turbo_tasks::function]
pub async fn analyze_endpoint(endpoint: Vc<Box<dyn Endpoint>>) -> Result<Vc<FileContent>> {
Ok(analyze_output_assets(
*endpoint.output().await?.output_assets,
))
}

#[turbo_tasks::value]
pub struct AnalyzeDataOutputAsset {
pub path: FileSystemPath,
Expand All @@ -549,10 +549,13 @@ pub struct AnalyzeDataOutputAsset {
#[turbo_tasks::value_impl]
impl AnalyzeDataOutputAsset {
#[turbo_tasks::function]
pub async fn new(path: FileSystemPath, output_assets: Vc<OutputAssets>) -> Result<Vc<Self>> {
pub async fn new(
path: FileSystemPath,
output_assets: ResolvedVc<OutputAssets>,
) -> Result<Vc<Self>> {
Ok(Self {
path,
output_assets: output_assets.to_resolved().await?,
output_assets,
}
.cell())
}
Expand Down
Loading