Home / File/ main.js — vite Source File

main.js — vite Source File

Architecture documentation for main.js, a javascript file in the vite codebase. 3 imports, 0 dependents.

File javascript ViteCore DevServer 3 imports 3 functions

Entity Profile

Dependency Diagram

graph LR
  fb39a84e_1c38_f252_04f4_7b1e2195916f["main.js"]
  fa2dc97c_2e99_2708_86f6_eb769b465bec["style.css"]
  fb39a84e_1c38_f252_04f4_7b1e2195916f --> fa2dc97c_2e99_2708_86f6_eb769b465bec
  c21a540c_b780_b84d_d693_88011ee2df93["./vite.svg"]
  fb39a84e_1c38_f252_04f4_7b1e2195916f --> c21a540c_b780_b84d_d693_88011ee2df93
  9cb939e2_7ee9_2e76_930c_960b45f1e5ad["./worker?worker"]
  fb39a84e_1c38_f252_04f4_7b1e2195916f --> 9cb939e2_7ee9_2e76_930c_960b45f1e5ad
  style fb39a84e_1c38_f252_04f4_7b1e2195916f fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

import './style.css'
import viteSvgPath from './vite.svg'
import MyWorker from './worker?worker'

async function run() {
  await import('./custom0.js')
  await import('./custom1.js')
  await import('./custom2.js')
  const { fn } = await import('./async.js')
  fn()
}

run()

let isLegacy

// make sure that branching works despite esbuild's constant folding (#1999)
if (import.meta.env.LEGACY) {
  if (import.meta.env.LEGACY === true) isLegacy = true
} else {
  if (import.meta.env.LEGACY === false) isLegacy = false
}

text('#env', `is legacy: ${isLegacy}`)

const metaEnvObj = import.meta.env
text('#env-equal', import.meta.env.LEGACY === metaEnvObj.LEGACY)

// Iterators
text('#iterators', [...new Set(['hello'])].join(''))

// structuredClone is supported core.js v3.20.0+
text(
  '#features-after-corejs-3',
  JSON.stringify(structuredClone({ foo: 'foo' })),
)

// async generator
async function* asyncGenerator() {
  for (let i = 0; i < 3; i++) {
    await new Promise((resolve) => setTimeout(resolve, 10))
    yield i
  }
}
;(async () => {
  const result = []
  for await (const i of asyncGenerator()) {
    result.push(i)
  }
  text('#async-generator', JSON.stringify(result))
})()

// babel-helpers
// Using `String.raw` to inject `@babel/plugin-transform-template-literals`
// helpers.
text(
  '#babel-helpers',
  String.raw`exposed babel helpers: ${window._templateObject != null}`,
)

// dynamic chunk names
import('./immutable-chunk.js')
  .then(({ fn }) => fn())
  .then((assets) => {
    text('#assets', assets.join('\n'))
  })

// dynamic css
document
  .querySelector('#dynamic-css-button')
  .addEventListener('click', async () => {
    await import('./dynamic.css')
    text('#dynamic-css', 'dynamic import css')
  })

text('#asset-path', viteSvgPath)

function text(el, text) {
  document.querySelector(el).textContent = text
}

const worker = new MyWorker()
worker.postMessage('ping')
worker.addEventListener('message', (ev) => {
  text('.worker-message', JSON.stringify(ev.data))
})

Domain

Subdomains

Dependencies

Frequently Asked Questions

What does main.js do?
main.js is a source file in the vite codebase, written in javascript. It belongs to the ViteCore domain, DevServer subdomain.
What functions are defined in main.js?
main.js defines 3 function(s): asyncGenerator, run, text.
What does main.js depend on?
main.js imports 3 module(s): ./vite.svg, ./worker?worker, style.css.
Where is main.js in the architecture?
main.js is located at playground/legacy/main.js (domain: ViteCore, subdomain: DevServer, directory: playground/legacy).

Analyze Your Own Codebase

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

Try Supermodel Free