aspect-build / rules_webpack

Bazel rules for webpack bundler https://webpack.js.org/
Apache License 2.0
32 stars 15 forks source link

[Bug]: rules_webpack doesn't parse pnpm lockfile v6 (which writes version as string) #114

Closed pswaminathan closed 1 year ago

pswaminathan commented 1 year ago

What happened?

  1. pnpm install webpack webpack-cli
  2. bazel build examples

Expect: Success

See:

$ bazel build models:all
INFO: Repository npm instantiated at:
  /Users/p/Code/ergatta/arm2/WORKSPACE:494:19: in <toplevel>
  /private/var/tmp/_bazel_p/5462d161dadab65df3f9fb5a8ecf08b9/external/aspect_rules_js/npm/npm_import.bzl:434:24: in npm_translate_lock
Repository rule npm_translate_lock defined at:
  /private/var/tmp/_bazel_p/5462d161dadab65df3f9fb5a8ecf08b9/external/aspect_rules_js/npm/private/npm_translate_lock.bzl:101:37: in <toplevel>
ERROR: An error occurred during the fetch of repository 'npm':
   Traceback (most recent call last):
    File "/private/var/tmp/_bazel_p/5462d161dadab65df3f9fb5a8ecf08b9/external/aspect_rules_js/npm/private/npm_translate_lock.bzl", line 57, column 41, in _impl
        state = npm_translate_lock_state.new(rctx)
    File "/private/var/tmp/_bazel_p/5462d161dadab65df3f9fb5a8ecf08b9/external/aspect_rules_js/npm/private/npm_translate_lock_state.bzl", line 538, column 10, in _new
        _init(priv, rctx, label_store)
    File "/private/var/tmp/_bazel_p/5462d161dadab65df3f9fb5a8ecf08b9/external/aspect_rules_js/npm/private/npm_translate_lock_state.bzl", line 57, column 23, in _init
        _load_lockfile(priv, rctx, label_store)
    File "/private/var/tmp/_bazel_p/5462d161dadab65df3f9fb5a8ecf08b9/external/aspect_rules_js/npm/private/npm_translate_lock_state.bzl", line 449, column 70, in _load_lockfile
        importers, packages, patched_dependencies = utils.parse_pnpm_lock(rctx.read(label_store.path("pnpm_lock")))
    File "/private/var/tmp/_bazel_p/5462d161dadab65df3f9fb5a8ecf08b9/external/aspect_rules_js/npm/private/utils.bzl", line 76, column 29, in _parse_pnpm_lock
        _assert_lockfile_version(parsed["lockfileVersion"])
    File "/private/var/tmp/_bazel_p/5462d161dadab65df3f9fb5a8ecf08b9/external/aspect_rules_js/npm/private/utils.bzl", line 95, column 13, in _assert_lockfile_version
        fail("version should be passed as a float")
Error in fail: version should be passed as a float
ERROR: /Users/p/Code/ergatta/arm2/WORKSPACE:494:19: fetching npm_translate_lock rule //external:npm: Traceback (most recent call last):
    File "/private/var/tmp/_bazel_p/5462d161dadab65df3f9fb5a8ecf08b9/external/aspect_rules_js/npm/private/npm_translate_lock.bzl", line 57, column 41, in _impl
        state = npm_translate_lock_state.new(rctx)
    File "/private/var/tmp/_bazel_p/5462d161dadab65df3f9fb5a8ecf08b9/external/aspect_rules_js/npm/private/npm_translate_lock_state.bzl", line 538, column 10, in _new
        _init(priv, rctx, label_store)
    File "/private/var/tmp/_bazel_p/5462d161dadab65df3f9fb5a8ecf08b9/external/aspect_rules_js/npm/private/npm_translate_lock_state.bzl", line 57, column 23, in _init
        _load_lockfile(priv, rctx, label_store)
    File "/private/var/tmp/_bazel_p/5462d161dadab65df3f9fb5a8ecf08b9/external/aspect_rules_js/npm/private/npm_translate_lock_state.bzl", line 449, column 70, in _load_lockfile
        importers, packages, patched_dependencies = utils.parse_pnpm_lock(rctx.read(label_store.path("pnpm_lock")))
    File "/private/var/tmp/_bazel_p/5462d161dadab65df3f9fb5a8ecf08b9/external/aspect_rules_js/npm/private/utils.bzl", line 76, column 29, in _parse_pnpm_lock
        _assert_lockfile_version(parsed["lockfileVersion"])
    File "/private/var/tmp/_bazel_p/5462d161dadab65df3f9fb5a8ecf08b9/external/aspect_rules_js/npm/private/utils.bzl", line 95, column 13, in _assert_lockfile_version
        fail("version should be passed as a float")
Error in fail: version should be passed as a float
ERROR: Error computing the main repository mapping: no such package '@npm//': version should be passed as a float
Loading:

Looking in the examples, I see

lockfileVersion: 5.4

Looking in my lock, I see:

$ head -n 1 pnpm-lock.yaml
lockfileVersion: '6.0'

Version

Development host: macOS Ventura 13.3.1

Output of bazel --version:

Aspect CLI version: 5.2.0
Build label: 6.1.1
Build target: bazel-out/darwin_arm64-opt/bin/src/main/java/com/google/devtools/build/lib/bazel/BazelServer_deploy.jar
Build time: Wed Mar 15 15:45:56 2023 (1678895156)
Build timestamp: 1678895156
Build timestamp as int: 1678895156

Version of the Aspect rules, or other relevant rules from your WORKSPACE or MODULE.bazel file: 0.12.0

How to reproduce

Install latest version of pnpm and try basic steps in example.

Any other information?

No response

jbedard commented 1 year ago

This is a rules_js issue fixed in v1.24: https://github.com/aspect-build/rules_js/commit/002397780d51735f1a98b362fca7018df31e85ac

pswaminathan commented 1 year ago

Whoops, I should have checked rules_js—it was right there in the traceback. Thanks for flagging!