| # 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 |
| |
| load("@bazel_skylib//:bzl_library.bzl", "bzl_library") |
| load("//:index.bzl", "js_library", "nodejs_binary") |
| load("//packages/jasmine:index.bzl", "jasmine_node_test") |
| load("//packages/concatjs:index.bzl", "ts_library") |
| load("@npm//typescript:index.bzl", "tsc") |
| |
| package(default_visibility = ["//visibility:public"]) |
| |
| bzl_library( |
| name = "bzl", |
| srcs = glob( |
| [ |
| "*.bzl", |
| "common/*.bzl", |
| ], |
| exclude = ["internal_*"], |
| ), |
| visibility = ["//visibility:public"], |
| deps = [ |
| "@bazel_skylib//lib:types", |
| "@build_bazel_rules_nodejs//:bzl", |
| "@build_bazel_rules_nodejs//internal/common:bzl", |
| "@rules_nodejs//nodejs:bzl", |
| ], |
| ) |
| |
| exports_files(["tsetse/tsconfig.json"]) |
| |
| _TSC_WRAPPED_TESTS = [ |
| "**/test_support.ts", |
| "**/*_test.ts", |
| ] |
| |
| _TSC_WRAPPED_SRCS = glob( |
| [ |
| "tsc_wrapped/*.ts", |
| "tsetse/**/*.ts", |
| ], |
| exclude = _TSC_WRAPPED_TESTS + ["tsetse/tests/**"], |
| ) |
| |
| _TSC_WRAPPED_JS = [k[:-3] + ".js" for k in _TSC_WRAPPED_SRCS] |
| |
| _TSC_WRAPPED_TYPINGS = [k[:-3] + ".d.ts" for k in _TSC_WRAPPED_SRCS] |
| |
| # Build our custom compiler using the vanilla one |
| tsc( |
| name = "tsc_wrapped", |
| outs = _TSC_WRAPPED_JS + _TSC_WRAPPED_TYPINGS, |
| args = [ |
| "--declaration", |
| "-p", |
| "$(execpath //packages/concatjs/internal:tsconfig.json)", |
| "--outDir", |
| "$(RULEDIR)", |
| ], |
| data = _TSC_WRAPPED_SRCS + [ |
| "//packages/concatjs/internal:tsconfig.json", |
| "@npm//@types/node", |
| "@npm//@angular/compiler-cli", |
| "@npm//protobufjs", |
| "@npm//tsickle", |
| "@npm//tsutils", |
| "@npm//typescript", |
| ], |
| visibility = ["//visibility:public"], |
| ) |
| |
| js_library( |
| name = "tsc_wrapped_lib", |
| srcs = [":tsc_wrapped"], |
| ) |
| |
| # Other ts_library rules will use this custom compiler, which calls the |
| # TypeScript APIs to act like tsc, but adds capabilities like Bazel workers. |
| # TODO(gregmagolan): make @npm//tsickle dependency optional |
| nodejs_binary( |
| name = "tsc_wrapped_bin", |
| data = [ |
| ":tsc_wrapped", |
| "//packages/concatjs/third_party/github.com/bazelbuild/bazel/src/main/protobuf:worker_protocol.proto", |
| "@npm//protobufjs", |
| "@npm//source-map-support", |
| "@npm//tsickle", |
| "@npm//tsutils", |
| "@npm//typescript", |
| ], |
| entry_point = ":tsc_wrapped/tsc_wrapped.js", |
| # With RBE or --worker_sandboxing you'll see that when supports_workers=True it doesn't run_node |
| # so it doesn't have the linker. Still needs our custom patches on require() |
| templated_args = ["--bazel_patch_module_resolver"], |
| visibility = ["//visibility:public"], |
| ) |
| |
| ts_library( |
| name = "test_lib", |
| srcs = glob(_TSC_WRAPPED_TESTS) + _TSC_WRAPPED_TYPINGS, |
| compiler = "//packages/concatjs/internal:tsc_wrapped_bin", |
| tsconfig = "//packages/concatjs/internal:tsconfig.json", |
| deps = [ |
| "@npm//@angular/compiler-cli", |
| "@npm//@types/jasmine", |
| "@npm//@types/node", |
| "@npm//tsickle", |
| "@npm//typescript", |
| ], |
| ) |
| |
| jasmine_node_test( |
| name = "test", |
| srcs = [], |
| tags = [ |
| # TODO: it seems like this test has been broken since we brought in from rules_typescript |
| "manual", |
| ], |
| deps = _TSC_WRAPPED_JS + [ |
| ":test_lib", |
| "//packages/concatjs/third_party/github.com/bazelbuild/bazel/src/main/protobuf:worker_protocol.proto", |
| "@npm//jasmine", |
| "@npm//protobufjs", |
| "@npm//source-map", |
| "@npm//typescript", |
| ], |
| ) |
| |
| # We don't need to distribute any of the content of the BUILD.bazel file in this package |
| # So generate an empty marker file |
| genrule( |
| name = "generated_BUILD", |
| srcs = [], |
| # Name the output "BUILD" so it doesn't collide with InputArtifact "BUILD.bazel" |
| outs = ["BUILD"], |
| cmd = "echo \"# Marker that this directory is a Bazel package\" > $@", |
| ) |
| |
| filegroup( |
| name = "package_contents", |
| srcs = [ |
| "build_defs.bzl", |
| "common/compilation.bzl", |
| "common/json_marshal.bzl", |
| "common/module_mappings.bzl", |
| "common/tsconfig.bzl", |
| "ts_config.bzl", |
| ], |
| visibility = ["//packages/concatjs:__subpackages__"], |
| ) |