| # 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("@build_bazel_rules_nodejs//:index.bzl", "nodejs_test") |
| load("@npm_node_patches//typescript:index.bzl", "tsc") |
| load("//internal/common:copy_to_bin.bzl", "copy_to_bin") |
| |
| package(default_visibility = ["//:__subpackages__"]) |
| |
| sources = glob( |
| [ |
| "*.ts", |
| "src/*.ts", |
| ], |
| exclude = ["**/*.d.ts"], |
| ) |
| |
| js = [s.replace(".ts", ".js") for s in sources] |
| |
| tests = glob( |
| ["test/**/*.ts"], |
| exclude = ["**/*.d.ts"], |
| ) |
| |
| test_js = [t.replace(".ts", ".js") for t in tests] |
| |
| tsc( |
| name = "compile", |
| # TODO: we ought to compile tests separately? |
| outs = js + test_js, |
| args = [ |
| "-p", |
| "$(execpath tsconfig-bazel.json)", |
| "--outDir", |
| "$(RULEDIR)", |
| ], |
| data = sources + tests + [ |
| "tsconfig.json", |
| "tsconfig-bazel.json", |
| "@npm_node_patches//:node_modules", |
| ], |
| tags = ["fix-windows"], |
| ) |
| |
| # Like the generated mocha_test but we don't want to run the patches before testing the patches |
| nodejs_test( |
| name = "unit_test", |
| data = js + test_js + [ |
| "@npm_node_patches//:node_modules", |
| ], |
| entry_point = "@npm_node_patches//:node_modules/mocha/bin/mocha", |
| tags = ["fix-windows"], |
| templated_args = ["$$(rlocation $(rootpath %s))" % s for s in test_js] + [ |
| # TODO: passes locally on mac without this flag but fails on CircleCI |
| "--bazel_patch_module_resolver", |
| "--nobazel_node_patches", |
| ], |
| ) |
| |
| copy_to_bin( |
| name = "bundle", |
| srcs = ["bundle.cjs"], |
| ) |