Skip to main content
Version: 1.34.x

npm_link_package

npm_link_package rule

Macros and Functions

"Links an npm package to node_modules if link is True.

When called at the root_package, a virtual store target is generated named link__{bazelified_name}__store.

When linking, a {name} target is generated which consists of the node_modules/<package> symlink and transitively its virtual store link and the virtual store links of the transitive closure of deps.

When linking, {name}/dir filegroup is also generated that refers to a directory artifact can be used to access the package directory for creating entry points or accessing files in the package.

Example usage (generated):

load("@aspect_rules_js//npm:defs.bzl", "npm_link_package")

npm_link_package(
# The name of the link target to create if `link` is True
name = "",
)

name

Required.

The name of the link target to create if link is True. For first-party deps linked across a workspace, the name must match in all packages being linked as it is used to derive the virtual store link target name.

root_package

Optional. Default: ""

the root package where the node_modules virtual store is linked to

Optional. Default: True

whether or not to link in this package If false, only the npmpackage_store target will be created _if this is called in the root_package.

src

Optional. Default: None

the npm_package target to link; may only to be specified when linking in the root package

deps

Optional. Default: {}

list of npm_package_store; may only to be specified when linking in the root package

Optional. Default: True

whether or not to fail if this is called in a package that is not the root package and link is False

auto_manual

Optional. Default: True

whether or not to automatically add a manual tag to the generated targets Links tagged "manual" dy default is desirable so that they are not built by bazel build ... if they are unused downstream. For 3rd party deps, this is particularly important so that 3rd party deps are not fetched at all unless they are used.

visibility

Optional. Default: ["//visibility:public"]

the visibility of the link target

kwargs

Optional.

see attributes of npm_package_store rule