Skip to content

[FR]: Automatically generate binary and library targets #1728

@jrandolf

Description

@jrandolf

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:

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

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",
)

Metadata

Metadata

Assignees

No one assigned

    Labels

    blockedBlocked by another issueenhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions