Skip to content

Commit

Permalink
fix: support custom tsc version numbers when integrity passed
Browse files Browse the repository at this point in the history
  • Loading branch information
jbedard committed Sep 7, 2024
1 parent 45755ef commit 016923f
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 5 deletions.
14 changes: 13 additions & 1 deletion e2e/external_dep/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,19 @@ ts_project(
tsc = "@npm_typescript3//:tsc",
)

ts_project(
name = "lib.ts56rc",
srcs = ["lib.ts"],
composite = True,
out_dir = "ts56rc_out",
tsc = "@npm_typescript-56rc//:tsc",
)

build_test(
name = "test",
targets = [":lib"],
targets = [
":lib",
"lib.ts3",
"lib.ts56rc",
],
)
9 changes: 8 additions & 1 deletion e2e/external_dep/MODULE.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,11 @@ rules_ts_ext.deps(
name = "npm_typescript3",
ts_version = "3.9.9",
)
use_repo(rules_ts_ext, "npm_typescript", "npm_typescript3")

# Example of an rc version
rules_ts_ext.deps(
name = "npm_typescript-56rc",
ts_integrity = "sha512-E3b2+1zEFu84jB0YQi9BORDjz9+jGbwwy1Zi3G0LUNw7a7cePUrHMRNy8aPh53nXpkFGVHSxIZo5vKTfYaFiBQ==",
ts_version = "5.6.1-rc",
)
use_repo(rules_ts_ext, "npm_typescript", "npm_typescript-56rc", "npm_typescript3")
6 changes: 6 additions & 0 deletions e2e/external_dep/WORKSPACE
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,12 @@ rules_ts_dependencies(
ts_version = "3.9.9",
)

rules_ts_dependencies(
name = "npm_typescript-56rc",
ts_integrity = "sha512-E3b2+1zEFu84jB0YQi9BORDjz9+jGbwwy1Zi3G0LUNw7a7cePUrHMRNy8aPh53nXpkFGVHSxIZo5vKTfYaFiBQ==",
ts_version = "5.6.1-rc",
)

load("@aspect_rules_js//js:repositories.bzl", "rules_js_dependencies")

rules_js_dependencies()
Expand Down
4 changes: 1 addition & 3 deletions ts/private/npm_repositories.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,6 @@ def _http_archive_version_impl(rctx):
ts = p["dependencies"]["typescript"]
else:
fail("key 'typescript' not found in either dependencies or devDependencies of %s" % json_path)
if any([not seg.isdigit() for seg in ts.split(".")]):
fail("""typescript version in package.json must be exactly specified, not a semver range: %s.
You can supply an exact 'ts_version' attribute to 'rules_ts_dependencies' to bypass this check.""" % ts)
version = ts

if integrity:
Expand All @@ -42,6 +39,7 @@ def _http_archive_version_impl(rctx):
else:
fail("""typescript version {} is not mirrored in rules_ts, is this a real version?
If so, you must manually set 'ts_integrity'.
If this is a semver range you must specify an exact version instead.
See documentation on rules_ts_dependencies.""".format(version))

rctx.download_and_extract(
Expand Down

0 comments on commit 016923f

Please sign in to comment.