blob: 7d90c31c468f9b7945c30a1551025c4de0f0938f [file] [log] [blame]
# Copyright 2017 The Bazel Authors. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
# gazelle:exclude worker_protocol.proto
package(default_visibility = ["//visibility:public"])
exports_files([
"tsconfig.json",
# Exported to be consumed for generating skydoc.
"build_defs.bzl",
"ts_config.bzl",
"ts_repositories.bzl",
])
load("//:defs.bzl", "ts_library")
load("@build_bazel_rules_nodejs//:defs.bzl", "nodejs_binary", "jasmine_node_test")
# Vanilla typescript compiler: run the tsc.js binary distributed by TypeScript
nodejs_binary(
name = "tsc",
entry_point = "typescript/lib/tsc.js",
node_modules = "@//:node_modules",
visibility = ["//internal:__subpackages__"],
)
# Build our custom compiler using the vanilla one
ts_library(
name = "tsc_wrapped",
srcs = glob(
[
"tsc_wrapped/*.ts",
"tsetse/*.ts",
"tsetse/rules/*.ts",
],
exclude = [
"**/test_support.ts",
"**/*_test.ts",
],
),
compiler = ":tsc",
data = [
"//third_party/github.com/bazelbuild/bazel/src/main/protobuf:worker_protocol.proto",
],
module_name = "@bazel/typescript",
module_root = "tsc_wrapped/index.d.ts",
node_modules = "@build_bazel_rules_typescript_tsc_wrapped_deps//:node_modules",
supports_workers = False,
tsconfig = "//internal:tsc_wrapped/tsconfig.json",
visibility = ["//visibility:public"],
# Cannot have any deps because it doesn't work with vanilla tsc
# Workaround for https://github.com/Microsoft/TypeScript/issues/22208
deps = [
],
)
# Other ts_library rules will use this custom compiler, which calls the
# TypeScript APIs to act like tsc, but adds capabilities like Bazel workers.
nodejs_binary(
name = "tsc_wrapped_bin",
data = [
":tsc_wrapped",
],
entry_point = "build_bazel_rules_typescript/internal/tsc_wrapped/tsc_wrapped.js",
node_modules = "@//:node_modules",
templated_args = ["--node_options=--expose-gc"],
visibility = ["//visibility:public"],
)
ts_library(
name = "test_lib",
srcs = glob(["tsc_wrapped/*_test.ts"]) + ["tsc_wrapped/test_support.ts"],
tsconfig = "//internal:tsc_wrapped/tsconfig.json",
deps = [":tsc_wrapped"],
)
jasmine_node_test(
name = "test",
srcs = [],
deps = [":test_lib"],
node_modules = "//:node_modules",
)