I want to compile some Typescript files and create a Node.js Image from the compiled Javascript files. It works fine when I have only one Typescript file with this BUILD
file:
load("@io_bazel_rules_docker//nodejs:image.bzl", "nodejs_image")
load("@npm_bazel_typescript//:index.bzl", "ts_library")
ts_library(
name = "compile",
srcs = ["src/index.ts"],
)
filegroup(
name = "files",
srcs = ["compile"],
output_group = "es5_sources",
)
nodejs_image(
name = "server",
entry_point = "files",
)
But as soon as I introduce multiple Typescript files like this:
load("@io_bazel_rules_docker//nodejs:image.bzl", "nodejs_image")
load("@npm_bazel_typescript//:index.bzl", "ts_library")
ts_library(
name = "compile",
srcs = ["src/index.ts", "src/util.ts"],
)
filegroup(
name = "files",
srcs = ["compile"],
output_group = "es5_sources",
)
nodejs_image(
name = "server",
data = ["files"],
entry_point = "files/src/index.js",
)
Bazel doesn't find the entrypoint file:
ERROR: missing input file '//server:files/src/index.js'
ERROR: /home/flo/Desktop/my-own-minimal-bazel/server/BUILD:15:1: //server:server: missing input file '//server:files/src/index.js'
Target //server:server failed to build
Use --verbose_failures to see the command lines of failed build steps.
ERROR: /home/flo/Desktop/my-own-minimal-bazel/server/BUILD:15:1 1 input file(s) do not exist
I can only get the repo to build if I break up the ts_library into two seperate ts_libs, one for the library, and one for the index.ts:
load("@io_bazel_rules_docker//nodejs:image.bzl", "nodejs_image")
load("@npm_bazel_typescript//:index.bzl", "ts_library")
ts_library(
name = "lib",
srcs = [
"util.ts",
],
)
ts_library(
name = "main",
srcs = [
"index.ts",
],
deps = [":lib"],
)
filegroup(
name = "libfiles",
srcs = ["lib"],
output_group = "es5_sources",
)
filegroup(
name = "mainfile",
srcs = ["main"],
output_group = "es5_sources",
)
nodejs_image(
name = "server",
data = [
":libfiles",
":mainfile",
],
entry_point = ":mainfile",
)
The above code is in a pull request to your repo. I'm not sure why you are unable to reference a single file of the filegroup!