Skip to content

Commit

Permalink
feat: expose createServerModuleRunnerTransport (#18730)
Browse files Browse the repository at this point in the history
  • Loading branch information
sheremet-va authored Jan 23, 2025
1 parent 3766004 commit 8c24ee4
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 1 deletion.
1 change: 1 addition & 0 deletions packages/vite/index.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ const disallowedVariables = [
// can be exposed, but doesn't make sense as it's Environment API related
'createServerHotChannel',
'createServerModuleRunner',
'createServerModuleRunnerTransport',
'isRunnableDevEnvironment',
]
disallowedVariables.forEach((name) => {
Expand Down
6 changes: 6 additions & 0 deletions packages/vite/rollup.dts.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,8 @@ function patchTypes(): Plugin {
renderChunk(code, chunk) {
if (
chunk.fileName.startsWith('module-runner') ||
// index and moduleRunner have a common chunk "moduleRunnerTransport"
chunk.fileName.startsWith('moduleRunnerTransport') ||
chunk.fileName.startsWith('types.d-')
) {
validateRunnerChunk.call(this, chunk)
Expand All @@ -117,6 +119,8 @@ function validateRunnerChunk(this: PluginContext, chunk: RenderedChunk) {
if (
!id.startsWith('./') &&
!id.startsWith('../') &&
// index and moduleRunner have a common chunk "moduleRunnerTransport"
!id.startsWith('moduleRunnerTransport.d') &&
!id.startsWith('types.d')
) {
this.warn(
Expand All @@ -139,6 +143,8 @@ function validateChunkImports(this: PluginContext, chunk: RenderedChunk) {
!id.startsWith('node:') &&
!id.startsWith('types.d') &&
!id.startsWith('vite/') &&
// index and moduleRunner have a common chunk "moduleRunnerTransport"
!id.startsWith('moduleRunnerTransport.d') &&
!deps.includes(id) &&
!deps.some((name) => id.startsWith(name + '/'))
) {
Expand Down
8 changes: 7 additions & 1 deletion packages/vite/src/node/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,10 @@ export { runnerImport } from './ssr/runnerImport'
export { BuildEnvironment } from './build'

export { fetchModule, type FetchModuleOptions } from './ssr/fetchModule'
export { createServerModuleRunner } from './ssr/runtime/serverModuleRunner'
export {
createServerModuleRunner,
createServerModuleRunnerTransport,
} from './ssr/runtime/serverModuleRunner'
export { createServerHotChannel } from './server/hmr'
export { ssrTransform as moduleRunnerTransform } from './ssr/ssrTransform'
export type { ModuleRunnerTransformOptions } from './ssr/ssrTransform'
Expand Down Expand Up @@ -170,6 +173,9 @@ export type {
HotChannel,
ServerHotChannel,
HotChannelClient,
NormalizedHotChannel,
NormalizedHotChannelClient,
NormalizedServerHotChannel,
} from './server/hmr'

export type { FetchFunction, FetchResult } from 'vite/module-runner'
Expand Down

0 comments on commit 8c24ee4

Please sign in to comment.