Skip to content

Commit

Permalink
Passing down original sourcemap for flight client loader (#40508)
Browse files Browse the repository at this point in the history
Consume the original sourcemap in flight client loader if there's any, to avoid source map is generated based on the module proxy which make debugging hard

Testing with adding `debugger` in layout router, screenshot:

<img width="400" alt="image" src="https://user-images.githubusercontent.com/4800338/189866388-adb1aba5-496b-4b8d-8098-ec04d6f1914a.png">
  • Loading branch information
huozhi committed Sep 13, 2022
1 parent a4ff041 commit 69d0e60
Showing 1 changed file with 7 additions and 3 deletions.
Expand Up @@ -16,12 +16,14 @@ function containsPath(parent: string, child: string) {

export default async function transformSource(
this: any,
source: string
): Promise<string> {
source: string,
map: any
) {
if (typeof source !== 'string') {
throw new Error('Expected source to have been transformed to a string.')
}

const callback = this.async()
const appDir = path.join(this.rootContext, 'app')
const isUnderAppDir = containsPath(appDir, this.resourcePath)
const filename = path.basename(this.resourcePath)
Expand Down Expand Up @@ -50,5 +52,7 @@ export default async function transformSource(
const { createProxy } = require("next/dist/build/webpack/loaders/next-flight-client-loader/module-proxy")\n
module.exports = createProxy(${JSON.stringify(this.resourcePath)})
`
return output
// Pass empty sourcemap
callback(null, output, map)
return
}

0 comments on commit 69d0e60

Please sign in to comment.