alexeagle | c5d98ba | 2017-04-28 20:42:26 +0200 | [diff] [blame] | 1 | # Copyright 2017 The Bazel Authors. All rights reserved. |
| 2 | # |
| 3 | # Licensed under the Apache License, Version 2.0 (the "License"); |
| 4 | # you may not use this file except in compliance with the License. |
| 5 | # You may obtain a copy of the License at |
| 6 | # |
| 7 | # http://www.apache.org/licenses/LICENSE-2.0 |
| 8 | # |
| 9 | # Unless required by applicable law or agreed to in writing, software |
| 10 | # distributed under the License is distributed on an "AS IS" BASIS, |
| 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 12 | # See the License for the specific language governing permissions and |
| 13 | # limitations under the License. |
| 14 | |
Alex Eagle | ab375ad | 2017-11-13 17:23:47 +0100 | [diff] [blame] | 15 | # gazelle:exclude worker_protocol.proto |
| 16 | |
alexeagle | c028da6 | 2017-04-27 17:18:39 +0200 | [diff] [blame] | 17 | package(default_visibility = ["//visibility:public"]) |
| 18 | |
alexeagle | 793b15e | 2017-08-23 00:58:40 +0200 | [diff] [blame] | 19 | exports_files(["worker_protocol.proto"]) |
alexeagle | 249a43a | 2018-03-01 16:31:18 +0100 | [diff] [blame] | 20 | |
Greg Magolan | 9269f6c | 2018-03-05 20:06:22 +0100 | [diff] [blame^] | 21 | load("//internal:build_defs.bzl", "ts_library") |
alexeagle | 249a43a | 2018-03-01 16:31:18 +0100 | [diff] [blame] | 22 | load("@build_bazel_rules_nodejs//:defs.bzl", "nodejs_binary", "jasmine_node_test") |
| 23 | |
| 24 | # Vanilla typescript compiler: run the tsc.js binary distributed by TypeScript |
| 25 | nodejs_binary( |
| 26 | name = "tsc", |
| 27 | node_modules = "@build_bazel_rules_typescript_tsc_wrapped_deps//:node_modules", |
| 28 | entry_point = "typescript/lib/tsc.js", |
| 29 | visibility = ["//internal:__subpackages__"], |
| 30 | ) |
| 31 | |
| 32 | # Build our custom compiler using the vanilla one |
| 33 | ts_library( |
| 34 | name = "tsc_wrapped", |
| 35 | srcs = glob([ |
| 36 | "tsc_wrapped/*.ts", |
| 37 | "tsetse/*.ts", |
| 38 | "tsetse/rules/*.ts" |
| 39 | ], exclude=["**/test_support.ts", "**/*_test.ts"]), |
Greg Magolan | 9269f6c | 2018-03-05 20:06:22 +0100 | [diff] [blame^] | 40 | supports_workers = False, |
| 41 | compiler = ":tsc", |
| 42 | node_modules = "@build_bazel_rules_typescript_tsc_wrapped_deps//:node_modules", |
alexeagle | 249a43a | 2018-03-01 16:31:18 +0100 | [diff] [blame] | 43 | module_name = "@bazel/typescript", |
alexeagle | 164adc4 | 2018-03-02 01:35:20 +0100 | [diff] [blame] | 44 | module_root = "tsc_wrapped/index.d.ts", |
alexeagle | 249a43a | 2018-03-01 16:31:18 +0100 | [diff] [blame] | 45 | tsconfig = "//internal:tsc_wrapped/tsconfig.json", |
| 46 | visibility = ["//visibility:public"], |
| 47 | data = [ |
| 48 | # Should be @bazel_tools//src/main/protobuf:worker_protocol.proto |
| 49 | # see https://github.com/bazelbuild/bazel/issues/3155#issuecomment-308156976 |
| 50 | ":worker_protocol.proto", |
| 51 | ], |
| 52 | # Cannot have any deps because it doesn't work with vanilla tsc |
| 53 | # Workaround for https://github.com/Microsoft/TypeScript/issues/22208 |
| 54 | deps = [ |
| 55 | ], |
| 56 | ) |
| 57 | |
| 58 | # Other ts_library rules will use this custom compiler, which calls the |
| 59 | # TypeScript APIs to act like tsc, but adds capabilities like Bazel workers. |
| 60 | nodejs_binary( |
| 61 | name = "tsc_wrapped_bin", |
| 62 | data = [ |
| 63 | ":tsc_wrapped", |
| 64 | ], |
| 65 | node_modules = "@build_bazel_rules_typescript_tsc_wrapped_deps//:node_modules", |
| 66 | entry_point = "build_bazel_rules_typescript/internal/tsc_wrapped/tsc_wrapped.js", |
| 67 | templated_args = ["--node_options=--expose-gc"], |
| 68 | visibility = ["//visibility:public"], |
| 69 | ) |
| 70 | |
| 71 | ts_library( |
| 72 | name = "test_lib", |
| 73 | srcs = glob(["tsc_wrapped/*_test.ts"]) + ["tsc_wrapped/test_support.ts"], |
| 74 | deps = [":tsc_wrapped"], |
| 75 | tsconfig = "//internal:tsc_wrapped/tsconfig.json", |
| 76 | ) |
| 77 | |
| 78 | jasmine_node_test( |
| 79 | name = "test", |
| 80 | srcs = [], |
| 81 | deps = [":test_lib"], |
| 82 | ) |