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