Home / Function/ serve() — vite Function Reference

serve() — vite Function Reference

Architecture documentation for the serve() function in serve.ts from the vite codebase.

Entity Profile

Dependency Diagram

graph TD
  00fe40e3_1255_a1e2_50c9_9a6218538c8c["serve()"]
  80095fa9_8d55_2d91_1178_2eda6e527933["serve.ts"]
  00fe40e3_1255_a1e2_50c9_9a6218538c8c -->|defined in| 80095fa9_8d55_2d91_1178_2eda6e527933
  style 00fe40e3_1255_a1e2_50c9_9a6218538c8c fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

playground/ssr-webworker/__tests__/serve.ts lines 10–37

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

Frequently Asked Questions

What does serve() do?
serve() is a function in the vite codebase, defined in playground/ssr-webworker/__tests__/serve.ts.
Where is serve() defined?
serve() is defined in playground/ssr-webworker/__tests__/serve.ts at line 10.

Analyze Your Own Codebase

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

Try Supermodel Free