blob: b88ec24f5bb27a304e01698e6a79e5faab6439dc [file] [log] [blame]
load("@build_bazel_rules_nodejs//:index.bzl", "nodejs_binary")
load("@npm//@bazel/typescript:index.bzl", "ts_library")
load("@npm//@bazel/rollup:index.bzl", "rollup_bundle")
package(default_visibility = ["//visibility:public"])
name = "licenses-map",
srcs = glob(["*.ts"]),
compiler = "//tools/node_tools:tsc_wrapped-bin",
tsconfig = "tsconfig.json",
deps = [
# rollup_bundle - workaround for
# The ts_library rule ("license-map") transpiles each .ts file to .js file.
# The "license-map" rule includes multiple .ts files and produces multiple output files.
# The nodejs_binary requires only one file as an entry_point. It is expected, that other
# .js files from ts_library are also available, but because of the bug they are not available.
# As a workaround we are using rollup_bundle to group all files together.
name = "license-map-generator-bundle",
config_file = "rollup.config.js",
entry_point = "license-map-generator.ts",
format = "cjs",
rollup_bin = "//tools/node_tools:rollup-bin",
deps = [
name = "license-map-generator-bin",
entry_point = "license-map-generator-bundle.js",
# (TODO)dmfilippov Find a better way to fix it (another workaround or submit a bug to
# plugin's authors or to a ts_config rule author).
# The following genrule is a workaround for a bazel intellij plugin's bug.
# According to the documentation, the ts_config_rules section should be added
# to a .bazelproject file if a project uses typescript
# (
# Unfortunately, this doesn't work. It seems, that the plugin expects some output from
# the ts_config rule, but the rule doesn't produce any output.
# To workaround the issue, the tsconfig_editor genrule was added. The genrule only copies
# input file to the output file, but this is enough to make bazel plugins works.
# So, if you have any problem a typescript editor (import errors, types not found, etc...) -
# try to build this rule from the command line
# (bazel build tools/node_tools/node_modules/licenses:tsconfig_editor) and then sync bazel project
# in intellij.
name = "tsconfig_editor",
srcs = ["tsconfig.json"],
outs = ["tsconfig_editor.json"],
cmd = "cp $< $@",