| # 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. |
| |
| package(default_visibility = ["//visibility:public"]) |
| |
| load("@build_bazel_rules_nodejs//:defs.bzl", "nodejs_binary") |
| load("//internal:defaults.bzl", "ts_library") |
| |
| # We compile this library with the module name "sm" to make it possible to |
| # use `import {} from 'sm';` both at type-check time (we include the mapping in |
| # the paths map in tsconfig) as well as runtime (we patch the nodejs module |
| # loader to discover the path in the runfiles). |
| ts_library( |
| name = "some_module", |
| srcs = ["index.ts"], |
| module_name = "sm", |
| ) |
| |
| ts_library( |
| name = "main", |
| srcs = ["main.ts"], |
| deps = [":some_module"], |
| ) |
| |
| nodejs_binary( |
| name = "bin", |
| data = [ |
| ":main", |
| ":some_module", |
| ], |
| entry_point = "build_bazel_rules_typescript/examples/some_module/main.js", |
| ) |
| |
| sh_test( |
| name = "module_load_test", |
| srcs = ["module_load_test.sh"], |
| data = [ |
| ":bin", |
| "@bazel_tools//tools/bash/runfiles", |
| ], |
| ) |