Skip to content

Commit

Permalink
perf: avoid ssrTransform object allocation (#9706)
Browse files Browse the repository at this point in the history
  • Loading branch information
antfu committed Aug 16, 2022
1 parent 3a6ae47 commit 6e58d9d
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 6 deletions.
4 changes: 1 addition & 3 deletions packages/vite/src/node/server/index.ts
Expand Up @@ -340,9 +340,7 @@ export async function createServer(
moduleGraph,
resolvedUrls: null, // will be set on listen
ssrTransform(code: string, inMap: SourceMap | null, url: string) {
return ssrTransform(code, inMap, url, code, {
json: { stringify: server.config.json?.stringify }
})
return ssrTransform(code, inMap, url, code, server.config)
},
transformRequest(url, options) {
return transformRequest(url, server, options)
Expand Down
10 changes: 7 additions & 3 deletions packages/vite/src/node/server/transformRequest.ts
Expand Up @@ -259,9 +259,13 @@ async function loadAndTransform(
}

const result = ssr
? await ssrTransform(code, map as SourceMap, url, originalCode, {
json: { stringify: !!server.config.json?.stringify }
})
? await ssrTransform(
code,
map as SourceMap,
url,
originalCode,
server.config
)
: ({
code,
map,
Expand Down

0 comments on commit 6e58d9d

Please sign in to comment.