next.js
2a9e7560 - Turbopack: handle invalid RSC imports via importmap (#88146)

Commit
45 days ago
Turbopack: handle invalid RSC imports via importmap (#88146) We have two lines of defense: 1. crates/next-custom-transforms/src/transforms/react_server_components.rs validates ESM imports of server-only and client-only and throws an issue if something is wrong. Notably, `require('server-only')` isn't caught by this 2. additionally, we had an `BeforeResolvePlugin` for server-only, client-only and styled-jsx. We should probably get rid of the first one completely for consistency (it's brittle) https://github.com/vercel/next.js/blob/79040a318d29641eb3d96a5a47c92a5f8506e826/crates/next-custom-transforms/src/transforms/react_server_components.rs#L663-L674 This PR is about improving the second one: The error message isn't ideal yet, but better than before (note: no import trace): ``` ./bench/basic-app/app Invalid import 'server-only' cannot be imported from a Client Component module. It should only be used from a Server Component. The error was caused by importing 'bench/basic-app/app' ``` now <img width="708" height="386" alt="Bildschirmfoto 2026-01-07 um 17 21 59" src="https://github.com/user-attachments/assets/4d49eff3-4959-4b70-aa47-6f3c10c75588" />
Author
Parents
Loading