Skip to content

Commit

Permalink
feat: expose ssrTransform to server (#5983)
Browse files Browse the repository at this point in the history
Co-authored-by: patak <matias.capeletto@gmail.com>
  • Loading branch information
antfu and patak-dev committed Dec 7, 2021
1 parent 49f28e2 commit 8184feb
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions packages/vite/src/node/server/index.ts
Expand Up @@ -55,13 +55,15 @@ import {
rebindErrorStacktrace,
ssrRewriteStacktrace
} from '../ssr/ssrStacktrace'
import { ssrTransform } from '../ssr/ssrTransform'
import { createMissingImporterRegisterFn } from '../optimizer/registerMissing'
import { resolveHostname } from '../utils'
import { searchForWorkspaceRoot } from './searchRoot'
import { CLIENT_DIR } from '../constants'
import { printCommonServerUrls } from '../logger'
import { performance } from 'perf_hooks'
import { invalidatePackageData } from '../packages'
import { SourceMap } from 'rollup'

export { searchForWorkspaceRoot } from './searchRoot'

Expand Down Expand Up @@ -206,6 +208,15 @@ export interface ViteDevServer {
options?: EsbuildTransformOptions,
inMap?: object
): Promise<ESBuildTransformResult>
/**
* Transform module code into SSR format.
* @experimental
*/
ssrTransform(
code: string,
inMap: SourceMap | null,
url: string
): Promise<TransformResult | null>
/**
* Load a given URL as an instantiated module for SSR.
*/
Expand Down Expand Up @@ -337,6 +348,7 @@ export async function createServer(
pluginContainer: container,
ws,
moduleGraph,
ssrTransform,
transformWithEsbuild,
transformRequest(url, options) {
return transformRequest(url, server, options)
Expand Down

0 comments on commit 8184feb

Please sign in to comment.