-
Notifications
You must be signed in to change notification settings - Fork 10
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
Issue with sourcemap pointing to missing file #4
Comments
This might also be unrelated to this plugin as I have reproduced the same issue simply using Vite without the plugin while using Tyrian. |
Hi. I've just spent a bunch of time looking into this as I've been seeing the same warning in my own project. I thought I'd post here what I've found out, in case anyone else comes across this issue: What's the impact?To be honest, I don't really know. If you load your app up in the browser and use your dev tools to check sources, you can clearly see that the browser is able to load both the remote and local source files. I don't know what Vite is using the sourcemaps for. What's going on?The warning from Vite comes from this line of code. If you modify your
and set an environment variable named
In the above example, I've got two sources. One is to a local class in my project, and the other is to a remote source file for one of my dependencies. It's a little clearer what the problem is now. You can see that vite is attempting to load the sources from the directory the Scala JS linker outputs sourcemaps to, but for some reason the URI is incorrect. If you navigate to {
"version": 3,
"file": "package.MyClass.js",
"mappings": "<redacted>",
"sources": ["file:///C:/path/to/project/src/main/scala/package/MyClass.scala", "https://raw.githubusercontent.com/raquo/Laminar/ebb55cd79ffbd2906a0be9cbc17e80fcad210ef0/src/main/scala/com/raquo/laminar/api/package.scala", "..."],
"names": ["redacted"],
"lineCount": 45
} So Scala JS is outputting the URIs correctly. The problem is these two bits of code in Vite: link, link What can I do about it?Project filesI came across this trick in the scala-js channel of the Scala discord (use
This transforms the project sources in your sourcemaps from However, we've changed the actual sourcemap definition and this breaks the sourcemap for the browser! It gets rid of the warning from Vite, but now you have a new (and real) problem. Remote filesI found this issue from someone running into similar problems with Webpack. There's good discussion in the issue, and @DominikGuzei was graceful to share an SBT task which can be used to download the remote sources referenced in your sourcemaps and modify the Unfortunately for us, as mentioned in the project files section I haven't found a solution that allows Vite to find the local files that doesn't simultaneously break the browser's ability to find the sourcemaps. TL;DRI don't know why Vite is emitting the sourcemap warning, but your browser should be able to find the sourcemaps with ScalaJS' default config. I've resigned to just living with the warning for now. |
@DanielMoss Thanks for a very detailed account of the problem! Have you discovered any new information since then by any chance? I noticed that rollup, which Vite uses under the hood, has an output.sourcemapPathTransform option that looks promising. Have you tried it?
Also:
Vite uses both esbuild and rollup, although tbh I'm not sure which of them (or both?) are responsible for sourcemap generation. Claude says esbuild is used in dev server, and rollup (+esbuild minification by default) in prod bundling, but I haven't verified. |
Hi @raquo! I'm afraid not. I haven't looked into this issue since writing my original comment above. I don't remember digging into rollup/esbuild at the time, so you're already ahead of where I was last October. I definitely didn't play around with |
Hi. I'm having some strange errors similar to what has been reported in this react vite plugin vitejs/vite#5438.
I'm not confident that it's not me doing something wrong though.
scalajs version 1.13.1
Error:
package.json
main.js
build.sbt contains following config
The app is started from this definition.
The app works, but I think this error will cause the bundle size to grow large? I tried digging into this, but I'm out of my depth now. Hopefully it's just some stupid mistake I've made in the way I've set it up.
Thanks for the nice plugin :)
The text was updated successfully, but these errors were encountered: