Unverified Commit 69d0e608 authored by Jiachi Liu's avatar Jiachi Liu Committed by GitHub

Passing down original sourcemap for flight client loader (#40508)

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">
parent a4ff0412
...@@ -16,12 +16,14 @@ function containsPath(parent: string, child: string) { ...@@ -16,12 +16,14 @@ function containsPath(parent: string, child: string) {
export default async function transformSource( export default async function transformSource(
this: any, this: any,
source: string source: string,
): Promise<string> { map: any
) {
if (typeof source !== 'string') { if (typeof source !== 'string') {
throw new Error('Expected source to have been transformed to a 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 appDir = path.join(this.rootContext, 'app')
const isUnderAppDir = containsPath(appDir, this.resourcePath) const isUnderAppDir = containsPath(appDir, this.resourcePath)
const filename = path.basename(this.resourcePath) const filename = path.basename(this.resourcePath)
...@@ -50,5 +52,7 @@ export default async function transformSource( ...@@ -50,5 +52,7 @@ export default async function transformSource(
const { createProxy } = require("next/dist/build/webpack/loaders/next-flight-client-loader/module-proxy")\n const { createProxy } = require("next/dist/build/webpack/loaders/next-flight-client-loader/module-proxy")\n
module.exports = createProxy(${JSON.stringify(this.resourcePath)}) module.exports = createProxy(${JSON.stringify(this.resourcePath)})
` `
return output // Pass empty sourcemap
callback(null, output, map)
return
} }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment