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 {
async fn title(&self) -> Result<StyledString> {
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>> {
let stack = vec![
StyledString::Text(rcstr!(
"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."
)),
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!("- remove them if possible, or")),
StyledString::Text(rcstr!("- only use them in development, or")),
StyledString::Line(vec![
StyledString::Text(rcstr!(
"- make sure they are statically scoped to some subfolder: "
......@@ -514,12 +504,15 @@ impl Issue for ForbiddenTracedFileIssue {
StyledString::Code(rcstr!("path.join(process.cwd(), 'data', bar)")),
StyledString::Text(rcstr!(", or")),
]),
StyledString::Text(rcstr!("- only use them in development, or")),
StyledString::Line(vec![
StyledString::Text(rcstr!("- add ignore comments: ")),
StyledString::Code(rcstr!(
"path.join(/*turbopackIgnore: true*/ process.cwd(), bar)"
)),
StyledString::Text(rcstr!(", or")),
]),
StyledString::Text(rcstr!("- remove them.")),
];
Ok(Some(StyledString::Stack(stack)))
}
......
......@@ -24,7 +24,7 @@ import stripAnsi from 'strip-ansi'
expect(stripAnsi(output)).toMatchInlineSnapshot(`
"Turbopack build encountered 1 warnings:
./app/join-cwd.js:4:10
Encountered unexpected file in NFT list
Dynamic filesystem access causes tracing of the whole project
2 |
3 | export default function (f) {
> 4 | return path.join(process.cwd(), f)
......@@ -32,14 +32,14 @@ import stripAnsi from 'strip-ansi'
5 | }
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:
- filesystem operations (like path.join, path.resolve or fs.readFile), or
- very dynamic requires (like require('./' + foo)).
Static analysis determined that this filesystem access causes the whole project to be traced and included in the output.
This is usually unintentional and leads to all source files (including the public folder) to be deployed as part of the server code.
This can slow down deployments or lead to failures when size limits are exceeded.
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
- 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:
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