mirror of
https://github.com/hanzoai/next.js.git
synced 2026-10-30 14:46:38 +00:00
This should really be an error, but let's start with making it a warning the only missing piece will be somehow showing the line/col information of the offending reference, this is currently very hard to figure out <img width="1265" height="428" alt="Bildschirmfoto 2026-01-28 um 12 32 17" src="https://github.com/user-attachments/assets/80e48fa8-a021-4ca2-a966-26164c42b1dd" />
45 lines
1.5 KiB
TypeScript
45 lines
1.5 KiB
TypeScript
import { nextTestSetup } from 'e2e-utils'
|
|
|
|
// Only Turbopack prints these warnings
|
|
;(process.env.IS_TURBOPACK_TEST ? describe : describe.skip)(
|
|
'build-tracing-message',
|
|
() => {
|
|
const { next } = nextTestSetup({
|
|
files: __dirname,
|
|
skipStart: true,
|
|
})
|
|
|
|
it('should warn when tracing all files in the project', async () => {
|
|
const { exitCode } = await next.build()
|
|
expect(exitCode).toBe(0)
|
|
|
|
let output = next.cliOutput
|
|
.slice(
|
|
next.cliOutput.indexOf('Turbopack build encountered'),
|
|
next.cliOutput.indexOf('✓ Compiled successfully')
|
|
)
|
|
.trim()
|
|
|
|
expect(output).toMatchInlineSnapshot(`
|
|
"Turbopack build encountered 1 warnings:
|
|
./next.config.js
|
|
Encountered unexpected file in NFT list
|
|
A file was traced that 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)).
|
|
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)
|
|
|
|
Import trace:
|
|
Server Component:
|
|
./next.config.js
|
|
./app/join-cwd.js
|
|
./app/page.js"
|
|
`)
|
|
})
|
|
}
|
|
)
|