-
-
Notifications
You must be signed in to change notification settings - Fork 1.7k
fix(next): Ensure inline sourcemaps are generated for wrapped modules in Dev #18640
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: develop
Are you sure you want to change the base?
fix(next): Ensure inline sourcemaps are generated for wrapped modules in Dev #18640
Conversation
node-overhead report 🧳Note: This is a synthetic benchmark with a minimal express app and does not necessarily reflect the real-world performance impact in an application.
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
This PR fixes debugger breakpoint support in development mode for Next.js server-side code by generating inline sourcemaps in the wrapping loader. The changes ensure that IDEs like VSCode and Cursor can correctly map breakpoints back to the original source files for server components, API routes, middleware, and other server-side code.
- Adds
isDevparameter to wrapping loader options and passes it through webpack configuration - Modifies sourcemap generation to use inline sourcemaps in dev mode and hidden sourcemaps in production
- Implements absolute path preservation in dev mode sourcemaps to ensure correct breakpoint resolution
- Adds test coverage for both dev and production sourcemap behavior
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 4 comments.
| File | Description |
|---|---|
| packages/nextjs/src/config/webpack.ts | Adds isDev flag to staticWrappingLoaderOptions to pass development mode state to the wrapping loader |
| packages/nextjs/src/config/loaders/wrappingLoader.ts | Implements inline sourcemap generation for dev mode, including logic to preserve absolute paths and create identity mappings when no sourcemap exists |
| packages/nextjs/test/config/wrappingLoader.test.ts | Adds test coverage for inline sourcemap presence in dev mode and absence in production mode |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
This fixes breakpoints for editors like VSCode/Cursor in server-side code.
I have verified that breakpoints work in:
This only affects webpack, and doesn't change anything for prod builds.
closes #17088