Skip to content
This repository has been archived by the owner on Sep 16, 2021. It is now read-only.

bazel build @build_bazel_rules_typescript//... fails from other workspaces #85

Closed
pshields opened this issue Nov 28, 2017 · 1 comment
Closed
Labels

Comments

@pshields
Copy link
Contributor

When adding a reference to rules_typescript from other workspaces, and attempting to build its targets, I run into errors. Is that intended?

For example, in the case where rules_typescript is in node_modules/@bazel/typescript, I get the following error:

$ bazel build @build_bazel_rules_typescript//...
ERROR: error loading package '@build_bazel_rules_typescript//bazel-rules_typescript/external/io_bazel_rules_closure/closure/library': Extension file not found. Unable to load package for '@build_bazel_rules_typescript//closure:defs.bzl': BUILD file not found on package path.

Another approach is to consume a local checkout of rules_typescript instead of the version installed into node_modules/@bazel/typescript folder. I haven't been able to successfully build the targets in rules_typescript under this approach, either.

Here's a minimal repro:

# Run the following in a new, temporary directory:
git clone https://github.com/bazelbuild/rules_typescript.git

# Create a barebones WORKSPACE file consuming the local rules_typescript repository.
cat > WORKSPACE << EOM
git_repository(
    name = "build_bazel_rules_nodejs",
    remote = "https://github.com/bazelbuild/rules_nodejs",
    tag = "0.1.11",
)
load("@build_bazel_rules_nodejs//:defs.bzl", "node_repositories")
node_repositories(package_json = ["//:package.json"])
git_repository(
    name = "io_bazel_rules_go",
    remote = "https://github.com/bazelbuild/rules_go.git",
    tag = "0.6.0"
)
load("@io_bazel_rules_go//go:def.bzl", "go_rules_dependencies", "go_register_toolchains")
go_rules_dependencies()
go_register_toolchains()
local_repository(
    name = "build_bazel_rules_typescript",
    path = "rules_typescript",
)
EOM

# Create a barebones BUILD file providing the necessary :node_modules target
cat > BUILD << EOM
package(default_visibility = ["//visibility:public"])
filegroup(name = "node_modules", srcs = glob([
    "node_modules/**/*.js",
    "node_modules/**/*.json",
    "node_modules/**/*.d.ts",
]))
EOM

# Optional: Copy rules_typescript's package.json and run Yarn (doesn't seem to help.)
cp rules_typescript/package.json ./
bazel run @yarn//...

# Now try to build rules_typescript from the new workspace.
bazel build @build_bazel_rules_typescript//...
# Observe various errors in several targets.

My use case is to try out unreleased rules_typescript features from a separate Bazel workspace. I'm attempting to try out an unmerged branch (#74) locally from the other workspace (since that branch isn't merged / released, I don't think I can get to it via installation into node_modules.)

It seems like a command such as bazel build @build_bazel_rules_typescript//... should be able to run successfully from other workspaces. Am I missing something?

@alexeagle alexeagle added the bug label Jan 23, 2018
@alexeagle
Copy link
Contributor

Sorry this never got attention. I think this is obsolete since typescript is now delivered as @bazel/typescript npm package and doesn't need to be built from sources.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

2 participants