| load("@bazel_lib//lib:diff_test.bzl", "diff_test") |
| load("@bazel_skylib//rules:build_test.bzl", "build_test") |
| load("@npm//:defs.bzl", "npm_link_all_packages", "npm_link_targets") |
| load("@pnpm__links//:defs.bzl", npm_link_pnpm = "npm_link_imported_package") |
| load("//js:defs.bzl", "js_library") |
| |
| # Link all packages from the /MODULE npm_translate_lock(name = "npm") and also packages from |
| # manual /MODULE npm_import rules to bazel-bin/node_modules as well as the package store |
| # bazel-bin/node_modules/.aspect_rules_js since /pnpm-lock.yaml is the root of the pnpm workspace |
| npm_link_all_packages( |
| imported_links = [ |
| npm_link_pnpm, |
| ], |
| ) |
| |
| # Ensure that jsonplus-plus is in the output tree for the @kubernetes/client-node sandboxed lifecycle |
| # hook test case |
| build_test( |
| name = "node_modules_build_test", |
| targets = ["//:node_modules"], |
| ) |
| |
| # buildifier: disable=duplicated-name |
| NODE_MODULES = npm_link_targets( |
| package = package_name(), |
| ) + [ |
| "//:node_modules/pnpm", |
| ] |
| |
| js_library( |
| name = "npm_link_targets_node_modules", |
| srcs = NODE_MODULES, |
| ) |
| |
| build_test( |
| name = "npm_link_targets_node_modules_build_test", |
| targets = ["//:npm_link_targets_node_modules"], |
| ) |
| |
| genquery( |
| name = "query_node_modules", |
| expression = "deps(//:node_modules) - //:node_modules", |
| scope = ["//:node_modules"], |
| ) |
| |
| genquery( |
| name = "query_npm_link_targets_node_modules", |
| expression = "deps(//:npm_link_targets_node_modules) - //:npm_link_targets_node_modules", |
| scope = ["//:npm_link_targets_node_modules"], |
| ) |
| |
| # Verifies that the targets list in //:npm_link_targets_node_modules is the same as //:node_modules |
| diff_test( |
| name = "npm_link_targets_test", |
| file1 = "query_node_modules", |
| file2 = "query_npm_link_targets_node_modules", |
| ) |
| |
| alias( |
| name = "format", |
| actual = "//tools/format", |
| ) |
| |
| alias( |
| name = "buildifier", |
| actual = "@buildifier_prebuilt//buildifier", |
| ) |