forked from vercel/next.js
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add source map support for server components/actions in the browser (v…
…ercel#71042) This PR adds support for showing the original server sources of server components and server actions in the browser's developer tools. To accomplish that, we're building on top of vercel#69190, vercel#70563, and vercel#70564, in which we prepared the proper generation of the source maps. This PR completes the feature, by wiring up `findSourceMapURL` (see facebook/react#30741) with a new dev server middleware that serves those source map files to the browser. Another change we had to make is disabling the dead-code elimination of server actions in client bundles (see vercel#70103), but only in development mode. This optimization is primarily intended for production bundles, so the change should not pose a problem. With that, it's now possible to jump directly into the server sources from the browser's dev tools, e.g. for component stacks of server logs that are replayed in the browser, or when inspecting server action props in the React DevTools.
- Loading branch information
1 parent
a48680d
commit 4907044
Showing
44 changed files
with
662 additions
and
377 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,16 @@ | ||
// TODO: Will be implemented later. | ||
export function findSourceMapURL(_filename: string): string | null { | ||
return null | ||
} | ||
const basePath = process.env.__NEXT_ROUTER_BASEPATH || '' | ||
const pathname = `${basePath}/__nextjs_source-map` | ||
|
||
export const findSourceMapURL = | ||
process.env.NODE_ENV === 'development' | ||
? function findSourceMapURL(filename: string): string | null { | ||
const url = new URL(pathname, document.location.origin) | ||
|
||
url.searchParams.set( | ||
'filename', | ||
filename.replace(new RegExp(`^${document.location.origin}`), '') | ||
) | ||
|
||
return url.href | ||
} | ||
: undefined |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
...es/next/src/client/components/react-dev-overlay/internal/container/RuntimeError/index.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
Oops, something went wrong.