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: add experimental option to skip SSR transform #11411

Merged
merged 1 commit into from
Jan 18, 2023
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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions packages/vite/src/node/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -292,6 +292,14 @@ export interface ExperimentalOptions {
* @default false
*/
hmrPartialAccept?: boolean
/**
* Skips SSR transform to make it easier to use Vite with Node ESM loaders.
* @warning Enabling this will break normal operation of Vite's SSR in development mode.
*
* @experimental
* @default false
*/
skipSsrTransform?: boolean
}

export interface LegacyOptions {
Expand Down
15 changes: 8 additions & 7 deletions packages/vite/src/node/server/transformRequest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -266,13 +266,14 @@ async function loadAndTransform(
}
}

const result = ssr
? await server.ssrTransform(code, map as SourceMap, url, originalCode)
: ({
code,
map,
etag: getEtag(code, { weak: true }),
} as TransformResult)
const result =
ssr && !server.config.experimental.skipSsrTransform
? await server.ssrTransform(code, map as SourceMap, url, originalCode)
: ({
code,
map,
etag: getEtag(code, { weak: true }),
} as TransformResult)

// Only cache the result if the module wasn't invalidated while it was
// being processed, so it is re-processed next time if it is stale
Expand Down