Dmitrii Filippov | 047240b | 2020-01-14 20:33:05 +0100 | [diff] [blame] | 1 | load("@build_bazel_rules_nodejs//:index.bzl", "nodejs_binary") |
| 2 | |
| 3 | package(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, ...) |
| 9 | nodejs_binary( |
| 10 | name = "rollup-bin", |
Dmitrii Filippov | 7043396 | 2020-03-30 15:32:37 +0200 | [diff] [blame] | 11 | # Define only minimal required dependencies. |
| 12 | # Otherwise remote build execution fails with the too many |
| 13 | # files error when it builds :release target. |
Dmitrii Filippov | 047240b | 2020-01-14 20:33:05 +0100 | [diff] [blame] | 14 | data = [ |
Dmitrii Filippov | 7043396 | 2020-03-30 15:32:37 +0200 | [diff] [blame] | 15 | "@tools_npm//rollup", |
| 16 | "@tools_npm//rollup-plugin-terser", |
Dmitrii Filippov | 047240b | 2020-01-14 20:33:05 +0100 | [diff] [blame] | 17 | ], |
| 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 Ostrovsky | f2c9a3d | 2022-02-12 14:53:31 +0100 | [diff] [blame] | 31 | # TODO: Would be nice to just use `tsc-bin` below instead. |
| 32 | # We would prefer to not depend on @bazel/concatjs ... |
Dmitrii Filippov | 047240b | 2020-01-14 20:33:05 +0100 | [diff] [blame] | 33 | nodejs_binary( |
| 34 | name = "tsc_wrapped-bin", |
| 35 | # Point bazel to your node_modules to find the entry point |
Ben Rohlfs | a935bd0 | 2021-08-03 15:48:59 +0200 | [diff] [blame] | 36 | data = [ |
David Ostrovsky | f2c9a3d | 2022-02-12 14:53:31 +0100 | [diff] [blame] | 37 | "@tools_npm//@bazel/concatjs", |
Ben Rohlfs | a935bd0 | 2021-08-03 15:48:59 +0200 | [diff] [blame] | 38 | "@tools_npm//typescript", |
| 39 | ], |
Dmitrii Filippov | 047240b | 2020-01-14 20:33:05 +0100 | [diff] [blame] | 40 | # It seems, bazel uses different approaches to compile ts files (it runs some |
| 41 | # ts service in background). It works without any workaround. |
David Ostrovsky | f2c9a3d | 2022-02-12 14:53:31 +0100 | [diff] [blame] | 42 | entry_point = "@tools_npm//:node_modules/@bazel/concatjs/internal/tsc_wrapped/tsc_wrapped.js", |
Dmitrii Filippov | 047240b | 2020-01-14 20:33:05 +0100 | [diff] [blame] | 43 | ) |
Dmitrii Filippov | 897b58e | 2020-05-20 18:32:26 +0200 | [diff] [blame] | 44 | |
| 45 | # Wrap a typescript into a tsc-bin binary. |
| 46 | # The tsc-bin can be used as a tool to compile typescript code. |
| 47 | nodejs_binary( |
| 48 | name = "tsc-bin", |
| 49 | # Point bazel to your node_modules to find the entry point |
Ben Rohlfs | a935bd0 | 2021-08-03 15:48:59 +0200 | [diff] [blame] | 50 | data = ["@tools_npm//typescript"], |
Dmitrii Filippov | 897b58e | 2020-05-20 18:32:26 +0200 | [diff] [blame] | 51 | entry_point = "@tools_npm//:node_modules/typescript/lib/tsc.js", |
| 52 | ) |