Home / File/ test-stacktrace.js — vite Source File

test-stacktrace.js — vite Source File

Architecture documentation for test-stacktrace.js, a javascript file in the vite codebase. 2 imports, 0 dependents.

File javascript 2 imports

Entity Profile

Dependency Diagram

graph LR
  25200b8e_15c8_13d6_87bc_d322eed7a619["test-stacktrace.js"]
  51e96894_3556_ed5c_1ede_97d449867adf["node:path"]
  25200b8e_15c8_13d6_87bc_d322eed7a619 --> 51e96894_3556_ed5c_1ede_97d449867adf
  54c37fea_4fe7_2693_71cb_1276b77f55f9["vite"]
  25200b8e_15c8_13d6_87bc_d322eed7a619 --> 54c37fea_4fe7_2693_71cb_1276b77f55f9
  style 25200b8e_15c8_13d6_87bc_d322eed7a619 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

import path from 'node:path'
import { createServer } from 'vite'

const isSourceMapEnabled = process.argv[2] === 'true'
const ext = process.argv[3]
process.setSourceMapsEnabled(isSourceMapEnabled)
console.log('# sourcemaps enabled:', isSourceMapEnabled)
console.log('# source file extension:', ext)

const isTest = process.env.VITEST

const vite = await createServer({
  root: import.meta.dirname,
  logLevel: isTest ? 'error' : 'info',
  server: {
    middlewareMode: true,
    ws: false,
  },
  appType: 'custom',
})

const abs1 = await vite.ssrLoadModule(`/src/error-${ext}.${ext}`)
const abs2 = await vite.ssrLoadModule(
  path.resolve(import.meta.dirname, `./src/error-${ext}.${ext}`),
)
const relative = await vite.ssrLoadModule(`./src/error-${ext}.${ext}`)

for (const mod of [abs1, abs2, relative]) {
  try {
    mod.error()
  } catch (e) {
    // this should not be called
    // when sourcemap support for `new Function` is supported and sourcemap is enabled
    // because the stacktrace is already rewritten by Node.js
    if (!isSourceMapEnabled) {
      vite.ssrFixStacktrace(e)
    }
    console.log(e)
  }
}

await vite.close()

Dependencies

  • node:path
  • vite

Frequently Asked Questions

What does test-stacktrace.js do?
test-stacktrace.js is a source file in the vite codebase, written in javascript.
What does test-stacktrace.js depend on?
test-stacktrace.js imports 2 module(s): node:path, vite.
Where is test-stacktrace.js in the architecture?
test-stacktrace.js is located at playground/ssr-html/test-stacktrace.js (directory: playground/ssr-html).

Analyze Your Own Codebase

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

Try Supermodel Free