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

RFC: TSC Provider? #695

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 2 additions & 14 deletions ts/private/ts_lib.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -54,10 +54,6 @@ https://docs.aspect.build/rulesets/aspect_rules_js/docs/js_library#deps for more
default = 0,
values = [-1, 0, 1],
),
"is_typescript_5_or_greater": attr.bool(
doc = "Whether TypeScript version is >= 5.0.0",
default = False,
),
"transpile": attr.int(
doc = """\
Whether tsc should be used to produce .js outputs
Expand All @@ -70,17 +66,10 @@ https://docs.aspect.build/rulesets/aspect_rules_js/docs/js_library#deps for more
default = -1,
values = [-1, 0, 1],
),
"tsc": attr.label(
doc = "TypeScript compiler binary",
mandatory = True,
executable = True,
cfg = "exec",
),
"tsc_worker": attr.label(
doc = "TypeScript compiler worker binary",
"tsc_tools": attr.label(
mandatory = True,
executable = True,
cfg = "exec",
#providers = [TscInfo],
),
"tsconfig": attr.label(
doc = "tsconfig.json file, see https://www.typescriptlang.org/tsconfig",
Expand All @@ -92,7 +81,6 @@ https://docs.aspect.build/rulesets/aspect_rules_js/docs/js_library#deps for more
settings in the tsconfig.json file""",
default = True,
),
"validator": attr.label(mandatory = True, executable = True, cfg = "exec"),
"_options": attr.label(
default = "@aspect_rules_ts//ts:options",
),
Expand Down
22 changes: 22 additions & 0 deletions ts/providers.bzl
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
"""Providers for rules_ts."""

TscInfo = provider(
doc = """Encapsulates information about a typescript compiler."""
fields = {
"tsc": "Typescript compiler binary (required)",
"tsc_worker": "Typescript compiler worker",
"validator": "Validator binary (required)",
"is_typescript_5_or_greater": "Whether typescript version is known to be greater than 5.",
},
)

def tsc_info(tsc, tsc_worker = None, validator = None, is_typescript_5_or_greater = False):
# TODO:
# - Argument validation
# - Take default validator if it is not set? Is this the right place for it?
return TscInfo(
tsc = tsc,
tsc_worker = tsc_worker,
validator = validator,
is_typescript_5_or_greater = is_typescript_5_or_greater,
)
Loading