Home / File/ index.ts — vite Source File

index.ts — vite Source File

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

File typescript ViteCore ConfigEngine 4 imports 1 dependents 1 functions

Entity Profile

Dependency Diagram

graph LR
  49374947_ff6e_87cb_13b2_fec34d5712bc["index.ts"]
  2f328851_91ee_fb05_63f0_4f466b9d6250["index.ts"]
  49374947_ff6e_87cb_13b2_fec34d5712bc --> 2f328851_91ee_fb05_63f0_4f466b9d6250
  e58f359e_e088_1368_10dc_00e9a8ae8bc3["DepOptimizationConfig"]
  49374947_ff6e_87cb_13b2_fec34d5712bc --> e58f359e_e088_1368_10dc_00e9a8ae8bc3
  031bc221_67a8_c579_f2bf_bb30a08beeb2["utils.ts"]
  49374947_ff6e_87cb_13b2_fec34d5712bc --> 031bc221_67a8_c579_f2bf_bb30a08beeb2
  50c942bf_5ddd_ac2c_f4f6_571d569b7215["mergeWithDefaults"]
  49374947_ff6e_87cb_13b2_fec34d5712bc --> 50c942bf_5ddd_ac2c_f4f6_571d569b7215
  7da774f9_eca5_d54e_6e01_6bee7d460a2b["config.ts"]
  7da774f9_eca5_d54e_6e01_6bee7d460a2b --> 49374947_ff6e_87cb_13b2_fec34d5712bc
  style 49374947_ff6e_87cb_13b2_fec34d5712bc fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

import type { DepOptimizationConfig } from '../optimizer'
import { mergeWithDefaults } from '../utils'

export type SSRTarget = 'node' | 'webworker'

export type SsrDepOptimizationConfig = DepOptimizationConfig

export interface SSROptions {
  noExternal?: string | RegExp | (string | RegExp)[] | true
  external?: string[] | true

  /**
   * Define the target for the ssr build. The browser field in package.json
   * is ignored for node but used if webworker is the target
   * This option will be removed in a future major version
   * @default 'node'
   */
  target?: SSRTarget

  /**
   * Control over which dependencies are optimized during SSR and esbuild options
   * During build:
   *   no external CJS dependencies are optimized by default
   * During dev:
   *   explicit no external CJS dependencies are optimized by default
   * @experimental
   */
  optimizeDeps?: SsrDepOptimizationConfig

  resolve?: {
    /**
     * Conditions that are used in the plugin pipeline. The default value is the root config's `resolve.conditions`.
     *
     * Use this to override the default ssr conditions for the ssr build.
     *
     * @default rootConfig.resolve.conditions
     */
    conditions?: string[]

    /**
     * Conditions that are used during ssr import (including `ssrLoadModule`) of externalized dependencies.
     *
     * @default ['node', 'module-sync']
     */
    externalConditions?: string[]

    mainFields?: string[]
  }
}

export interface ResolvedSSROptions extends SSROptions {
  target: SSRTarget
  optimizeDeps: SsrDepOptimizationConfig
}

const _ssrConfigDefaults = Object.freeze({
  // noExternal
  // external
  target: 'node',
  optimizeDeps: {},
  // resolve
} satisfies SSROptions)
export const ssrConfigDefaults: Readonly<Partial<SSROptions>> =
  _ssrConfigDefaults

export function resolveSSROptions(
  ssr: SSROptions | undefined,
  preserveSymlinks: boolean,
): ResolvedSSROptions {
  const defaults = mergeWithDefaults(_ssrConfigDefaults, {
    optimizeDeps: { esbuildOptions: { preserveSymlinks } },
  } satisfies SSROptions)
  return mergeWithDefaults(defaults, ssr ?? {})
}

Domain

Subdomains

Frequently Asked Questions

What does index.ts do?
index.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 index.ts?
index.ts defines 1 function(s): resolveSSROptions.
What does index.ts depend on?
index.ts imports 4 module(s): DepOptimizationConfig, index.ts, mergeWithDefaults, utils.ts.
What files import index.ts?
index.ts is imported by 1 file(s): config.ts.
Where is index.ts in the architecture?
index.ts is located at packages/vite/src/node/ssr/index.ts (domain: ViteCore, subdomain: ConfigEngine, directory: packages/vite/src/node/ssr).

Analyze Your Own Codebase

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

Try Supermodel Free