Skip to content

Can't use tsc output for js_library  #3329

@cartmanez

Description

@cartmanez

🐞 bug report

Affected Rule

tsc

Is this a regression?

Not sure. Did not use bazel before

Description

js_library works just fine for me when it depends on the output of ts_project.
However, I can't achieve the same using tsc.
I.e. the below does not produce valid package when dist is a tsc rule, and works when dist is ts_project


js_library(
    name = "package-a",
    package_name = "@my-scope/package-a",
    srcs = ["package.json",":dist"],
    deps = [":dist"],
)

🔬 Minimal Reproduction

https://github.com/cartmanez/bazel-ts-repo

In that repo /packages/package-b depends on /packages/package-a, /packages/package-d depends on /packages/package-c


# this command will fail, because //packages/package-a is built using tsc
bazel build //packages/package-b:dist


# this command will succeed - //packages/package-c is built using ts_project
bazel build //packages/package-d:dist

🔥 Exception or Error

When dependent package is built with tsc, it is present in node_modules folder in sandbox, but it's dist folder is empty

packages/package-b/src/index.ts:1:31 - error TS2307: Cannot find module '@my-scope/package-a'

🌍 Your Environment

Operating System:

  Linux archlinux 5.16.9-arch1-1 #1 SMP PREEMPT Fri, 11 Feb 2022 22:42:06 +0000 x86_64 GNU/Linux  

Output of bazel version:

  
Bazelisk version: v1.11.0
Build label: 5.0.0
Build target: bazel-out/k8-opt/bin/src/main/java/com/google/devtools/build/lib/bazel/BazelServer_deploy.jar
Build time: Wed Jan 19 14:08:54 2022 (1642601334)
Build timestamp: 1642601334
Build timestamp as int: 1642601334  

Rules_nodejs version:

  5.1.0  

Anything else relevant?
Seems like no. Thank you in advance!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions