Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 0 additions & 2 deletions BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ load("//npm:defs.bzl", "npm_link_package")
# manual /WORKSPACE 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(
name = "node_modules",
imported_links = [
npm_link_acorn,
npm_link_pnpm,
Expand All @@ -27,7 +26,6 @@ build_test(

# buildifier: disable=duplicated-name
NODE_MODULES = npm_link_targets(
name = "node_modules",
package = package_name(),
) + [
"//:node_modules/acorn",
Expand Down
4 changes: 2 additions & 2 deletions docs/migrate.md
Original file line number Diff line number Diff line change
Expand Up @@ -114,12 +114,12 @@ As long as you're able to run your build and test under pnpm, we expect the beha

## Link the node modules

Typically you just add a `npm_link_all_packages(name = "node_modules")` call to the BUILD file next to each `package.json` file:
Typically you just add a `npm_link_all_packages()` call to the BUILD file next to each `package.json` file:

```starlark
load("@npm//:defs.bzl", "npm_link_all_packages")

npm_link_all_packages(name = "node_modules")
npm_link_all_packages()
```

This macro will expand to a rule for each npm package, which creates part of the `bazel-bin/[path/to/package]/node_modules` tree.
Expand Down
5 changes: 2 additions & 3 deletions docs/npm_import.md

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 2 additions & 5 deletions docs/npm_link_all_packages.md

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion e2e/bzlmod/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ not_windows = select({
})

npm_link_all_packages(
name = "node_modules",
imported_links = [
npm_link_meaning_of_life,
],
Expand Down
2 changes: 1 addition & 1 deletion e2e/bzlmod/other_module/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
load("@npm_other_module//:defs.bzl", "npm_link_all_packages")
load("@npm_other_module//:pyright/package_json.bzl", pyright = "bin")

npm_link_all_packages(name = "node_modules")
npm_link_all_packages()

pyright.pyright_binary(
name = "pyright",
Expand Down
2 changes: 1 addition & 1 deletion e2e/gyp_no_install_script/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ load("@aspect_bazel_lib//lib:write_source_files.bzl", "write_source_files")
load("@aspect_rules_js//js:defs.bzl", "js_test")
load("@npm//:defs.bzl", "npm_link_all_packages")

npm_link_all_packages(name = "node_modules")
npm_link_all_packages()

js_test(
name = "test",
Expand Down
2 changes: 1 addition & 1 deletion e2e/js_image_docker/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ load("@io_bazel_rules_docker//container:layer.bzl", "container_layer")
load("@io_bazel_rules_docker//contrib:test.bzl", "container_test")
load("@npm//:defs.bzl", "npm_link_all_packages")

npm_link_all_packages(name = "node_modules")
npm_link_all_packages()

platform(
name = "arm64_linux",
Expand Down
2 changes: 1 addition & 1 deletion e2e/js_image_oci/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
load("@npm//:defs.bzl", "npm_link_all_packages")

npm_link_all_packages(name = "node_modules")
npm_link_all_packages()
2 changes: 1 addition & 1 deletion e2e/js_image_oci/pkg/a/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
load("@aspect_rules_js//npm:defs.bzl", "npm_package")
load("@npm//:defs.bzl", "npm_link_all_packages")

npm_link_all_packages(name = "node_modules")
npm_link_all_packages()

npm_package(
name = "pkg",
Expand Down
2 changes: 1 addition & 1 deletion e2e/js_image_oci/pkg/b/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
load("@aspect_rules_js//js:defs.bzl", "js_library")
load("@npm//:defs.bzl", "npm_link_all_packages")

npm_link_all_packages(name = "node_modules")
npm_link_all_packages()

js_library(
name = "pkg",
Expand Down
2 changes: 1 addition & 1 deletion e2e/js_run_devserver/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
load("@bazel_skylib//rules:build_test.bzl", "build_test")
load("@npm//:defs.bzl", "npm_link_all_packages")

npm_link_all_packages(name = "node_modules")
npm_link_all_packages()

build_test(
name = "test",
Expand Down
2 changes: 1 addition & 1 deletion e2e/npm_link_package-esm/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ load("@bazel_skylib//rules:build_test.bzl", "build_test")
load("@foo//:@aspect-test/a/package_json.bzl", aspect_test_a_bin = "bin")
load("@npm//:defs.bzl", "npm_link_all_packages")

npm_link_all_packages(name = "node_modules")
npm_link_all_packages()

npm_link_package(
name = "node_modules/@e2e/lib",
Expand Down
2 changes: 1 addition & 1 deletion e2e/npm_link_package-rerooted/root/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ load("@bazel_skylib//rules:build_test.bzl", "build_test")
load("@foo//:@aspect-test/a/package_json.bzl", aspect_test_a_bin = "bin")
load("@npm//:defs.bzl", "npm_link_all_packages")

npm_link_all_packages(name = "node_modules")
npm_link_all_packages()

npm_link_package(
name = "node_modules/@e2e/lib",
Expand Down
2 changes: 1 addition & 1 deletion e2e/npm_link_package/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ load("@bazel_skylib//rules:build_test.bzl", "build_test")
load("@foo//:@aspect-test/a/package_json.bzl", aspect_test_a_bin = "bin")
load("@npm//:defs.bzl", "npm_link_all_packages")

npm_link_all_packages(name = "node_modules")
npm_link_all_packages()

npm_link_package(
name = "node_modules/@e2e/lib",
Expand Down
2 changes: 1 addition & 1 deletion e2e/npm_translate_lock/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ load("@aspect_bazel_lib//lib:write_source_files.bzl", "write_source_files")
load("@bazel_skylib//rules:build_test.bzl", "build_test")
load("@npm//:defs.bzl", "npm_link_all_packages")

npm_link_all_packages(name = "node_modules")
npm_link_all_packages()

build_test(
name = "test",
Expand Down
2 changes: 1 addition & 1 deletion e2e/npm_translate_lock_auth/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
load("@bazel_skylib//rules:build_test.bzl", "build_test")
load("@npm//:defs.bzl", "npm_link_all_packages")

npm_link_all_packages(name = "node_modules")
npm_link_all_packages()

build_test(
name = "test",
Expand Down
2 changes: 1 addition & 1 deletion e2e/npm_translate_lock_disable_hooks/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ load("@aspect_bazel_lib//lib:write_source_files.bzl", "write_source_files")
load("@bazel_skylib//rules:build_test.bzl", "build_test")
load("@npm//:defs.bzl", "npm_link_all_packages")

npm_link_all_packages(name = "node_modules")
npm_link_all_packages()

build_test(
name = "test",
Expand Down
2 changes: 1 addition & 1 deletion e2e/npm_translate_lock_empty/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ load("@aspect_bazel_lib//lib:write_source_files.bzl", "write_source_files")
load("@bazel_skylib//rules:build_test.bzl", "build_test")
load("@npm//:defs.bzl", "npm_link_all_packages")

npm_link_all_packages(name = "node_modules")
npm_link_all_packages()

build_test(
name = "test",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
load("@npm//:defs.bzl", "npm_link_all_packages")

npm_link_all_packages(name = "node_modules")
npm_link_all_packages()

sh_test(
name = "test_sh",
Expand Down
2 changes: 1 addition & 1 deletion e2e/npm_translate_lock_git+ssh/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
load("@bazel_skylib//rules:build_test.bzl", "build_test")
load("@npm//:defs.bzl", "npm_link_all_packages")

npm_link_all_packages(name = "node_modules")
npm_link_all_packages()

build_test(
name = "test",
Expand Down
2 changes: 1 addition & 1 deletion e2e/npm_translate_lock_partial_clone/root/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
load("@bazel_skylib//rules:build_test.bzl", "build_test")
load("@npm//:defs.bzl", "npm_link_all_packages")

npm_link_all_packages(name = "node_modules")
npm_link_all_packages()

build_test(
name = "test",
Expand Down
2 changes: 1 addition & 1 deletion e2e/npm_translate_lock_replace_packages/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ load("@aspect_rules_js//npm:defs.bzl", "npm_package")
load("@bazel_skylib//rules:build_test.bzl", "build_test")
load("@npm//:defs.bzl", "npm_link_all_packages")

npm_link_all_packages(name = "node_modules")
npm_link_all_packages()

js_test(
name = "test",
Expand Down
2 changes: 1 addition & 1 deletion e2e/npm_translate_lock_subdir_patch/subdir/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
load("@aspect_rules_js//js:defs.bzl", "js_test")
load("@npm//:defs.bzl", "npm_link_all_packages")

npm_link_all_packages(name = "node_modules")
npm_link_all_packages()

js_test(
name = "test",
Expand Down
2 changes: 1 addition & 1 deletion e2e/npm_translate_package_lock/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
load("@bazel_skylib//rules:build_test.bzl", "build_test")
load("@npm//:defs.bzl", "npm_link_all_packages")

npm_link_all_packages(name = "node_modules")
npm_link_all_packages()

build_test(
name = "test",
Expand Down
2 changes: 1 addition & 1 deletion e2e/npm_translate_yarn_lock/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
load("@bazel_skylib//rules:build_test.bzl", "build_test")
load("@npm//:defs.bzl", "npm_link_all_packages")

npm_link_all_packages(name = "node_modules")
npm_link_all_packages()

build_test(
name = "test",
Expand Down
2 changes: 1 addition & 1 deletion e2e/package_json_module/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
load("@npm//:defs.bzl", "npm_link_all_packages")
load("@npm//:mocha/package_json.bzl", mocha_bin = "bin")

npm_link_all_packages(name = "node_modules")
npm_link_all_packages()

mocha_bin.mocha_test(
name = "test",
Expand Down
2 changes: 1 addition & 1 deletion e2e/patch_from_repo/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
load("@bazel_skylib//rules:build_test.bzl", "build_test")
load("@npm//:defs.bzl", "npm_link_all_packages")

npm_link_all_packages(name = "node_modules")
npm_link_all_packages()

build_test(
name = "test",
Expand Down
2 changes: 1 addition & 1 deletion e2e/pnpm_lockfiles/lockfile-test.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ def lockfile_test(npm_link_all_packages, name = None):
lock_version = name if name else native.package_name()
lock_repo = "lock-%s" % lock_version

npm_link_all_packages(name = "node_modules")
npm_link_all_packages()

# Copy each test to this lockfile dir
for test in ["patched-dependencies-test.js", "aliases-test.js"]:
Expand Down
2 changes: 1 addition & 1 deletion e2e/pnpm_workspace/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ load("@aspect_bazel_lib//lib:write_source_files.bzl", "write_source_files")
load("@bazel_skylib//rules:build_test.bzl", "build_test")
load("@npm//:defs.bzl", "npm_link_all_packages")

npm_link_all_packages(name = "node_modules")
npm_link_all_packages()

sh_test(
name = "node_test",
Expand Down
2 changes: 1 addition & 1 deletion e2e/pnpm_workspace/app/a/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ load("@bazel_skylib//rules:build_test.bzl", "build_test")
load("@npm//:defs.bzl", "npm_link_all_packages", "npm_link_targets")
load("@npm//app/a:@aspect-test/a/package_json.bzl", aspect_test_a_bin = "bin")

npm_link_all_packages(name = "node_modules")
npm_link_all_packages()

js_binary(
name = "main",
Expand Down
2 changes: 1 addition & 1 deletion e2e/pnpm_workspace/app/b/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ load("@aspect_rules_js//js:defs.bzl", "js_binary", "js_test")
load("@bazel_skylib//rules:build_test.bzl", "build_test")
load("@npm//:defs.bzl", "npm_link_all_packages")

npm_link_all_packages(name = "node_modules")
npm_link_all_packages()

js_binary(
name = "main",
Expand Down
2 changes: 1 addition & 1 deletion e2e/pnpm_workspace/app/c/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ load("@aspect_rules_js//js:defs.bzl", "js_binary", "js_test")
load("@npm//:defs.bzl", "npm_link_all_packages")
load("@npm//app/a:@aspect-test/a/package_json.bzl", aspect_test_a_bin = "bin")

npm_link_all_packages(name = "node_modules")
npm_link_all_packages()

js_binary(
name = "main",
Expand Down
2 changes: 1 addition & 1 deletion e2e/pnpm_workspace/app/d/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
load("@aspect_rules_js//js:defs.bzl", "js_binary", "js_test")
load("@npm//:defs.bzl", "npm_link_all_packages")

npm_link_all_packages(name = "node_modules")
npm_link_all_packages()

js_binary(
name = "main",
Expand Down
2 changes: 1 addition & 1 deletion e2e/pnpm_workspace/lib/a/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ load("@aspect_rules_js//npm:defs.bzl", "npm_package")
load("@bazel_skylib//rules:build_test.bzl", "build_test")
load("@npm//:defs.bzl", "npm_link_all_packages")

npm_link_all_packages(name = "node_modules")
npm_link_all_packages()

npm_package(
name = "pkg",
Expand Down
2 changes: 1 addition & 1 deletion e2e/pnpm_workspace/lib/b/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ load("@aspect_rules_js//npm:defs.bzl", "npm_package")
load("@bazel_skylib//rules:build_test.bzl", "build_test")
load("@npm//:defs.bzl", "npm_link_all_packages")

npm_link_all_packages(name = "node_modules")
npm_link_all_packages()

npm_package(
name = "pkg",
Expand Down
2 changes: 1 addition & 1 deletion e2e/pnpm_workspace/lib/c/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
load("@aspect_rules_js//npm:defs.bzl", "npm_package")
load("@npm//:defs.bzl", "npm_link_all_packages")

npm_link_all_packages(name = "node_modules")
npm_link_all_packages()

npm_package(
name = "pkg",
Expand Down
2 changes: 1 addition & 1 deletion e2e/pnpm_workspace/lib/d/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ load("@aspect_rules_js//js:defs.bzl", "js_library")
load("@bazel_skylib//rules:build_test.bzl", "build_test")
load("@npm//:defs.bzl", "npm_link_all_packages")

npm_link_all_packages(name = "node_modules")
npm_link_all_packages()

js_library(
name = "pkg",
Expand Down
Loading
Loading