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

@rollup/plugin-replace breaks when module ID includes query parameters #1422

Closed
segevfiner opened this issue Jan 30, 2023 · 3 comments
Closed

Comments

@segevfiner
Copy link

segevfiner commented Jan 30, 2023

  • Rollup Plugin Name: replace
  • Rollup Plugin Version: 5.0.2
  • Rollup Version: 3.12.0 (Via Vite 4.0.4)
  • Operating System (or Browser): macOS 13.2 Chrome 109.0.5414.119
  • Node Version: 16.19.0
  • Link to reproduction (⚠️ read below): https://github.com/segevfiner/vite-worker-sourcemaps-bug

Expected Behavior

Source maps work correctly with @rollup/plugin-replace even with module that use query parameters as used by Vite and other plugins.

Actual Behavior

They break. Either the source is missing or both the file names and source is missing producing null. null is not even valid in sources AFAIK.

worker.ts is missing sourcesContent, it has null, test.ts has null for both sources & sourcesContent, and the browser tries to look for a file with null has its name, which is obviously wrong.

There are often warnings of the form:

Sourcemap for "/Users/segevfiner/junk/vite-worker-sourcemaps-bug/src/worker.ts" points to missing source files

Additional Information

This might be an issue in magic-string, I reported it there as well Rich-Harris/magic-string#238

I have hit this with Vite, but the issue can likely be caused by using query parameters with vanilla Rollup and plugins that handle them.

cc @YossiSaadi

@shellscape
Copy link
Collaborator

Note that this is not a minimal repository as advised within the issue template, and your issue probably won't get any traction with maintainers as a result. If you're able to use one of the available reproduction methods to distill the error, you'll have a much better chance of having this addressed.

@segevfiner
Copy link
Author

I tried to debug this further and it seems it might be an issue in Vite own sourcemaps plugin that doesn't handle it's own ids with query parameters when there are plugins that output some kinds of sourcemaps. I'll reopen there.

@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

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

No branches or pull requests

3 participants