blob: 72d5c39ecde4c786905393831fff9f1bbeeea008 [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.
load("//internal:build_defs.bzl", ts_library = "tsc_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",
node_modules = "@build_bazel_rules_typescript_deps//:node_modules",
entry_point = "typescript/lib/tsc.js",
visibility = ["//internal:__subpackages__"],
)
# Build our custom compiler using the vanilla one
ts_library(
name = "tsc_wrapped",
srcs = [
"compiler_host.ts",
"diagnostics.ts",
"file_cache.ts",
"index.ts",
"manifest.ts",
"strict_deps.ts",
"tsc_wrapped.ts",
"tsconfig.ts",
"umd_module_declaration_transform.ts",
"worker.ts",
],
module_name = "@bazel/typescript",
module_root = "index.d.ts",
tsconfig = ":tsconfig.json",
visibility = ["//visibility:public"],
data = [
# Should be @bazel_tools//src/main/protobuf:worker_protocol.proto
# see https://github.com/bazelbuild/bazel/issues/3155#issuecomment-308156976
"//internal:worker_protocol.proto",
],
deps = [
":perf_trace",
":plugin_api",
"//internal/tsetse:runner",
],
)
ts_library(
name = "plugin_api",
srcs = ["plugin_api.ts"],
visibility = ["//internal/tsetse:__pkg__"],
)
ts_library(
name = "perf_trace",
srcs = ["perf_trace.ts"],
visibility = ["//internal/tsetse:__pkg__"],
)
# 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",
],
node_modules = "@build_bazel_rules_typescript_deps//:node_modules",
entry_point = "build_bazel_rules_typescript/internal/tsc_wrapped/tsc_wrapped.js",
templated_args = ["--node_options=--expose-gc"],
visibility = ["//visibility:public"],
)
ts_library(
name = "test_lib",
srcs = glob(["*_test.ts"]) + ["test_support.ts"],
deps = [":tsc_wrapped"],
tsconfig = ":tsconfig.json",
)
jasmine_node_test(
name = "test",
srcs = [],
deps = [":test_lib"],
)