Home / File/ index.ts — vite Source File

index.ts — vite Source File

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

File typescript PluginSystem LegacySupport 12 imports 18 functions

Entity Profile

Dependency Diagram

graph LR
  9776ecb6_00c0_b3b9_b3f7_177fedabeacc["index.ts"]
  4f9da5f4_2720_8f92_92bb_2635a921fc15["types.ts"]
  9776ecb6_00c0_b3b9_b3f7_177fedabeacc --> 4f9da5f4_2720_8f92_92bb_2635a921fc15
  86772873_9e89_0694_fae4_6dda658eed12["Options"]
  9776ecb6_00c0_b3b9_b3f7_177fedabeacc --> 86772873_9e89_0694_fae4_6dda658eed12
  ce349c09_3cd5_548b_1a03_c4108351206c["snippets.ts"]
  9776ecb6_00c0_b3b9_b3f7_177fedabeacc --> ce349c09_3cd5_548b_1a03_c4108351206c
  51e96894_3556_ed5c_1ede_97d449867adf["node:path"]
  9776ecb6_00c0_b3b9_b3f7_177fedabeacc --> 51e96894_3556_ed5c_1ede_97d449867adf
  9e678916_202a_edec_9e08_b4e120d4b153["node:crypto"]
  9776ecb6_00c0_b3b9_b3f7_177fedabeacc --> 9e678916_202a_edec_9e08_b4e120d4b153
  ad382781_051b_4f17_29a3_3e882464e6c0["node:module"]
  9776ecb6_00c0_b3b9_b3f7_177fedabeacc --> ad382781_051b_4f17_29a3_3e882464e6c0
  6feed3e8_55b8_cce7_b5ef_e40b872585f7["node:url"]
  9776ecb6_00c0_b3b9_b3f7_177fedabeacc --> 6feed3e8_55b8_cce7_b5ef_e40b872585f7
  54c37fea_4fe7_2693_71cb_1276b77f55f9["vite"]
  9776ecb6_00c0_b3b9_b3f7_177fedabeacc --> 54c37fea_4fe7_2693_71cb_1276b77f55f9
  ff79973e_f09f_1c6b_f6b5_d1707df47116["magic-string"]
  9776ecb6_00c0_b3b9_b3f7_177fedabeacc --> ff79973e_f09f_1c6b_f6b5_d1707df47116
  c370aa02_7baa_c793_3038_96be0f98bbaf["core"]
  9776ecb6_00c0_b3b9_b3f7_177fedabeacc --> c370aa02_7baa_c793_3038_96be0f98bbaf
  bff4f846_ab01_b5ba_74d4_c1608e434d2c["picocolors"]
  9776ecb6_00c0_b3b9_b3f7_177fedabeacc --> bff4f846_ab01_b5ba_74d4_c1608e434d2c
  eacaf3e3_8cb4_50a1_1d3d_33f478c0b929["browserslist"]
  9776ecb6_00c0_b3b9_b3f7_177fedabeacc --> eacaf3e3_8cb4_50a1_1d3d_33f478c0b929
  style 9776ecb6_00c0_b3b9_b3f7_177fedabeacc fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

import path from 'node:path'
import crypto from 'node:crypto'
import { createRequire } from 'node:module'
import { fileURLToPath } from 'node:url'
import { build, normalizePath } from 'vite'
import MagicString from 'magic-string'
import type {
  BuildOptions,
  HtmlTagDescriptor,
  Plugin,
  ResolvedConfig,
  Rollup,
} from 'vite'
import type {
  PluginItem as BabelPlugin,
  types as BabelTypes,
} from '@babel/core'
import colors from 'picocolors'
import browserslist from 'browserslist'
import type { Options } from './types'
import {
  detectModernBrowserCode,
  dynamicFallbackInlineCode,
  legacyEntryId,
  legacyPolyfillId,
  modernChunkLegacyGuard,
  safari10NoModuleFix,
  systemJSInlineCode,
} from './snippets'

// lazy load babel since it's not used during dev
let babel: Promise<typeof import('@babel/core')> | undefined
async function loadBabel() {
  return (babel ??= import('@babel/core'))
}

// The requested module 'browserslist' is a CommonJS module
// which may not support all module.exports as named exports
const { loadConfig: browserslistLoadConfig } = browserslist

// Duplicated from build.ts in Vite Core, at least while the feature is experimental
// We should later expose this helper for other plugins to use
function toOutputFilePathInHtml(
  filename: string,
  type: 'asset' | 'public',
  hostId: string,
  hostType: 'js' | 'css' | 'html',
  config: ResolvedConfig,
  toRelative: (filename: string, importer: string) => string,
): string {
  const { renderBuiltUrl } = config.experimental
  let relative = config.base === '' || config.base === './'
  if (renderBuiltUrl) {
    const result = renderBuiltUrl(filename, {
      hostId,
      hostType,
      type,
      ssr: !!config.build.ssr,
    })
    if (typeof result === 'object') {
// ... (1010 more lines)

Domain

Subdomains

Dependencies

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 PluginSystem domain, LegacySupport subdomain.
What functions are defined in index.ts?
index.ts defines 18 function(s): buildPolyfillChunk, cspHashes, detectPolyfills, getBaseInHTML, isLegacyBundle, isLegacyChunk, joinUrlSegments, loadBabel, polyfillsPlugin, prependModenChunkLegacyGuardPlugin, and 8 more.
What does index.ts depend on?
index.ts imports 12 module(s): Options, browserslist, core, magic-string, node:crypto, node:module, node:path, node:url, and 4 more.
Where is index.ts in the architecture?
index.ts is located at packages/plugin-legacy/src/index.ts (domain: PluginSystem, subdomain: LegacySupport, directory: packages/plugin-legacy/src).

Analyze Your Own Codebase

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

Try Supermodel Free