Skip to content

Add sourceMapRelativePaths option for portable sourcemaps#1624

Open
bartvandenende-wm wants to merge 4 commits intorokucommunity:masterfrom
bartvandenende-wm:feature/sourcemap-relative-paths
Open

Add sourceMapRelativePaths option for portable sourcemaps#1624
bartvandenende-wm wants to merge 4 commits intorokucommunity:masterfrom
bartvandenende-wm:feature/sourcemap-relative-paths

Conversation

@bartvandenende-wm
Copy link
Contributor

Summary

Adds a new sourceMapRelativePaths bsconfig option that emits relative file paths in sourcemap sources instead of absolute paths. This makes sourcemaps portable across different machines and CI environments.

Resolves #1156

Problem

Sourcemaps currently embed absolute paths (e.g. /home/runner/work/project/src/main.bs). When build output is moved to another machine -- for example when libraries are published to npm and consumed elsewhere -- these paths no longer resolve and debugging tools cannot locate the original source files.

Solution

A new boolean config option sourceMapRelativePaths (default: false) post-processes the generated sourcemap at serialization time, converting absolute sources entries to paths relative to the .map file location. For example:

// Before (absolute)
{ "sources": ["/Users/dev/project/src/source/main.bs"] }

// After (relative, with sourceMapRelativePaths: true)
{ "sources": ["../../src/source/main.bs"] }

VSCode extension compatibility

In the issue, @TwitchBronBron noted:

I think we needed absolute paths because of the way the vscode extension moves files around.

After inspecting the roku-debug source, this concern does not apply. The SourceMapManager.set() method already resolves source paths using path.resolve():

parsedSourceMap.sources = parsedSourceMap.sources.map(source => fileUtils.standardizePath(
    path.resolve(
        //use the map's sourceRoot, or the map's folder path (to support relative paths)
        parsedSourceMap.sourceRoot || path.dirname(sourceMapPath),
        source
    )
));

bartvandenende-wm and others added 4 commits February 14, 2026 11:55
…urcemaps

Adds a new `sourceMapRelativePaths` bsconfig option (default: false) that
converts absolute source paths in generated .map files to paths relative
to the map file location. This makes sourcemaps portable across machines.

Resolves rokucommunity#1156

Co-authored-by: Cursor <cursoragent@cursor.com>
Document the new sourceMapRelativePaths option and the previously
undocumented sourceMap option in docs/bsconfig.md.

Co-authored-by: Cursor <cursoragent@cursor.com>
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

Successfully merging this pull request may close these issues.

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

2 participants