aspect-build / aspect-build/rules_ts
[Bug]: Transpiled TS conflicts with js_binary
- Dominant language
- Starlark
- Stars
- 138
- Forks
- 87
- Avg merge
- 2d 8h
- Merged PRs (30d)
- 3
Description
### What happened?
Moving from rules_ts-1.0.0-rc4 to a newer release fails if there's transpiled TS used as the `entry_point` for a `js_binary`:
```bazel
load("@aspect_rules_ts//ts:defs.bzl", "ts_project")
load("@aspect_rules_swc//swc:defs.bzl", "swc_transpiler")
load("@bazel_skylib//lib:partial.bzl", "partial")
load("@aspect_rules_js//js:defs.bzl", "js_binary")
ts_project(
name = "src",
srcs = [
"src.ts",
],
declaration = True,
transpiler = partial.make(
swc_transpiler,
),
tsconfig = "//:tsconfig",
deps = [
"//:node_modules/@types/node",
],
)
js_binary(
name = "src-bin",
entry_point = ":src.js",
)
```
It looks like there's some kind of conflict with the anticipated output files:
```
ERROR: file 'src/src.js' is generated by these conflicting actions:
Label: //src:src_transpile, //src:src-bin
RuleClass: swc_transpiler rule, js_binary rule
Configuration: 8c7c8a83495a6b29f5e61b94373e857884c6b6f4ed04fcd868a9a81a5d062e34
Mnemonic: SWCTranspile, CopyFile
Action key: de389923a7de025ef490f7e6b9a234d395f1f6ecb01641df70f2ff4f0cba0cc9, 198c8d00c9d14a3e2ca1aa96583f202cabc88d60e6bf360e2eedd6182abb11df
Progress message: Transpiling with swc //src:src_transpile [swc bazel-out/darwin_arm64-fastbuild/bin/src/src.ts], Copying file src/src.js
PrimaryInput: File:[[]bazel-out/darwin_arm64-fastbuild/bin]src/src.ts, File:[/[path]/repro/ts-build-bug-repro[source]]src/src.js
PrimaryOutput: File:[[]bazel-out/darwin_arm64-fastbuild/bin]src/src.js
ERROR: com.google.devtools.build.lib.skyframe.ArtifactConflictFinder$ConflictException: com.google.devtools.build.lib.actions.MutableActionGraph$ActionConflictException: for src/src.js, previous action: action 'Copying file src/src.js', attempted action: action 'Transpiling with swc //src:src_transpile [swc bazel-out/darwin_arm64-fastbuild/bin/src/src.ts]'
```
### Version
Development (host) and target OS/architectures:
Output of `bazel --version`: Bazel 5.3.2
Version of the Aspect rules, or other relevant rules from your
`WORKSPACE` or `MODULE.bazel` file: rules_ts-1.0.X
Language(s) and/or frameworks involved: SWC, JS, TS.
### How to reproduce
I made a repro over at https://github.com/paullewis/ts-build-bug-repro.
### Any other information?
_No response_
### Fund our work
- [ ] Sponsor our open source work by donating a [bug bounty](https://opencollective.com/aspect-build/)
Contributor guide
Research direction
Start with the linked ts-build-bug-repro and run the shown Bazel configuration using ts_project with swc_transpiler and js_binary. Inspect the generated src/src.js actions and resolve the conflict between SWCTranspile and CopyFile so the transpiled TypeScript can serve as the js_binary entry_point without duplicate outputs.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript, 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