Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: include package store directory in default output of npm_link_package_store #1762

Merged
merged 1 commit into from
May 28, 2024

Conversation

gregmagolan
Copy link
Member

@gregmagolan gregmagolan commented May 28, 2024

Having a dangling symlink as the default output of :node_modules/foo npm_link_package_store targets breaks genrules that worked in rules_js 1.0 since they needed to also depend on :node_modules/foo. This change fixes that use case.

It also resolves an npm_package bug where if a :node_modules/foo was included in sources, the underlying copy_to_directory action would fail to resolve the realpath of the dangling symlink and fail. This bug was reported in RELEASE 2.0 tracking issue: #1671 (comment). The issue was due to :node_modules/foo targets only having the symlink to package store in their default output and not the package store itself. This caused copy_to_directory to fail to follow the symlink since the package store directory was not in the output tree. NB: since the exclude srcs pattern includes **/node_modules/** the underlying copy_to_directory tool should not try to realpath that file since it is excluded from copying. That upstream fix is in progress here: bazel-contrib/bazel-lib#857.

Test plan

  • Covered by existing test cases
  • Added new test case

//npm/private/test/npm_package:pkg_2 fails with

ERROR: /Users/greg/aspect/rules/js/rules_js/npm/private/test/npm_package/BUILD.bazel:31:12: Copying files to directory npm/private/test/npm_package/pkg_2 failed: (Exit 1): copy_to_directory failed: error executing CopyToDirectory command (from target //npm/private/test/npm_package:pkg_2) external/aspect_bazel_lib~~toolchains~copy_to_directory_darwin_arm64/copy_to_directory bazel-out/darwin_arm64-fastbuild/bin/npm/private/test/npm_package/pkg_2_config.json ''
2024/05/28 02:58:46 lstat bazel-out/darwin_arm64-fastbuild/bin/npm/private/test/npm_package/node_modules/chalk failed: lstat bazel-out/darwin_arm64-fastbuild/bin/node_modules/.aspect_rules_js/chalk@5.0.1/node_modules/chalk: no such file or directory

without this patch

Copy link

aspect-workflows bot commented May 28, 2024

Test

1 test target passed

Targets
//npm/private/test/npm_package:test_pkg_2 [k8-fastbuild]                165ms

Total test execution time was 165ms. 192 tests (99.5%) were fully cached saving 53s.


Test

e2e/bzlmod

All tests were cache hits

4 tests (100.0%) were fully cached saving 467ms.


Test

e2e/gyp_no_install_script

All tests were cache hits

2 tests (100.0%) were fully cached saving 693ms.


Test

e2e/js_image_oci

All tests were cache hits

1 test (100.0%) was fully cached saving 9s.


Test

e2e/npm_link_package

All tests were cache hits

2 tests (100.0%) were fully cached saving 1s.


Test

e2e/npm_link_package-esm

All tests were cache hits

2 tests (100.0%) were fully cached saving 923ms.


Test

e2e/npm_translate_lock

All tests were cache hits

1 test (100.0%) was fully cached saving 73ms.


Test

e2e/npm_translate_lock_empty

All tests were cache hits

1 test (100.0%) was fully cached saving 73ms.


Test

e2e/npm_translate_lock_multi

All tests were cache hits

2 tests (100.0%) were fully cached saving 271ms.


Test

e2e/npm_translate_lock_partial_clone

All tests were cache hits

1 test (100.0%) was fully cached saving 117ms.


Test

e2e/npm_translate_lock_subdir_patch

All tests were cache hits

1 test (100.0%) was fully cached saving 248ms.


Test

e2e/npm_translate_package_lock

All tests were cache hits

1 test (100.0%) was fully cached saving 73ms.


Test

e2e/npm_translate_yarn_lock

All tests were cache hits

1 test (100.0%) was fully cached saving 73ms.


Test

e2e/package_json_module

All tests were cache hits

1 test (100.0%) was fully cached saving 520ms.


Test

e2e/pnpm_lockfiles

All tests were cache hits

21 tests (100.0%) were fully cached saving 7s.


Test

e2e/pnpm_workspace

All tests were cache hits

8 tests (100.0%) were fully cached saving 3s.


Test

e2e/pnpm_workspace_rerooted

All tests were cache hits

6 tests (100.0%) were fully cached saving 2s.


Test

e2e/repo_mapping

All tests were cache hits

2 tests (100.0%) were fully cached saving 451ms.


Test

e2e/rules_foo

All tests were cache hits

2 tests (100.0%) were fully cached saving 605ms.


Test

e2e/vendored_node

All tests were cache hits

1 test (100.0%) was fully cached saving 187ms.


Buildifier      Format

@gregmagolan gregmagolan marked this pull request as ready for review May 28, 2024 09:50
@gregmagolan gregmagolan force-pushed the fixup_node_modules_foo_default_info branch from 50dfb58 to 47b4387 Compare May 28, 2024 09:53
@gregmagolan gregmagolan requested a review from jbedard May 28, 2024 09:53
@gregmagolan gregmagolan force-pushed the fixup_node_modules_foo_default_info branch from 47b4387 to 2517a35 Compare May 28, 2024 10:00
@gregmagolan gregmagolan mentioned this pull request May 28, 2024
21 tasks
@gregmagolan gregmagolan force-pushed the fixup_node_modules_foo_default_info branch 4 times, most recently from 7a31989 to 0855720 Compare May 28, 2024 18:00
@gregmagolan gregmagolan force-pushed the fixup_node_modules_foo_default_info branch from 0855720 to 4923fbf Compare May 28, 2024 18:01
@gregmagolan gregmagolan merged commit 86469b8 into main May 28, 2024
107 checks passed
@gregmagolan gregmagolan deleted the fixup_node_modules_foo_default_info branch May 28, 2024 18:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants