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

[Bug]: Source generated by conflicting actions when importing js into ts #707

Open
aptenodytes-forsteri opened this issue Oct 5, 2024 · 10 comments
Labels
bug Something isn't working

Comments

@aptenodytes-forsteri
Copy link

aptenodytes-forsteri commented Oct 5, 2024

What happened?

When importing js into ts while also transpiling with swc, rules_ts produces an error.

Repro case here: https://github.com/aptenodytes-forsteri/ts_js_interop

Version

Development (host) and target OS/architectures:
Ubuntu 22.04

Output of bazel --version:
bazel 7.3.2

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

load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive", "http_file")

http_archive(
        name = "aspect_rules_js",
        sha256 = "4cab6898f0ff8048e32640cce06a47aa4b92b2fb330d055940f95f24c8ebb868",
        strip_prefix = "rules_js-2.0.1",
        url = "https://github.com/aspect-build/rules_js/releases/download/v2.0.1/rules_js-v2.0.1.tar.gz",
    )

http_archive(
    name = "aspect_rules_ts",
    sha256 = "5aafa2422b6f2ed6d8db9edcd6368693055960bca7e149516b95c0d45a6a7ae5",
    strip_prefix = "rules_ts-3.1.0",
    url = "https://github.com/aspect-build/rules_ts/releases/download/v3.1.0/rules_ts-v3.1.0.tar.gz",
)

http_archive(
    name = "aspect_rules_swc",
    sha256 = "d63d7b283249fa942f78d2716ecff3edbdc10104ee1b9a6b9464ece471ef95ea",
    strip_prefix = "rules_swc-2.0.0",
    url = "https://github.com/aspect-build/rules_swc/releases/download/v2.0.0/rules_swc-v2.0.0.tar.gz",
)


Language(s) and/or frameworks involved:
js / ts

How to reproduce

Clone https://github.com/aptenodytes-forsteri/ts_js_interop/tree/main

bazel build //...

More generally, attempt to import javascript into typescript. We have some code that has not been converted to typescript. We had successfully been importing this javascript into our typescript. Now, we get errors about conflicting source files.

Any other information?

No response

@aptenodytes-forsteri aptenodytes-forsteri added the bug Something isn't working label Oct 5, 2024
@jbedard
Copy link
Member

jbedard commented Oct 7, 2024

Thanks for the good repro. I think this is fixed in the latest rules_ts release though, mainly just as a side-effect of adding declarations_transpiler and no_emit features. Can you try it out?

@aptenodytes-forsteri
Copy link
Author

Yes, 3.2.0 seems to fix it. Worth adding a test case for this if there isn't one already? I'll also check to see if any other combinations of ts and js can break it.

@jbedard
Copy link
Member

jbedard commented Oct 8, 2024

If you can contribute a test case that failed previously that would be great. I don't think any were added when fixed but maybe you can verify that?

@aptenodytes-forsteri
Copy link
Author

My test case now passes with the new version, but a subsequent dependency fails

emit_transpiler_js = emit_js and transpiler and transpiler != "tsc"
I think this is now getting set to false, so when I try to esbuild from my generated js, I get no js file exists.

@aptenodytes-forsteri
Copy link
Author

I guess maybe I need to eliminate emit_declaration_only = True,

@aptenodytes-forsteri
Copy link
Author

Err no, when I delete emit_declaration_only = True, I get the conflict again.

@aptenodytes-forsteri
Copy link
Author

@jbedard
Copy link
Member

jbedard commented Oct 8, 2024

Can you try adding test cases to rules_ts to reproduce it?

@aptenodytes-forsteri
Copy link
Author

Can you try adding test cases to rules_ts to reproduce it?

#712

@aptenodytes-forsteri
Copy link
Author

If I remove emit_declaration_only = True, I get the conflict error again.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants