From 92b7c8501fa86d350e153cde71b3c25944d30226 Mon Sep 17 00:00:00 2001 From: Greg Magolan Date: Wed, 25 Mar 2020 21:16:46 -0700 Subject: [PATCH] test: test fix for nodejs_binary entry point logic #1739 --- internal/node/test/BUILD.bazel | 26 ++++++++++++++++++++++++++ internal/node/test/main.ts | 1 + internal/node/test/tsconfig.json | 3 +++ 3 files changed, 30 insertions(+) create mode 100644 internal/node/test/main.ts create mode 100644 internal/node/test/tsconfig.json diff --git a/internal/node/test/BUILD.bazel b/internal/node/test/BUILD.bazel index 897a3cbeef..df5f4efe8e 100644 --- a/internal/node/test/BUILD.bazel +++ b/internal/node/test/BUILD.bazel @@ -1,5 +1,6 @@ load("@build_bazel_rules_nodejs//:index.bzl", "nodejs_binary", "nodejs_test", "npm_package_bin") load("@build_bazel_rules_nodejs//internal/golden_file_test:golden_file_test.bzl", "golden_file_test") +load("@npm//typescript:index.bzl", "tsc") load("//internal/js_library:js_library.bzl", "js_library") load("//internal/node:node_repositories.bzl", "BUILT_IN_NODE_PLATFORMS") load("//third_party/github.com/bazelbuild/bazel-skylib:rules/copy_file.bzl", "copy_file") @@ -342,3 +343,28 @@ nodejs_test( entry_point = "empty_args_fail.js", expected_exit_code = 0, ) + +tsc( + name = "main_lib", + outs = [ + "main.js", + ], + args = [ + "-p", + "$(execpath tsconfig.json)", + "--outDir", + # $(RULEDIR) is a shorthand for the dist/bin directory where Bazel requires we write outputs + "$(RULEDIR)", + ], + data = [ + "main.ts", + "tsconfig.json", + ], +) + +nodejs_test( + name = "main_test", + data = [":main_lib"], + entry_point = ":main.js", + templated_args = ["--nobazel_patch_module_resolver"], +) diff --git a/internal/node/test/main.ts b/internal/node/test/main.ts new file mode 100644 index 0000000000..ee5e348f16 --- /dev/null +++ b/internal/node/test/main.ts @@ -0,0 +1 @@ +console.log('hello world' as string); \ No newline at end of file diff --git a/internal/node/test/tsconfig.json b/internal/node/test/tsconfig.json new file mode 100644 index 0000000000..346e6cea95 --- /dev/null +++ b/internal/node/test/tsconfig.json @@ -0,0 +1,3 @@ +{ + "include": ["main.ts"] +}