aspect-build / aspect-build/rules_swc

[Bug]: When using a wrapped `swc` transpiler in a `ts_project`, source maps are wrong.

Open
#222 5 comments 0 reactions 0 assignees View on GitHub
bug need: more info
Dominant language
Starlark
Stars
49
Forks
40
PR merge metrics
No merged PRs in 30d

Description

### What happened?

I'm using something simple like this in order to produce source_maps:

This file is in a `BUILD.bazel` in a folder hello
```skylark
ts_project(
name = "lib",
srcs = glob([
"src/**/*.ts",
]),
declaration = True,
declaration_map = True,
source_map = True,
transpiler = partial.make(
swc,
source_maps = True,
swcrc = ":.swcrc",
),
tsconfig = "tsconfig",
validate = True,
visibility = ["//visibility:public"],
deps = [
":node_modules",
],
)
```

It produce:
```
{
"version":3,
"sources":[
"index.ts"
],
...
}
```

Where it should be:
```
{
"version":3,
"sources":[
"src/index.ts"
],
"sourceRoot": "hello"
...
}
```

### Version

Development (host) and target OS/architectures:

Output of `bazel --version`:
6.4.0

Version of the Aspect rules, or other relevant rules from your
`WORKSPACE` or `MODULE.bazel` file:

```
http_archive(
name = "rules_nodejs",
sha256 = "162f4adfd719ba42b8a6f16030a20f434dc110c65dc608660ef7b3411c9873f9",
strip_prefix = "rules_nodejs-6.0.2",
url = "https://github.com/bazelbuild/rules_nodejs/releases/download/v6.0.2/rules_nodejs-v6.0.2.tar.gz",
)

http_archive(
name = "aspect_rules_swc",
sha256 = "8eb9e42ed166f20cacedfdb22d8d5b31156352eac190fc3347db55603745a2d8",
strip_prefix = "rules_swc-1.1.0",
url = "https://github.com/aspect-build/rules_swc/releases/download/v1.1.0/rules_swc-v1.1.0.tar.gz",
)

http_archive(
name = "aspect_rules_ts",
sha256 = "bd3e7b17e677d2b8ba1bac3862f0f238ab16edb3e43fb0f0b9308649ea58a2ad",
strip_prefix = "rules_ts-2.1.0",
url = "https://github.com/aspect-build/rules_ts/releases/download/v2.1.0/rules_ts-v2.1.0.tar.gz",
)

http_archive(
name = "aspect_rules_js",
sha256 = "76a04ef2120ee00231d85d1ff012ede23963733339ad8db81f590791a031f643",
strip_prefix = "rules_js-1.34.1",
url = "https://github.com/aspect-build/rules_js/releases/download/v1.34.1/rules_js-v1.34.1.tar.gz",
)
```

Language(s) and/or frameworks involved:

### How to reproduce

_No response_

### Any other information?

_No response_

Contributor guide

Open the contributing guide

Research direction

Start with the BUILD.bazel example and inspect how ts_project passes the wrapped swc transpiler, using the referenced .swcrc and tsconfig inputs. Reproduce the generated source map and trace where the sources path and sourceRoot are established; done means the output points to src/index.ts under hello as described.

Written by the indexing model from the issue text.

Assessment

Tech stack
typescript
Domain
build-system
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.