From 7ccf3682360edf8a10f128d806a2b698ae543456 Mon Sep 17 00:00:00 2001 From: Joey Perrott Date: Wed, 27 Aug 2025 21:56:30 +0000 Subject: [PATCH] build: define typescript version via string in module.bazel file (#63431) Within our module.bazel file when describing the version of typescript to use for rules_ts, we use ts_version instead of ts_version_from to prevent our package.json file from being part of the set of files used to calculate the sha for the lock file. Any unrelated change to the version of the typescript file would end up causing our lockfile to be out of date. This amount of churn has proven to be too much for our current setup. We instead now test to validate the versions defined in the package.json and MODULE.bazel files match. PR Close #63431 --- BUILD.bazel | 7 ++++++- MODULE.bazel | 2 +- MODULE.bazel.lock | 6 ++---- 3 files changed, 9 insertions(+), 6 deletions(-) diff --git a/BUILD.bazel b/BUILD.bazel index 87ea20b4c71..5821e61db01 100644 --- a/BUILD.bazel +++ b/BUILD.bazel @@ -1,4 +1,5 @@ load("@aspect_rules_js//js:defs.bzl", "js_library") +load("@devinfra//bazel/validation:defs.bzl", "validate_ts_version_matching") load("@npm//:defs.bzl", "npm_link_all_packages") load("//:yarn.bzl", "YARN_PATH") load("//tools:defaults.bzl", "copy_to_bin", "js_binary") @@ -11,7 +12,6 @@ exports_files([ "browser-providers.conf.js", YARN_PATH, "package.json", - "angular.json", ]) npm_link_all_packages( @@ -25,6 +25,11 @@ filegroup( srcs = ["package.json"], ) +validate_ts_version_matching( + module_lock_file = "MODULE.bazel.lock", + package_json = "package.json", +) + alias( name = "tsconfig.json", actual = "//packages:tsconfig-build.json", diff --git a/MODULE.bazel b/MODULE.bazel index 84d61a69a6b..e92b0ea65df 100644 --- a/MODULE.bazel +++ b/MODULE.bazel @@ -104,7 +104,7 @@ rules_ts_ext.deps( name = "angular_npm_typescript", # Obtained by: curl --silent https://registry.npmjs.org/typescript/5.9.2 | jq -r '.dist.integrity' ts_integrity = "sha512-CWBzXQrc/qOkhidw1OzBTQuYRbfyxDXJMVJ1XNwUHGROVmuaeiEm3OslpZ1RV96d7SKKjZKrSJu3+t/xlw3R9A==", - ts_version_from = "//:package.json", + ts_version = "5.9.2", ) use_repo(rules_ts_ext, **{"npm_typescript": "angular_npm_typescript"}) diff --git a/MODULE.bazel.lock b/MODULE.bazel.lock index 9ef2701602f..f7ee6a28bd8 100644 --- a/MODULE.bazel.lock +++ b/MODULE.bazel.lock @@ -545,9 +545,8 @@ "@@aspect_rules_ts~//ts:extensions.bzl%ext": { "general": { "bzlTransitiveDigest": "9IJp6IlB/FMHFBJe4MX/DQM4zi3oArC8yqYE/+NyPwk=", - "usagesDigest": "VEukiyPNBCfwTk3eLa/G6XI3Kv7diVRz/46ULqKcb78=", + "usagesDigest": "dQksgKjptt43p6K/aEOYjcWKS47HbtBzBSMhEYqUYts=", "recordedFileInputs": { - "@@//package.json": "424408e31cbc2ea0d8c16641b88b5be7b14a79fd714b0865a3077debed50d04a", "@@rules_browsers~//package.json": "45572077938c7a4916e4aaedf7db7ce8425854ab92f35348cff02a2134023bb8" }, "recordedDirentsInputs": {}, @@ -557,8 +556,7 @@ "bzlFile": "@@aspect_rules_ts~//ts/private:npm_repositories.bzl", "ruleClassName": "http_archive_version", "attributes": { - "version": "", - "version_from": "@@//:package.json", + "version": "5.9.2", "integrity": "sha512-CWBzXQrc/qOkhidw1OzBTQuYRbfyxDXJMVJ1XNwUHGROVmuaeiEm3OslpZ1RV96d7SKKjZKrSJu3+t/xlw3R9A==", "urls": [ "https://registry.npmjs.org/typescript/-/typescript-{}.tgz"