Unverified Commit fc05e6cb authored by Niklas Mischkulnig's avatar Niklas Mischkulnig Committed by GitHub

Turbopack: improve NFT warning message (#94854)

<img width="1382" height="476" alt="Bildschirmfoto 2026-06-16 um 18 11
15"
src="https://github.com/user-attachments/assets/f0ac053a-92fc-4b72-aef7-18f02fd17a82"
/>
parent 40296fe5
...@@ -479,34 +479,24 @@ impl Issue for ForbiddenTracedFileIssue { ...@@ -479,34 +479,24 @@ impl Issue for ForbiddenTracedFileIssue {
async fn title(&self) -> Result<StyledString> { async fn title(&self) -> Result<StyledString> {
Ok(StyledString::Text(rcstr!( Ok(StyledString::Text(rcstr!(
"Encountered unexpected file in NFT list" "Dynamic filesystem access causes tracing of the whole project"
))) )))
} }
async fn description(&self) -> Result<Option<StyledString>> { async fn description(&self) -> Result<Option<StyledString>> {
let stack = vec![ let stack = vec![
StyledString::Text(rcstr!( StyledString::Text(rcstr!(
"This import traced the next.config.js file which indicates that the whole \ "Static analysis determined that this filesystem access causes the whole project \
project was traced unintentionally. Somewhere in the import trace below, there \ to be traced and included in the output."
are:" )),
StyledString::Text(rcstr!(
"This is usually unintentional and leads to all source files (including the \
public folder) to be deployed as part of the server code."
)),
StyledString::Text(rcstr!(
"This can slow down deployments or lead to failures when size limits are exceeded."
)), )),
StyledString::Line(vec![
StyledString::Text(rcstr!("- filesystem operations (like ")),
StyledString::Code(rcstr!("path.join")),
StyledString::Text(rcstr!(", ")),
StyledString::Code(rcstr!("path.resolve")),
StyledString::Text(rcstr!(" or ")),
StyledString::Code(rcstr!("fs.readFile")),
StyledString::Text(rcstr!("), or")),
]),
StyledString::Line(vec![
StyledString::Text(rcstr!("- very dynamic requires (like ")),
StyledString::Code(rcstr!("require('./' + foo)")),
StyledString::Text(rcstr!(").")),
]),
StyledString::Text(rcstr!("To resolve this, you can")), StyledString::Text(rcstr!("To resolve this, you can")),
StyledString::Text(rcstr!("- remove them if possible, or")),
StyledString::Text(rcstr!("- only use them in development, or")),
StyledString::Line(vec![ StyledString::Line(vec![
StyledString::Text(rcstr!( StyledString::Text(rcstr!(
"- make sure they are statically scoped to some subfolder: " "- make sure they are statically scoped to some subfolder: "
...@@ -514,12 +504,15 @@ impl Issue for ForbiddenTracedFileIssue { ...@@ -514,12 +504,15 @@ impl Issue for ForbiddenTracedFileIssue {
StyledString::Code(rcstr!("path.join(process.cwd(), 'data', bar)")), StyledString::Code(rcstr!("path.join(process.cwd(), 'data', bar)")),
StyledString::Text(rcstr!(", or")), StyledString::Text(rcstr!(", or")),
]), ]),
StyledString::Text(rcstr!("- only use them in development, or")),
StyledString::Line(vec![ StyledString::Line(vec![
StyledString::Text(rcstr!("- add ignore comments: ")), StyledString::Text(rcstr!("- add ignore comments: ")),
StyledString::Code(rcstr!( StyledString::Code(rcstr!(
"path.join(/*turbopackIgnore: true*/ process.cwd(), bar)" "path.join(/*turbopackIgnore: true*/ process.cwd(), bar)"
)), )),
StyledString::Text(rcstr!(", or")),
]), ]),
StyledString::Text(rcstr!("- remove them.")),
]; ];
Ok(Some(StyledString::Stack(stack))) Ok(Some(StyledString::Stack(stack)))
} }
......
...@@ -24,7 +24,7 @@ import stripAnsi from 'strip-ansi' ...@@ -24,7 +24,7 @@ import stripAnsi from 'strip-ansi'
expect(stripAnsi(output)).toMatchInlineSnapshot(` expect(stripAnsi(output)).toMatchInlineSnapshot(`
"Turbopack build encountered 1 warnings: "Turbopack build encountered 1 warnings:
./app/join-cwd.js:4:10 ./app/join-cwd.js:4:10
Encountered unexpected file in NFT list Dynamic filesystem access causes tracing of the whole project
2 | 2 |
3 | export default function (f) { 3 | export default function (f) {
> 4 | return path.join(process.cwd(), f) > 4 | return path.join(process.cwd(), f)
...@@ -32,14 +32,14 @@ import stripAnsi from 'strip-ansi' ...@@ -32,14 +32,14 @@ import stripAnsi from 'strip-ansi'
5 | } 5 | }
6 | 6 |
This import traced the next.config.js file which indicates that the whole project was traced unintentionally. Somewhere in the import trace below, there are: Static analysis determined that this filesystem access causes the whole project to be traced and included in the output.
- filesystem operations (like path.join, path.resolve or fs.readFile), or This is usually unintentional and leads to all source files (including the public folder) to be deployed as part of the server code.
- very dynamic requires (like require('./' + foo)). This can slow down deployments or lead to failures when size limits are exceeded.
To resolve this, you can To resolve this, you can
- remove them if possible, or
- only use them in development, or
- make sure they are statically scoped to some subfolder: path.join(process.cwd(), 'data', bar), or - make sure they are statically scoped to some subfolder: path.join(process.cwd(), 'data', bar), or
- add ignore comments: path.join(/*turbopackIgnore: true*/ process.cwd(), bar) - only use them in development, or
- add ignore comments: path.join(/*turbopackIgnore: true*/ process.cwd(), bar), or
- remove them.
Import trace: Import trace:
Server Component: Server Component:
......
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