rxjs bazel files interact badly with containing bazel projects

Created on 28 Aug 2018  路  4Comments  路  Source: ReactiveX/rxjs

Bug Report

Current Behavior
In projects that

  • use bazel
  • have client apps whose node_modules folder contains rxjs
    It is not possible to go "bazel build ..." at the top level, because bazel gets confused by rxjs' bazel files.

Reproduction

  1. Be in a folder, in a bazel workspace, above a client application that depends (perhaps indirectly) on rxjs
  2. Run bazel build ... and observe output:
ERROR: error loading package 'MY_CLIENT_APP/client/node_modules/rxjs/src': Extension file not found. Unable to load package for '@build_bazel_rules_typescript//:defs.bzl': The repository could not be resolved
INFO: Elapsed time: 2.643s
INFO: 0 processes.
FAILED: Build did NOT complete successfully (1 packages loaded)
    currently loading: MY_CLIENT_APP/client/node_modules/rxjs/src

Expected behavior
No error

Environment

$ bazel version
Build label: 0.13.0-homebrew

Possible Solution
Please have a release step that expunges or renames bazel files, or does some other trick, s.t. this problem does not occur when your module is brought into bazel projects.

Workaround only: doing local_repository() hacks in our WORKSPACE, or having a script that deletes the files as a hack.

Most helpful comment

For people reading this and who would want a quick fix, you may add this to your WORKSPACE file:

local_repository(
  name = "ignore_rxjs_module",
  path = "./some_path/node_modules/rxjs/src",
)

All 4 comments

cc @alexeagle

For people reading this and who would want a quick fix, you may add this to your WORKSPACE file:

local_repository(
  name = "ignore_rxjs_module",
  path = "./some_path/node_modules/rxjs/src",
)

Our plan is to stop including any bazel files in the distribution of rxjs.
To make rxjs work seamlessly with the bazel typescript rules, we should either:

  • fetch rxjs sources in the bazel build, not rely on npm distro, or
  • change the JS files in the npm distro to work natively (have named UMD modules), or
  • make a new third_party interop mechanism where a bazel action transpiles modules to have named UMD

In the meantime @IljaKroonen has the right workaround.
Note that starting in Bazel 0.18 (due to be released any day now) you can just put node_modules in your .bazelignore file, which is a much more robust long-term solution to any npm package shipping bazel files.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

dooreelko picture dooreelko  路  3Comments

Agraphie picture Agraphie  路  3Comments

benlesh picture benlesh  路  3Comments

cartant picture cartant  路  3Comments

marcusradell picture marcusradell  路  4Comments