AI & Agent Dev Bug Sandbox logo
AI & Agent Dev Bug Sandbox
Back to Radar

Turbopack: Module Not Found Warning For Styled-Jsx/Style.Js On Pages Router With Pnpm

Next.js 16.x with Turbopack and pnpm emits a false 'Module not found' warning for styled-jsx/style.js during Pages Router builds, even though the build succeeds and the file is traced.

mediumConfidence 85%Next.jsAffected V16.2.12Affected V16.3.2Affected V16.3.5Affected V16.3.8

Origin Analysis

Turbopack's pages server import map marks `styled-jsx/style` as `ExternalTraced::Traced`, causing the tracer to resolve it from the tracing root (`_`) instead of from `next`'s own dependency context; pnpm's strict node_modules layout hides styled-jsx from the project root, so resolution fails and emits the warning.
1. Create package.json with next@16.3.8, react@19.3.0, react-dom@19.3.0. 2. Create pages/index.js and pages/_app.js containing <style jsx global>{`:root { --x: 1 }`}</style>. 3. Run pnpm install. 4. Run pnpm build. Observe warning.

Fixing Code Block

"styled-jsx/style" => request.into_external(ExternalType::CommonJs).with_target("styled-jsx/style.js").untraced(),
Replace `.traced()` with `.untraced()` for the styled-jsx/style external entry in `crates/next-core/src/next_import_map.rs`. This prevents Turbopack from attempting to resolve the external from the project tracing root, eliminating the false warning. The asset is still included via `require_hook_modules` tracing from the `next` package, so runtime behavior remains unchanged.

Edge Case Audit

Marking the external untraced means Turbopack will not include it in the initial trace; however, the secondary `require_hook_modules` tracing currently covers it. If that secondary tracing is removed or altered in a future refactor, styled-jsx could be omitted from serverless/edge output. Rollback by reverting to `.traced()`. This change is safe for all current 16.x versions but should be tested with npm, pnpm, and yarn.

Ecosystem Topology