Skip to content
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

Vite chokes outputting sourcemaps for modules with query parameters when there are certain kinds of plugins outputting sourcemaps from transform #11860

Closed
7 tasks done
segevfiner opened this issue Jan 31, 2023 · 2 comments

Comments

@segevfiner
Copy link
Contributor

segevfiner commented Jan 31, 2023

Describe the bug

Using @rollup/plugin-replace with a web worker imported using ?worker causes sourcemaps to break.

Note that transform callbacks are allowed to return source maps with sources & sourcesContent not set correctly, e.g. [null], & rollup is supposed to correct the other fields, only really looking at mappings, names AFAIK.

See https://rollupjs.org/plugin-development/#source-code-transformations

Originally reported here, but pinpointed to Vite:

cc @YossiSaadi

Reproduction

https://github.com/segevfiner/vite-worker-sourcemaps-bug

Steps to reproduce

  1. Run pnpm install & pnpm dev.
  2. The sourcemaps for worker.ts and test.js are borked. Pointing to null as the source file, Vite also spews Sourcemap for "/Users/segevfiner/junk/vite-worker-sourcemaps-bug/src/worker.ts" points to missing source files.

System Info

System:
    OS: macOS 13.2
    CPU: (10) arm64 Apple M1 Pro
    Memory: 105.47 MB / 16.00 GB
    Shell: 5.8.1 - /bin/zsh
  Binaries:
    Node: 16.19.0 - ~/.nvm/versions/node/v16.19.0/bin/node
    Yarn: 1.22.19 - ~/.nvm/versions/node/v16.19.0/bin/yarn
    npm: 9.4.0 - ~/.nvm/versions/node/v16.19.0/bin/npm
  Browsers:
    Chrome: 109.0.5414.119
    Safari: 16.3
  npmPackages:
    @vitejs/plugin-vue: ^4.0.0 => 4.0.0
    vite: ^4.0.0 => 4.1.0-beta.1

Used Package Manager

pnpm

Logs

Click to expand!
Sourcemap for "/Users/segevfiner/junk/vite-worker-sourcemaps-bug/src/worker.ts" points to missing source files
  vite:sourcemap Missing sources:
  vite:sourcemap   /Users/segevfiner/junk/vite-worker-sourcemaps-bug/src/worker.ts?type=module&worker_file +0ms

Validations

@stereokai
Copy link

This happens to me using @rollup/plugin-replace in a regular .js file (not web worker) and without a ? in the url

@sapphi-red
Copy link
Member

Taking a second look, this seems to be fixed by #13662.

@github-actions github-actions bot locked and limited conversation to collaborators Dec 5, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

3 participants