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

fix: consider root dir for source maps paths #277

Merged
merged 1 commit into from
Oct 28, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion examples/root_dir/expected/a.js.map.golden
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"sources": [
"../../src/a.ts"
"../src/a.ts"
]
}
2 changes: 1 addition & 1 deletion examples/root_dir/expected/b.js.map.golden
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"sources": [
"../../src/b.ts"
"../src/b.ts"
]
}
2 changes: 1 addition & 1 deletion examples/root_dir/expected/sub/c.js.map.golden
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"sources": [
"../../../src/sub/c.ts"
"../../src/sub/c.ts"
]
}
2 changes: 1 addition & 1 deletion examples/source_root/expected_subdir.js.map.golden
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"sources": [
"../src/subdir.ts"
"src/subdir.ts"
],
"sourceRoot": "../../../debug/source"
}
5 changes: 4 additions & 1 deletion swc/private/swc.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,10 @@ def _calculate_source_file(ctx, src):

# out of src subdir
if src_pkg:
s = paths.join(s, "/".join([".." for _ in src_pkg.split("/")]))
src_pkg_depth = len(src_pkg.split("/"))
root_dir_depth = len(ctx.attr.root_dir.split("/")) if ctx.attr.root_dir else 0
effective_depth = max(0, src_pkg_depth - root_dir_depth)
s = paths.join(s, "/".join([".." for _ in range(effective_depth)]))

# out of the out dir
if ctx.attr.out_dir:
Expand Down