Home / File/ serve.ts — vite Source File

serve.ts — vite Source File

Architecture documentation for serve.ts, a typescript file in the vite codebase. 3 imports, 1 dependents.

File typescript ViteCore ConfigEngine 3 imports 1 dependents 1 functions

Entity Profile

Dependency Diagram

graph LR
  80095fa9_8d55_2d91_1178_2eda6e527933["serve.ts"]
  51e96894_3556_ed5c_1ede_97d449867adf["node:path"]
  80095fa9_8d55_2d91_1178_2eda6e527933 --> 51e96894_3556_ed5c_1ede_97d449867adf
  c61c7da5_ab1b_2881_075e_127cc87cab93["kill-port"]
  80095fa9_8d55_2d91_1178_2eda6e527933 --> c61c7da5_ab1b_2881_075e_127cc87cab93
  d3fd5575_295b_d6be_24dd_62d277645dc9["~utils"]
  80095fa9_8d55_2d91_1178_2eda6e527933 --> d3fd5575_295b_d6be_24dd_62d277645dc9
  2521c391_6acf_ecb8_c307_40255b46902a["ssr-webworker.spec.ts"]
  2521c391_6acf_ecb8_c307_40255b46902a --> 80095fa9_8d55_2d91_1178_2eda6e527933
  style 80095fa9_8d55_2d91_1178_2eda6e527933 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

// this is automatically detected by playground/vitestSetup.ts and will replace
// the default e2e test serve behavior

import path from 'node:path'
import kill from 'kill-port'
import { ports, rootDir } from '~utils'

export const port = ports['ssr-webworker']

export async function serve(): Promise<{ close(): Promise<void> }> {
  await kill(port)

  // we build first, regardless of whether it's prod/build mode
  // because Vite doesn't support the concept of a "webworker server"
  const { build } = await import('vite')

  // worker build
  await build({
    root: rootDir,
    logLevel: 'silent',
    build: {
      target: 'esnext',
      ssr: 'src/entry-worker.jsx',
      outDir: 'dist/worker',
    },
  })

  const { createServer } = await import(path.resolve(rootDir, 'worker.js'))
  const { mf } = await createServer(port)

  return {
    // for test teardown
    async close() {
      await mf.dispose()
    },
  }
}

Domain

Subdomains

Functions

Dependencies

  • kill-port
  • node:path
  • ~utils

Frequently Asked Questions

What does serve.ts do?
serve.ts is a source file in the vite codebase, written in typescript. It belongs to the ViteCore domain, ConfigEngine subdomain.
What functions are defined in serve.ts?
serve.ts defines 1 function(s): serve.
What does serve.ts depend on?
serve.ts imports 3 module(s): kill-port, node:path, ~utils.
What files import serve.ts?
serve.ts is imported by 1 file(s): ssr-webworker.spec.ts.
Where is serve.ts in the architecture?
serve.ts is located at playground/ssr-webworker/__tests__/serve.ts (domain: ViteCore, subdomain: ConfigEngine, directory: playground/ssr-webworker/__tests__).

Analyze Your Own Codebase

Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.

Try Supermodel Free