rokucommunity / brighterscript

A superset of Roku's BrightScript language
MIT License
160 stars 46 forks source link

[sourcemaps] Use relative paths for source file reference in the the generated sourcemaps. #1156

Open bartvandenende-wm opened 5 months ago

bartvandenende-wm commented 5 months ago

Summary

Use relative paths for source file reference in the the generated sourcemaps.

Repro steps

given a project that is located in /my-machine/git/my-bs-project

using the below ./bsconfig.json:

  "stagingDir": "build"

I expect the sourcemaps to be generated with a relative path to the project cwd by default, so that when I move the build output from /my-machine/git/my-projects/build to /other-machine/git/my-projects/build the source references are still valid.

This has a small added benefit that it also reduces verbosity of logs for users that have long absolute paths, for example rooibos uses the source maps to print the test file references in the debugger console.

Expected result:

{
  "version":3,
  "sources": ["../src/my-file.bs"]
   ...
}

Actual result:

{
  "version":3,
  "sources": ["/my-machine/git/my-bs-project/src/my-file.bs"]
   ...
}
TwitchBronBron commented 5 months ago

I'd definitely be open to a bsconfig.json setting that supports relative paths. I think we needed absolute paths because of the way the vscode extension moves files around.