silverwolf-x/project / packages /next /src /client /app-find-source-map-url.ts
silverwolf-x's picture
download
raw
1.22 kB
const basePath = process.env.__NEXT_ROUTER_BASEPATH || ''
const pathname = `${basePath}/__nextjs_source-map`
export const findSourceMapURL =
// Source maps are only served by the dev server.
process.env.__NEXT_DEV_SERVER
? function findSourceMapURL(filename: string): string | null {
if (filename === '') {
return null
}
if (
filename.startsWith(document.location.origin) &&
filename.includes('/_next/static')
) {
// This is a request for a client chunk. This can only happen when
// using Turbopack. In this case, since we control how those source
// maps are generated, we can safely assume that the sourceMappingURL
// is relative to the filename, with an added `.map` extension. The
// browser can just request this file, and it gets served through the
// normal dev server, without the need to route this through
// the `/__nextjs_source-map` dev middleware.
return `${filename}.map`
}
const url = new URL(pathname, document.location.origin)
url.searchParams.set('filename', filename)
return url.href
}
: undefined

Xet Storage Details

Size:
1.22 kB
·
Xet hash:
2bb371da32e4da433e0dd1c048388291f67a831970b91498a49eb1822a36b98c

Xet efficiently stores files, intelligently splitting them into unique chunks and accelerating uploads and downloads. More info.