Home / File/ env.ts — vite Source File

env.ts — vite Source File

Architecture documentation for env.ts, a typescript file in the vite codebase.

File typescript HMRClient HotRuntime 1 functions 1 classes

Entity Profile

Relationship Graph

Source Code

declare const __DEFINES__: Record<string, any>

const context = (() => {
  if (typeof globalThis !== 'undefined') {
    return globalThis
  } else if (typeof self !== 'undefined') {
    return self
  } else if (typeof window !== 'undefined') {
    return window
  } else {
    return Function('return this')()
  }
})()

// assign defines
const defines = __DEFINES__
Object.keys(defines).forEach((key) => {
  const segments = key.split('.')
  let target = context
  for (let i = 0; i < segments.length; i++) {
    const segment = segments[i]
    if (i === segments.length - 1) {
      target[segment] = defines[key]
    } else {
      target = target[segment] || (target[segment] = {})
    }
  }
})

Domain

Subdomains

Functions

Classes

Frequently Asked Questions

What does env.ts do?
env.ts is a source file in the vite codebase, written in typescript. It belongs to the HMRClient domain, HotRuntime subdomain.
What functions are defined in env.ts?
env.ts defines 1 function(s): context.
Where is env.ts in the architecture?
env.ts is located at packages/vite/src/client/env.ts (domain: HMRClient, subdomain: HotRuntime, directory: packages/vite/src/client).

Analyze Your Own Codebase

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

Try Supermodel Free