bazelbuild / examples

Examples for Bazel
http://bazel.build
Apache License 2.0
800 stars 497 forks source link

[Bug]: pnpm v9 lockfile issues for frontend examples #464

Open dkthezero opened 3 weeks ago

dkthezero commented 3 weeks ago

Reproduce:

Then the error occur:

Repository rule npm_translate_lock_rule defined at:
  /private/var/tmp/_bazel_dkthezero/f3a599e6e224858962c4e41ca1d729db/external/aspect_rules_js~/npm/private/npm_translate_lock.bzl:145:42: in <toplevel>
ERROR: An error occurred during the fetch of repository 'aspect_rules_js~~npm~npm':
   Traceback (most recent call last):
        File "/private/var/tmp/_bazel_dkthezero/f3a599e6e224858962c4e41ca1d729db/external/aspect_rules_js~/npm/private/npm_translate_lock.bzl", line 117, column 45, in _npm_translate_lock_impl
                helpers.verify_lifecycle_hooks_specified(rctx, state)
        File "/private/var/tmp/_bazel_dkthezero/f3a599e6e224858962c4e41ca1d729db/external/aspect_rules_js~/npm/private/npm_translate_lock_helpers.bzl", line 585, column 13, in _verify_lifecycle_hooks_specified
                fail("""\
Error in fail: ERROR: pnpm.onlyBuiltDependencies required in pnpm workspace root package.json when using pnpm v9 or later

As of pnpm v9, the lockfile no longer specifies if packages have lifecycle hooks.

Packages that rules_js should generate lifecycle hook actions for must now be declared in
pnpm.onlyBuiltDependencies in the pnpm workspace root package.json. See
https://pnpm.io/package_json#pnpmonlybuiltdependencies for more information.

Prior to pnpm v9, rules_js keyed off of the requiresBuild attribute in the pnpm lock
file to determine if a lifecycle hook action should be generated for an npm package.
See [pnpm #7707](https://github.com/pnpm/pnpm/issues/7707) for the reasons that pnpm
removed the requiredBuild attribute from the lockfile in v9.

Fix: Downgrade the pnpm to v8.15.8. Expectation: can run with pnpm v9