blob: b14c0c6e1efd10cd327d69a3120a0bf56bf05f16 [file] [log] [blame]
Dmitrii Filippov047240b2020-01-14 20:33:05 +01001load("@build_bazel_rules_nodejs//:index.bzl", "nodejs_binary")
2
3package(default_visibility = ["//visibility:public"])
4
5# By default, rollup_bundle rule uses rollup from @npm workspace
6# and it expects that all plugins are installed in the same workspace.
7# This rule defines another rollup-bin from @tools_npm workspace.
8# Usage: rollup_bundle(rollup_bin = "//tools/node_tools:rollup-bin, ...)
9nodejs_binary(
10 name = "rollup-bin",
Dmitrii Filippov70433962020-03-30 15:32:37 +020011 # Define only minimal required dependencies.
12 # Otherwise remote build execution fails with the too many
13 # files error when it builds :release target.
Dmitrii Filippov047240b2020-01-14 20:33:05 +010014 data = [
Dmitrii Filippov70433962020-03-30 15:32:37 +020015 "@tools_npm//rollup",
16 "@tools_npm//rollup-plugin-terser",
Dmitrii Filippov047240b2020-01-14 20:33:05 +010017 ],
18 # The entry point must be "@tools_npm:node_modules/rollup/dist/bin/rollup",
19 # But bazel doesn't run it correctly with the following command line:
20 # bazel test --test_env=GERRIT_NOTEDB=ON --spawn_strategy=standalone \
21 # --genrule_strategy=standalone --test_output errors --test_summary detailed \
22 # --flaky_test_attempts 3 --test_verbose_timeout_warnings --build_tests_only \
23 # --subcommands //...
24 # This command line appears in Gerrit CI.
25 # For details, see comment in rollup-runner.js file
26 entry_point = "//tools/node_tools:rollup-runner.js",
27)
28
29# Create a tsc_wrapped compiler rule to use in the ts_library
30# compiler attribute when using self-managed dependencies
David Ostrovskyf2c9a3d2022-02-12 14:53:31 +010031# TODO: Would be nice to just use `tsc-bin` below instead.
32# We would prefer to not depend on @bazel/concatjs ...
Dmitrii Filippov047240b2020-01-14 20:33:05 +010033nodejs_binary(
34 name = "tsc_wrapped-bin",
35 # Point bazel to your node_modules to find the entry point
Ben Rohlfsa935bd02021-08-03 15:48:59 +020036 data = [
David Ostrovskyf2c9a3d2022-02-12 14:53:31 +010037 "@tools_npm//@bazel/concatjs",
Ben Rohlfsa935bd02021-08-03 15:48:59 +020038 "@tools_npm//typescript",
39 ],
Dmitrii Filippov047240b2020-01-14 20:33:05 +010040 # It seems, bazel uses different approaches to compile ts files (it runs some
41 # ts service in background). It works without any workaround.
David Ostrovskyf2c9a3d2022-02-12 14:53:31 +010042 entry_point = "@tools_npm//:node_modules/@bazel/concatjs/internal/tsc_wrapped/tsc_wrapped.js",
Dmitrii Filippov047240b2020-01-14 20:33:05 +010043)
Dmitrii Filippov897b58e2020-05-20 18:32:26 +020044
45# Wrap a typescript into a tsc-bin binary.
46# The tsc-bin can be used as a tool to compile typescript code.
47nodejs_binary(
48 name = "tsc-bin",
49 # Point bazel to your node_modules to find the entry point
Ben Rohlfsa935bd02021-08-03 15:48:59 +020050 data = ["@tools_npm//typescript"],
Dmitrii Filippov897b58e2020-05-20 18:32:26 +020051 entry_point = "@tools_npm//:node_modules/typescript/lib/tsc.js",
52)