vite icon indicating copy to clipboard operation
vite copied to clipboard

Only show error backtrace when `VITE_BACKTRACE=1`

Open typed-sigterm opened this issue 6 months ago • 0 comments

Description

Just moved a file... the terminal at the bottom of VS Code suddenly exploded with a long error:

10:31:57 [vite] Internal server error: Failed to resolve import "../utility" from "src/providers/auth.ts". Does the file exist?
  Plugin: vite:import-analysis
  File: .../src/providers/auth.ts:2:21
  1  |  import { supa } from "../utility";
     |                        ^
  2  |  const authProvider = {
  3  |    async login({ email, password, providerName }) {
      at TransformPluginContext._formatLog (file:///.../node_modules/vite/dist/node/chunks/dep-DBxKXgDP.js:42499:41)
      at TransformPluginContext.error (file:///.../node_modules/vite/dist/node/chunks/dep-DBxKXgDP.js:42496:16)
      at normalizeUrl (file:///.../node_modules/vite/dist/node/chunks/dep-DBxKXgDP.js:40475:23)
      at process.processTicksAndRejections (node:internal/process/task_queues:105:5)
      at async file:///.../node_modules/vite/dist/node/chunks/dep-DBxKXgDP.js:40594:37
      at async Promise.all (index 0)
      at async TransformPluginContext.transform (file:///.../node_modules/vite/dist/node/chunks/dep-DBxKXgDP.js:40521:7)
      at async EnvironmentPluginContainer.transform (file:///.../node_modules/vite/dist/node/chunks/dep-DBxKXgDP.js:42294:18)
      at async loadAndTransform (file:///.../node_modules/vite/dist/node/chunks/dep-DBxKXgDP.js:35735:27)   
      at async viteTransformMiddleware (file:///.../node_modules/vite/dist/node/chunks/dep-DBxKXgDP.js:37250:24)

It's filled with the most secondary information, while the most important information needs to be unfolded to be seen.

Suggested solution

Like rust:

thread 'main' panicked at src/main.rs:2:5:
some error message...
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
10:31:57 [vite] Internal server error: Failed to resolve import "../utility" from "src/providers/auth.ts". Does the file exist?
  Note: run with `VITE_BACKTRACE=1` environment variable to display a backtrace

Alternative

No response

Additional context

No response

Validations

typed-sigterm avatar May 17 '25 02:05 typed-sigterm