aspect-build / rules_js

High-performance Bazel rules for running Node.js tools and building JavaScript projects
https://docs.aspect.build/rules/aspect_rules_js
Apache License 2.0
310 stars 107 forks source link

[Bug]: js_image_layer does not include repo mapping file in app layer #1973

Closed jfirebaugh closed 2 weeks ago

jfirebaugh commented 1 month ago

What happened?

js_image_layer omits the repo mapping file, so @bazel/runfiles resolution fails inside the resulting container when bzlmod is enabled.

Version

Development (host) and target OS/architectures:

Output of bazel --version: 7.3.1

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

Language(s) and/or frameworks involved:

How to reproduce

Via `js_image_layer`, build a container image containing a `js_binary` target with a runfiles dependency, and with bzlmod enabled. The binary can do nothing but:

const runfiles = require('@bazel/runfiles')
runfiles.resolve('<repo name>/<runfile>')

Run the container. It will fail with "Error: could not resolve module /".

If you inspect the container contents (e.g. with dive), you can see that the app layer has no .repo_mapping file.



### Any other information?

_No response_
thesayyn commented 1 month ago

This needs to be fixed in js_image_layer. However I'd like to take this opportunity and drop js_image_layers custom nodejs program