Skip to content

Commit 246a087

Browse files
authoredAug 20, 2022
refactor: use server.ssrTransform (#9769)
1 parent 01857af commit 246a087

File tree

2 files changed

+10
-11
lines changed

2 files changed

+10
-11
lines changed
 

‎packages/vite/src/node/server/index.ts

+9-3
Original file line numberDiff line numberDiff line change
@@ -220,7 +220,8 @@ export interface ViteDevServer {
220220
ssrTransform(
221221
code: string,
222222
inMap: SourceMap | null,
223-
url: string
223+
url: string,
224+
originalCode?: string
224225
): Promise<TransformResult | null>
225226
/**
226227
* Load a given URL as an instantiated module for SSR.
@@ -339,8 +340,13 @@ export async function createServer(
339340
ws,
340341
moduleGraph,
341342
resolvedUrls: null, // will be set on listen
342-
ssrTransform(code: string, inMap: SourceMap | null, url: string) {
343-
return ssrTransform(code, inMap, url, code, server.config)
343+
ssrTransform(
344+
code: string,
345+
inMap: SourceMap | null,
346+
url: string,
347+
originalCode = code
348+
) {
349+
return ssrTransform(code, inMap, url, originalCode, server.config)
344350
},
345351
transformRequest(url, options) {
346352
return transformRequest(url, server, options)

‎packages/vite/src/node/server/transformRequest.ts

+1-8
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@ import {
1616
timeFrom
1717
} from '../utils'
1818
import { checkPublicFile } from '../plugins/asset'
19-
import { ssrTransform } from '../ssr/ssrTransform'
2019
import { getDepsOptimizer } from '../optimizer'
2120
import { injectSourcesContent } from './sourcemap'
2221
import { isFileServingAllowed } from './middlewares/static'
@@ -259,13 +258,7 @@ async function loadAndTransform(
259258
}
260259

261260
const result = ssr
262-
? await ssrTransform(
263-
code,
264-
map as SourceMap,
265-
url,
266-
originalCode,
267-
server.config
268-
)
261+
? await server.ssrTransform(code, map as SourceMap, url, originalCode)
269262
: ({
270263
code,
271264
map,

0 commit comments

Comments
 (0)
Please sign in to comment.