Skip to content

build(cdk): add bazel ng_module rules #8370

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Nov 15, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 35 additions & 0 deletions BUILD.bazel
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
package(default_visibility = ["//visibility:public"])
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

maybe we should use //:__subpackages__ as the default visibility everywhere, to avoid external repos depending on our rules

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If I try to use that here I get:

ERROR: /usr/local/google/home/jelbourn/.cache/bazel/_bazel_jelbourn/2010aad45cf3f55bb7127948064a6254/external/build_bazel_rules_typescript/internal/tsc_wrapped/BUILD.bazel:19:1: Target '//:node_modules' is not visible from target '@build_bazel_rules_typescript//internal/tsc_wrapped:tsc_bin'. Check the visibility declaration of the former target if you think the dependency is legitimate
ERROR: /usr/local/google/home/jelbourn/.cache/bazel/_bazel_jelbourn/2010aad45cf3f55bb7127948064a6254/external/build_bazel_rules_typescript/internal/tsc_wrapped/BUILD.bazel:19:1: Target '//:node_modules' is not visible from target '@build_bazel_rules_typescript//internal/tsc_wrapped:tsc_bin'. Check the visibility declaration of the former target if you think the dependency is legitimate
ERROR: Analysis of target '//src/cdk/observers:observers' failed; build aborted: Analysis of target '@build_bazel_rules_typescript//internal/tsc_wrapped:tsc_bin' failed; build aborted
INFO: Elapsed time: 0.833s
FAILED: Build did NOT complete successfully (1 packages loaded)

For the rest of the rules I'm not too concerned about it right now


# TODO(jelbourn): figure out if these workarounds are still needed

# This rule belongs in node_modules/BUILD
# It's here as a workaround for
# https://github.com/bazelbuild/bazel/issues/374#issuecomment-296217940
filegroup(
name = "node_modules",
# Performance workaround: list individual files
# Reduces the number of files as inputs to nodejs_binary:
# bazel query "deps(:node_modules)" | wc -l
# This won't scale in the general case.
# TODO(alexeagle): figure out what to do
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sorry, I have an idea how to fix this if anyone has some time to investigate...

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Doesn't strike me as that bad- you want to be explicit about your dependencies anyway

srcs = glob(["/".join(["node_modules", pkg, "**", ext]) for pkg in [
"@angular",
"jasmine",
"typescript",
"tslib",
"zone.js",
"rxjs",
"@types",
"tsickle",
"hammerjs",
"protobufjs",
"bytebuffer",
"reflect-metadata",
"minimist",
"moment",
] for ext in [
"*.js",
"*.json",
"*.d.ts",
]]),
)
36 changes: 36 additions & 0 deletions WORKSPACE
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
workspace(name = "angular_material_src")

# Add nodejs rules
git_repository(
name = "build_bazel_rules_nodejs",
remote = "https://github.com/bazelbuild/rules_nodejs.git",
# TODO(jelbourn): use the correct tag here.
commit = "31d36ff2acdf630d1e331f38006cf1a5d303d338",
)

# NOTE: this rule installs nodejs, npm, and yarn, but does NOT install
# your npm dependencies. You must still run the package manager.
load("@build_bazel_rules_nodejs//:defs.bzl", "node_repositories")
node_repositories(package_json = ["//:package.json"])

# Add sass rules
git_repository(
name = "io_bazel_rules_sass",
remote = "https://github.com/bazelbuild/rules_sass.git",
tag = "0.0.2",
)

load("@io_bazel_rules_sass//sass:sass.bzl", "sass_repositories")
sass_repositories()

# Add TypeScript rules
local_repository(
name = "build_bazel_rules_typescript",
path = "node_modules/@bazel/typescript",
Copy link
Member

@devversion devversion Nov 15, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should explicitly specify this as a dependency: https://www.npmjs.com/package/@bazel/typescript

)

# Add Angular rules
local_repository(
name = "angular",
path = "node_modules/@angular/bazel",
)
20 changes: 20 additions & 0 deletions angular.tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
// WORKAROUND https://github.com/angular/angular/issues/18810
// This file is required to run ngc on angular libraries, to write files like
// node_modules/@angular/core/core.ngsummary.json
{
"compilerOptions": {
"lib": [
"dom",
"es2015"
],
"experimentalDecorators": true,
"types": []
},
"include": [
"node_modules/@angular/**/*"
],
"exclude": [
"node_modules/@angular/bazel/**",
"node_modules/@angular/compiler-cli/**"
]
}
Loading