Skip to content

Commit

Permalink
feat: add experimental option to skip SSR transform (#11411)
Browse files Browse the repository at this point in the history
  • Loading branch information
cyco130 authored Jan 18, 2023
1 parent 00919bb commit e781ef3
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 7 deletions.
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

0 comments on commit e781ef3

Please sign in to comment.