just use @npm label
diff --git a/WORKSPACE b/WORKSPACE index 8ae2c80..ddcd88e 100644 --- a/WORKSPACE +++ b/WORKSPACE
@@ -50,9 +50,6 @@ # load("@rules_nodejs//nodejs:repositories.bzl", "nodejs_register_toolchains") -load("@rules_nodejs//nodejs:ts_repositories.bzl", "ts_repositories") - -ts_repositories(ts_version = "4.5.4") # The order matters because Bazel will provide the first registered toolchain when a rule asks Bazel to select it # This applies to the resolved_toolchain
diff --git a/examples/app/WORKSPACE b/examples/app/WORKSPACE index cc90836..4a85ded 100644 --- a/examples/app/WORKSPACE +++ b/examples/app/WORKSPACE
@@ -26,11 +26,7 @@ build_bazel_rules_nodejs_dependencies() -load("@build_bazel_rules_nodejs//:index.bzl", "node_repositories", "yarn_install") - -node_repositories( - ts_version = "3.6.3", -) +load("@build_bazel_rules_nodejs//:index.bzl", "yarn_install") yarn_install( name = "npm",
diff --git a/examples/nestjs/WORKSPACE b/examples/nestjs/WORKSPACE index 5ce944e..4b86293 100644 --- a/examples/nestjs/WORKSPACE +++ b/examples/nestjs/WORKSPACE
@@ -26,11 +26,7 @@ build_bazel_rules_nodejs_dependencies() -load("@build_bazel_rules_nodejs//:index.bzl", "node_repositories", "yarn_install") - -node_repositories( - ts_version = "3.5.3", -) +load("@build_bazel_rules_nodejs//:index.bzl", "yarn_install") yarn_install( name = "npm",
diff --git a/internal/node/node_repositories.bzl b/internal/node/node_repositories.bzl index 0134954..040ceff 100644 --- a/internal/node/node_repositories.bzl +++ b/internal/node/node_repositories.bzl
@@ -26,7 +26,7 @@ """ Wrapper macro around node_repositories_rule to call it for each platform. - Also register bazel toolchains, and make other convenience repositories such as yarn and typescript. + Also register bazel toolchains, and make other convenience repositories. Args: **kwargs: the documentation is generated from the node_repositories_rule, not this macro.
diff --git a/nodejs/ts_repositories.bzl b/nodejs/ts_repositories.bzl deleted file mode 100644 index 3b7622a..0000000 --- a/nodejs/ts_repositories.bzl +++ /dev/null
@@ -1,85 +0,0 @@ -""""Fetches needed to run the typescript compiler - -This method fetches typescript directly, rather than via the npm install of a @bazel/typescript package -""" - -load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive") - -# TODO(alexeagle): we could setup a GH Actions automation to continuously mirror this from upstream -_TS_CHECKSUMS = { - "3.5.3": "7e066461729870f9bff8edffab8afb1a511854e040200451bbdf8aec65802b77", - "3.6.3": "ef803d564f80a7c1aa731896556f0d05af6b7b371abcd687ffd493e7bd718457", - "4.3.5": "c7be550da858be7abfc73dd0b9060ab23ce835ae3b05931f4500a25c09766d45", - "4.4.4": "7524841bbf63777fef1fe6e1a826026b1dd4849f54f5affa481502faab2cdb16", - "4.5.4": "5b2b014c4d6f9ad4615d7ced8cc32f882a4a96df8213722577b42277afb03cba", -} - -DEFAULT_VERSION = _TS_CHECKSUMS.keys()[-1] - -# Namespace this so it's unlikely to conflict with other repositories -_default_name = "bbrnj_typescript" - -def ts_repositories( - ts_version, - name = _default_name, - sha256 = None, - url = "https://registry.npmjs.org/typescript/-/typescript-{version}.tgz"): - """Fetch a typescript package from npm - - Args: - name: name of the resulting external repository. - If you override the name, you'll also have to override the `tsc` attr of `ts_project`. - - ts_version: Version of the typescript package. - See https://www.npmjs.com/package/typescript?activeTab=versions - To avoid surprising behavior, you should assert that this matches what your package.json - installs for non-Bazel tooling such as the editor. - - sha256: integrity hash of the typescript package, computed by running: - `curl --silent https://registry.npmjs.org/typescript/-/typescript-[version].tgz | shasum -a 256` - - url: where the bazel downloader should fetch the package from, allows a `{version}` placeholder. - """ - - if not sha256: - sha256 = _TS_CHECKSUMS[ts_version] - if not sha256: - fail("No sha256 available for version %s, please set the sha256 attribute" % ts_version) - - http_archive( - name = name, - build_file_content = """# Generated by /ts/repositories.bzl -load("@build_bazel_rules_nodejs//:index.bzl", "nodejs_binary") -load("@rules_nodejs//third_party/github.com/bazelbuild/bazel-skylib:rules/copy_file.bzl", "copy_file") -load("@bazel_skylib//rules:write_file.bzl", "write_file") - -# Turn a source directory into a TreeArtifact for RBE-compat -copy_file( - name = "{name}", - src = "package", - # This attribute comes from rules_nodejs patch of - # https://github.com/bazelbuild/bazel-skylib/pull/323 - is_directory = True, - out = "package", - visibility = ["//visibility:public"], -) - -write_file( - name = "gen_tsc.js", - out = "tsc.js", - content = [ - "const runfiles = require(process.env['BAZEL_NODE_RUNFILES_HELPER'])", - "require(runfiles.resolve('{name}') + '/package/bin/tsc')", - ], -) - -nodejs_binary( - name = "tsc", - data = ["@{name}"], - entry_point = "tsc.js", - visibility = ["//visibility:public"], -) -""".format(name = name, version = ts_version), - sha256 = sha256, - urls = [url.format(version = ts_version)], - )
diff --git a/packages/typescript/internal/ts_project.bzl b/packages/typescript/internal/ts_project.bzl index e45a0a7..fe92110 100644 --- a/packages/typescript/internal/ts_project.bzl +++ b/packages/typescript/internal/ts_project.bzl
@@ -28,7 +28,7 @@ # that compiler might allow more sources than tsc does. "srcs": attr.label_list(allow_files = True, mandatory = True), "supports_workers": attr.bool(default = False), - "tsc": attr.label(default = Label(_DEFAULT_TSC), executable = True, cfg = "exec"), + "tsc": attr.label(default = Label("@npm//typescript/bin:tsc"), executable = True, cfg = "exec"), "transpile": attr.bool(doc = "whether tsc should be used to produce .js outputs"), "tsconfig": attr.label(mandatory = True, allow_single_file = [".json"]), }