Skip to content

Vite module runner stacktrace on first line is incorrect #19627

Description

@hi-ogawa

Describe the bug

Yet another very minor stack trace issue. It's likely due to "use strict" appended on runtime side evaluation. Recording it here so I have a place to point to for one test failure on oxc module runner vitejs#85.

  • repro3.js
throw new Error('__TEST__')
  • vite2.js
import { createServerModuleRunner } from "vite";
import { createServer } from "vite";

async function main() {
  const server = await createServer({ configFile: false})
  const runner = createServerModuleRunner(server.environments.ssr, {
    // same issues for any interceptor
    sourcemapInterceptor: "prepareStackTrace"
  });
  await runner.import(process.argv[2]);
}

main()

On Node:

$ node repro3.js
file:///dir/repro3.js:1
throw new Error('__TEST__')
      ^

Error: __TEST__
    at file:///dir/repro3.js:1:7

On Vite:

$ node vite2.js repro3.js
[vite] connected.
/dir/repro3.js:3  <--  (probably rewriting this is not supported or node's bug)
"use strict";throw new Error('__TEST__')
                   ^

Error: __TEST__
    at /dir/repro3.js:1:18  <-- ❓❓

Reproduction

https://stackblitz.com/github/hi-ogawa/reproductions/tree/main/oxc-source-map-call-stack-column?file=README.md

Steps to reproduce

Download stackblitz and test it locally

System Info

System:
    OS: Linux 5.0 undefined
    CPU: (8) x64 Intel(R) Core(TM) i9-9880H CPU @ 2.30GHz
    Memory: 0 Bytes / 0 Bytes
    Shell: 1.0 - /bin/jsh
  Binaries:
    Node: 18.20.3 - /usr/local/bin/node
    Yarn: 1.22.19 - /usr/local/bin/yarn
    npm: 10.2.3 - /usr/local/bin/npm
    pnpm: 8.15.6 - /usr/local/bin/pnpm
  npmPackages:
    vite: ^6.2.1 => 6.2.1

Used Package Manager

npm

Logs

No response

Validations

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions