Bazel/NodeJS - nodejs_binary data referencing another rule not working as expected

97 Views Asked by At

We have a monorepo with several typescript code bases and want to have some shared code:

The common code is:

ts_project(
    name = "common",
    srcs = glob(
        ["**/*.ts"],
        exclude = ["**/*.spec.ts"],
    ),
    composite = True,
    tsconfig = "//:tsconfig_node",
    visibility = ["//visibility:public"],
    deps = [
        "@npm//@types/node",
    ],
)

I can reference common just fine from other ts_projects:

ts_project(
    name = "app",
    ...
     deps = [
        "//common:common",
    ]

I am looking to do the same for a nodejs_binary rule (in this case using the Parcel bundler):

load("@npm//parcel:index.bzl", "parcel")

# UI production build using parcel.
parcel(
    name = "build",
    data = ui_srcs + [
        "//:tsconfig.json",
        "//common:common",
        "@npm//:node_modules",
        ".parcelrc",
        ".terserrc",
    ],
    output_dir = True,
)

However it fails as it can't find the common files, and running with sandbox debug shows the contents of content are not being copied over. Any suggestions on how to achieve this or am I missing something obvious?

thanks!

0

There are 0 best solutions below