| 1 |
load("@rules_nodejs//:index.bzl", "nodejs_binary") |
| 2 |
|
| 3 |
package( |
| 4 |
default_applicable_licenses = ["//:license"], |
| 5 |
) |
| 6 |
|
| 7 |
licenses(["notice"]) |
| 8 |
|
| 9 |
# This is the easiest way to make sure we have a karma binary and all |
| 10 |
# the plugins loaded into the node_modules folder in |
| 11 |
# $SANDBOX_EXEC_ROOT/node_modules |
| 12 |
# where the karma binary is invoked from. Other attempts to do this |
| 13 |
# involving DefaultInfo [1] and depsets [2] didn't quite work because |
| 14 |
# the transitive dependencies appear to have been loaded in |
| 15 |
# $SANDBOX_EXEC_ROOT/bazel-out/k8-opt/bin/modules/canvaskit/canvaskit_js_tests.runfiles/npm/node_modules/ |
| 16 |
# instead, which is not where karma could find them. (Putting transitive |
| 17 |
# deps under bazel-out works for C++ because we can add to the include |
| 18 |
# search directories (via --include-directory or -I), but it is not clear |
| 19 |
# how to expand karma's search path like that. |
| 20 |
# |
| 21 |
# Below basically says "We have a karma binary which needs these plugins to run" |
| 22 |
# and have the karma_test macro use this as the executable instead of karma |
| 23 |
# directly. This must be used in conjunction with listing the plugins in the |
| 24 |
# karma configuration file (handled by karma_test). |
| 25 |
nodejs_binary( |
| 26 |
name = "karma_with_plugins", |
| 27 |
data = [ |
| 28 |
"@npm//jasmine-core", |
| 29 |
"@npm//karma", |
| 30 |
"@npm//karma-chrome-launcher", |
| 31 |
"@npm//karma-firefox-launcher", |
| 32 |
"@npm//karma-jasmine", |
| 33 |
], |
| 34 |
entry_point = {"@npm//:node_modules/karma": "bin/karma"}, |
| 35 |
visibility = ["//modules:__subpackages__"], |
| 36 |
) |