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

feat: expose ssrTransform to server #5983

Merged
merged 4 commits into from
Dec 7, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions packages/vite/src/node/server/index.ts
Original file line number Diff line number Diff line change
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.
patak-dev marked this conversation as resolved.
Show resolved Hide resolved
* @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