aspect-build / aspect-build/rules_js

[FR]: Automatically generate binary and library targets

Open
#1,728 7 comments 0 reactions 0 assignees View on GitHub
blocked enhancement
Dominant language
Starlark
Stars
378
Forks
183
Avg merge
1d 9h
Merged PRs (30d)
32

Description

### What is the current behavior?

For library targets, users must use `npm_link_all_packages` to link libraries before using `:node_modules`. For binary targets, users need to import the `bin` object for a library and manually declare it.

### Describe the feature

Instead of:

```bazel
load("@aspect_rules_js//js:defs.bzl", "js_library")
load("@npm//:defs.bzl", "npm_link_all_packages")
load("@npm//:typescript/package_json.bzl", "bin") # This is just an example
load("@aspect_rules_js//js:defs.bzl", "js_run_binary")

npm_link_all_packages()

js_library(
name = "test",
deps = [
":node_modules/lodash"
]
)

bin.typescript_binary(
name = "typescript",
)

js_run_binary(
name = "t2",
tool = ":typescript",
)
```

let's do

```bazel
load("@aspect_rules_js//js:defs.bzl", "js_library")
load("@npm//:defs.bzl", "npm_link_all_packages")
load("@npm//:typescript/package_json.bzl", "bin") # This is just an example

js_library(
name = "test",
deps = [
"@npm//:node_modules/lodash" # Or preferably "@npm//node_modules/lodash"
]
)

js_run_binary(
name = "t2",
tool = "@npm//node_modules/typscript/bin:typescript",
)
```

Contributor guide

Open the contributing guide

Research direction

Start by comparing the current and proposed Bazel examples around js_library, js_run_binary, npm_link_all_packages, and the package_json.bzl bin entry point. Define the target-generation behavior needed for library and binary packages, then verify that the proposed labels work without the manual linking and imports shown in the current example.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript, nodejs
Domain
build-system, tooling
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.