Skip to content
New issue

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

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

Already on GitHub? # to your account

Source map root added to sources that do not need it #3183

Closed
ptrdom opened this issue Jun 20, 2023 · 1 comment
Closed

Source map root added to sources that do not need it #3183

ptrdom opened this issue Jun 20, 2023 · 1 comment

Comments

@ptrdom
Copy link

ptrdom commented Jun 20, 2023

I am working on integrating esbuild as a bundler for Scala.js projects (https://github.com/ptrdom/scalajs-esbuild) and I am running into an issue I do not understand.

Scala.js compilation outputs source maps for .js files with entries like these:

[
  "https://raw.githubusercontent.com/scala-js/scala-js/v1.10.1/javalanglib/src/main/scala/java/lang/System.scala",
  "file:///C:/project/src/main/scala/Main.scala"
]

After bundling with esbuild these become:

[
  "../../https://raw.githubusercontent.com/scala-js/scala-js/v1.10.1/javalanglib/src/main/scala/java/lang/System.scala",
  "../../file:///C:/project/src/main/scala/Main.scala"
]

I am guessing that sourceRoot is added to them, and because bundles are located in /www/assets, but the script is executed in project root, it results in ../../ being added. In this case this behavior is not needed, so I am wondering how could I avoid it?

If Scala.js project uses some node_modules, then source map entries do get correctly resolved as, for example, "../../node_modules/lodash/lodash.js", but everything else does not work.

@ptrdom ptrdom changed the title Source map root appended to sources that do not need it Source map root added to sources that do not need it Jun 21, 2023
@GongT
Copy link

GongT commented Jul 16, 2023

absolute source map issue. same cause: #2218

I'm creating a plugin, compile scss using sass library.

sass create sourcemaps with "file:///absolute/path" in "sources" field, and esbuild turn them into "../src/file:/absolute/path", this is strange.
If I remove "file://", they becomes "../src/absolute/path", still not usable.

The most important thing is, I have no way to guess relative path of a source map when there are multiple output file, I can't know "who import me" in onLoad stage.

# for free to join this conversation on GitHub. Already have an account? # to comment
Projects
None yet
Development

No branches or pull requests

3 participants