Skip to content
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

fix(ssr): fix sourcemap content (fixes #8657) #8997

Merged
merged 4 commits into from Jul 10, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion packages/vite/src/node/server/index.ts
Expand Up @@ -320,7 +320,7 @@ export async function createServer(
ws,
moduleGraph,
ssrTransform(code: string, inMap: SourceMap | null, url: string) {
return ssrTransform(code, inMap, url, {
return ssrTransform(code, inMap, url, code, {
json: { stringify: server.config.json?.stringify }
})
},
Expand Down
3 changes: 2 additions & 1 deletion packages/vite/src/node/server/transformRequest.ts
Expand Up @@ -235,6 +235,7 @@ async function loadAndTransform(
inMap: map,
ssr
})
const originalCode = code
if (
transformResult == null ||
(isObject(transformResult) && transformResult.code == null)
Expand All @@ -258,7 +259,7 @@ async function loadAndTransform(
}

const result = ssr
? await ssrTransform(code, map as SourceMap, url, {
? await ssrTransform(code, map as SourceMap, url, originalCode, {
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Instead of passing originalCode, we could always generate sourcemaps. But that will cost a lot if the file is large.

json: { stringify: !!server.config.json?.stringify }
})
: ({
Expand Down