You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I am using rules_ts with bazel, and by default it will create a ts_project rule for each .ts file found in a directory. The same applies to test files ending in .spec.ts..
This behavior can be modified to a limited extent using gazelle directives, but I don't see a way to get the behavior I want.
Describe the feature
I have a custom rule I want to use for tests. Nothing special, but it combines a ts_project for the test file with a vitest run from load("@npm//:vitest/package_json.bzl", vitest_bin = "bin").
and that's all. I don't see how to get the behavior I want though.
I cannot use a simple aspect:map_kind directive, because I want the substitution ts_project -> ts_test to happen only for test files, not for every filetype (other ts files should still use the ts_project rule).
I looked into the Starlark Extension API (which seems really cool!) but I have found 2 issues:
The first is that the default ts_project behavior is not changes, so now I have both a ts_test rule and a ts_project rule, which is not what I want
The second is that I would have to write my own logic for ts_test dependencies. Here I just want to reuse the same logic from ts_project, just set in a different macro - but I don't want to rewrite the whole 'parse file import to add dependencies' logic.
So my question is - what can I do about this? I am very new to this space, so perhaps there's something obvious I am missing.
One thing that I think might work is to add a gazelle directive to specify which rule should be used for the .spec.ts targets, so that I could set it to my own rule using the aspect:map_kind directive and have everything else work as it is, without having to write a custom starlark plugin
Another idea would be exporting the whole logic as a starlark extension so one could change it without having to fork / recompile the CLI, but directly adding a new plugin.
Any help would be appreciated. Thanks a lot!
The text was updated successfully, but these errors were encountered:
What is the current behavior?
Hi,
I am using
rules_ts
with bazel, and by default it will create ats_project
rule for each.ts
file found in a directory. The same applies to test files ending in.spec.ts.
.This behavior can be modified to a limited extent using gazelle directives, but I don't see a way to get the behavior I want.
Describe the feature
I have a custom rule I want to use for tests. Nothing special, but it combines a
ts_project
for the test file with avitest
run fromload("@npm//:vitest/package_json.bzl", vitest_bin = "bin")
.So the idea is that I would be able to write
and that's all. I don't see how to get the behavior I want though.
aspect:map_kind
directive, because I want the substitutionts_project
->ts_test
to happen only for test files, not for every filetype (otherts
files should still use thets_project
rule).ts_project
behavior is not changes, so now I have both ats_test
rule and ats_project
rule, which is not what I wantts_test
dependencies. Here I just want to reuse the same logic fromts_project
, just set in a different macro - but I don't want to rewrite the whole 'parse file import to add dependencies' logic.So my question is - what can I do about this? I am very new to this space, so perhaps there's something obvious I am missing.
One thing that I think might work is to add a
gazelle
directive to specify which rule should be used for the.spec.ts
targets, so that I could set it to my own rule using theaspect:map_kind
directive and have everything else work as it is, without having to write a custom starlark pluginAnother idea would be exporting the whole logic as a starlark extension so one could change it without having to fork / recompile the CLI, but directly adding a new plugin.
Any help would be appreciated. Thanks a lot!
The text was updated successfully, but these errors were encountered: