Skip to content

document convenient way to lay out all files in bazel-out #1771

@mrmeku

Description

@mrmeku

🐞 bug report

Affected Rule

The issue is caused by the rule: ts_project

Is this a regression?

No

Description

Consider what happens when you try to bundle a index.js emited by ts_project.

index.js is placed in execroot/workspace/bazel-out/k8-fastbuild/bin/index.js and tries to do a relative import of a non-generated file something like ./styles.css (other common scenarios would be a local .js, or .json file)

styles.css is placed in execroot/workspace/styles.css

So the relative import fails since the bundler doesn't know how to resolve things living bazel-out vs not in bazel-out

In order to fix this sort of thing we'll either need to layout the directory structure differently or provide some documentation on ways to configure bundlers to resolve these imports.

A clear and concise description of the problem...

🔬 Minimal Reproduction

#1770

🔥 Exception or Error


ERROR in ./bazel-out/k8-fastbuild/bin/index.js
Module not found: Error: Can't resolve './styles.css' in '.../execroot/react_webpack/bazel-out/k8-fastbuild/bin'
 @ ./bazel-out/k8-fastbuild/bin/index.js 5:13-36

🌍 Your Environment

Output of bazel version:

  
Build label: 2.2.0
Build target: bazel-out/k8-opt/bin/src/main/java/com/google/devtools/build/lib/bazel/BazelServer_deploy.jar
Build time: Tue Mar 3 09:26:12 2020 (1583227572)
Build timestamp: 1583227572
Build timestamp as int: 1583227572
  

Rules_nodejs version:

(Please check that you have matching versions between WORKSPACE file and @bazel/* npm packages.)

  
http_archive(
    name = "build_bazel_rules_nodejs",
    sha256 = "d0c4bb8b902c1658f42eb5563809c70a06e46015d64057d25560b0eb4bdc9007",
    urls = ["https://github.com/bazelbuild/rules_nodejs/releases/download/1.5.0/rules_nodejs-1.5.0.tar.gz"],
)
  

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions