Skip to content

Vite module runner stacktrace on first line is incorrect #19627

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
7 tasks done
hi-ogawa opened this issue Mar 12, 2025 · 0 comments
Open
7 tasks done

Vite module runner stacktrace on first line is incorrect #19627

hi-ogawa opened this issue Mar 12, 2025 · 0 comments

Comments

@hi-ogawa
Copy link
Collaborator

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

hi-ogawa added a commit to hi-ogawa/vite that referenced this issue Mar 12, 2025
hi-ogawa added a commit to hi-ogawa/vite that referenced this issue Apr 10, 2025
wip: workaround double createRequire

chore: enable back pnpm override

fix: fix duplicate createRequire

chore: fix overrides

ci: trigger preview

Revert "ci: trigger preview"

This reverts commit 6fb3890.

chore: oxc-transform 0.57.0

test: update test and note vitejs#19627

test: test ssrTransform deps
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant