Unverified Commit ad75394a authored by Tobias Koppers's avatar Tobias Koppers Committed by GitHub

fix code generation for loader tree (#47987)

### What?

Fix missing `,` in loader tree code.

also adds `unsupported` as category of implicit metadata issue

### Why?

The loader tree to JS generated invalid code when there there where two
non-page files in a directory.

fixes WEB-861
parent e4e5c167
...@@ -597,9 +597,9 @@ impl AppRendererVc { ...@@ -597,9 +597,9 @@ impl AppRendererVc {
state.counter += 1; state.counter += 1;
let identifier = magic_identifier::mangle(&format!("{name} #{i}")); let identifier = magic_identifier::mangle(&format!("{name} #{i}"));
let chunks_identifier = magic_identifier::mangle(&format!("chunks of {name} #{i}")); let chunks_identifier = magic_identifier::mangle(&format!("chunks of {name} #{i}"));
write!( writeln!(
state.loader_tree_code, state.loader_tree_code,
"{name}: [() => {identifier}, JSON.stringify({chunks_identifier}) + '.js']", " {name}: [() => {identifier}, JSON.stringify({chunks_identifier}) + '.js'],",
name = StringifyJs(name) name = StringifyJs(name)
)?; )?;
state.imports.push(format!( state.imports.push(format!(
...@@ -638,7 +638,7 @@ import {}, {{ chunks as {} }} from "COMPONENT_{}"; ...@@ -638,7 +638,7 @@ import {}, {{ chunks as {} }} from "COMPONENT_{}";
components, components,
} = &*loader_tree.await?; } = &*loader_tree.await?;
write!( writeln!(
state.loader_tree_code, state.loader_tree_code,
"[{segment}, {{", "[{segment}, {{",
segment = StringifyJs(segment) segment = StringifyJs(segment)
...@@ -649,7 +649,7 @@ import {}, {{ chunks as {} }} from "COMPONENT_{}"; ...@@ -649,7 +649,7 @@ import {}, {{ chunks as {} }} from "COMPONENT_{}";
walk_tree(state, parallel_route).await?; walk_tree(state, parallel_route).await?;
writeln!(state.loader_tree_code, ",")?; writeln!(state.loader_tree_code, ",")?;
} }
write!(state.loader_tree_code, "}}, {{")?; writeln!(state.loader_tree_code, "}}, {{")?;
// add components // add components
let Components { let Components {
page, page,
...@@ -886,6 +886,11 @@ impl Issue for UnsupportedImplicitMetadataIssue { ...@@ -886,6 +886,11 @@ impl Issue for UnsupportedImplicitMetadataIssue {
IssueSeverity::Warning.into() IssueSeverity::Warning.into()
} }
#[turbo_tasks::function]
fn category(&self) -> StringVc {
StringVc::cell("unsupported".to_string())
}
#[turbo_tasks::function] #[turbo_tasks::function]
fn context(&self) -> FileSystemPathVc { fn context(&self) -> FileSystemPathVc {
self.app_dir self.app_dir
......
PlainIssue { PlainIssue {
severity: Warning, severity: Warning,
context: "[project]/packages/next-swc/crates/next-dev-tests/tests/integration/next/app/implicit-metadata/input/app", context: "[project]/packages/next-swc/crates/next-dev-tests/tests/integration/next/app/implicit-metadata/input/app",
category: "", category: "unsupported",
title: "Implicit metadata from filesystem is currently not supported in Turbopack", title: "Implicit metadata from filesystem is currently not supported in Turbopack",
description: "The following files were found in the app directory, but are not supported by Turbopack. They are ignored:\n\n- [project]/packages/next-swc/crates/next-dev-tests/tests/integration/next/app/implicit-metadata/input/app/apple-icon.png\n- [project]/packages/next-swc/crates/next-dev-tests/tests/integration/next/app/implicit-metadata/input/app/icon1234.png\n- [project]/packages/next-swc/crates/next-dev-tests/tests/integration/next/app/implicit-metadata/input/app/icon234.png", description: "The following files were found in the app directory, but are not supported by Turbopack. They are ignored:\n\n- [project]/packages/next-swc/crates/next-dev-tests/tests/integration/next/app/implicit-metadata/input/app/apple-icon.png\n- [project]/packages/next-swc/crates/next-dev-tests/tests/integration/next/app/implicit-metadata/input/app/icon1234.png\n- [project]/packages/next-swc/crates/next-dev-tests/tests/integration/next/app/implicit-metadata/input/app/icon234.png",
detail: "", detail: "",
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment