Skip to content

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

@supercairos

Description

@supercairos

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

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingneed: more infoThe issue isn't clear as written

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions