aspect-build / aspect-build/rules_js

[Bug]: Issue bundling `js_binary` into a tar

Open
#2,465 3 comments 1 reaction 0 assignees View on GitHub
bug
Dominant language
Starlark
Stars
378
Forks
183
Avg merge
1d 9h
Merged PRs (30d)
32

Description

### What happened?

_Note I was unsure whether to put this into `rules_js` or `tar.bzl`._

Attempting to bundle this:

```starlark
load("@npm//:defs.bzl", "npm_link_all_packages")
load("@npm//:xlsx-cli/package_json.bzl", xlsx_cli_bin = "bin")
load("@tar.bzl", "tar")

npm_link_all_packages(
name = "node_modules",
)

xlsx_cli_bin.xlsx_cli_binary(
name = "xlsx_cli",
)

tar(
name = "xlsx_cli_archive",
srcs = [
":xlsx_cli",
],
)
```

Gives:

```
tar: Error reading archive bazel-out/k8-fastbuild/bin/xlsx_cli_archive_mtree.txt: mtree specification has different type for xlsx_cli_/xlsx_cli.runfiles/_main/node_modules/.aspect_rules_js/@cdn.sheetjs.com+xlsx-cli+xlsx-cli-1.1.4.tgz/node_modules/commander
```

Full repro: https://github.com/njlr/rules_js_tar_repro

### Version

Development (host) and target OS/architectures:

Output of `bazel --version`: `8.4.2`

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

```starlark
"""rules_js_tar_repro"""

bazel_dep(name = "aspect_rules_js", version = "2.2.0")
bazel_dep(name = "tar.bzl", version = "0.6.0")

npm = use_extension(
"@aspect_rules_js//npm:extensions.bzl",
"npm",
dev_dependency = True,
)

npm.npm_translate_lock(
name = "npm",
pnpm_lock = "//:pnpm-lock.yaml",
verify_node_modules_ignored = "//:.bazelignore",
)
use_repo(npm, "npm")
```

Language(s) and/or frameworks involved:

`tar.bzl`

### How to reproduce

See https://github.com/njlr/rules_js_tar_repro

### Any other information?

Might be an issue with `tar.bzl`?

Contributor guide

Open the contributing guide

Research direction

Start with the linked full repro and reproduce the tar() failure using the shown js_binary and npm setup. Inspect the generated xlsx_cli_archive_mtree.txt entry for commander and trace how tar.bzl handles the js_binary runfiles tree. Done means the archive builds without the mtree type conflict.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript
Domain
build-system
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.