build: idiomatic install of @angular/bazel npm package (#26258) (#26488)

PR Close #26488
This commit is contained in:
Greg Magolan
2018-10-16 13:20:00 -07:00
committed by Igor Minar
parent 30d6233e83
commit 631998b2df
27 changed files with 4118 additions and 3621 deletions

View File

@ -2,14 +2,13 @@ package(default_visibility = ["//visibility:public"])
filegroup(
name = "package_assets",
srcs = glob(["*"]) + [
"//packages/bazel/src/ng_package:package_assets",
"//packages/bazel/src/ngc-wrapped:package_assets",
"//packages/bazel/src/protractor:package_assets",
],
srcs = ["modify_tsconfig.js"],
visibility = ["//packages/bazel:__subpackages__"],
)
# For generating skydoc
exports_files(glob(["*.bzl"]))
load("@build_bazel_rules_nodejs//:defs.bzl", "nodejs_binary")
nodejs_binary(

View File

@ -16,6 +16,9 @@ load(
)
load("@build_bazel_rules_nodejs//internal/common:node_module_info.bzl", "NodeModuleInfo", "collect_node_modules_aspect")
_DEFAULT_COMPILER = "@angular//:@angular/bazel/ngc-wrapped"
_DEFAULT_NG_XI18N = "@npm//@angular/bazel/bin:xi18n"
def compile_strategy(ctx):
"""Detect which strategy should be used to implement ng_module.
@ -358,7 +361,7 @@ def ngc_compile_action(
ctx.actions.run(
inputs = list(inputs),
outputs = messages_out,
executable = ctx.executable._ng_xi18n,
executable = ctx.executable.ng_xi18n,
arguments = (_EXTRA_NODE_OPTIONS_FLAGS +
[tsconfig_file.path] +
# The base path is bin_dir because of the way the ngc
@ -521,12 +524,21 @@ NG_MODULE_ATTRIBUTES = {
"inline_resources": attr.bool(default = True),
"no_i18n": attr.bool(default = False),
"compiler": attr.label(
default = Label("//packages/bazel/src/ngc-wrapped"),
doc = """Sets a different ngc compiler binary to use for this library.
The default ngc compiler depends on the `@npm//@angular/bazel`
target which is setup for projects that use bazel managed npm deps that
fetch the @angular/bazel npm package. It is recommended that you use
the workspace name `@npm` for bazel managed deps so the default
compiler works out of the box. Otherwise, you'll have to override
the compiler attribute manually.
""",
default = Label(_DEFAULT_COMPILER),
executable = True,
cfg = "host",
),
"_ng_xi18n": attr.label(
default = Label("//packages/bazel/src/ngc-wrapped:xi18n"),
"ng_xi18n": attr.label(
default = Label(_DEFAULT_NG_XI18N),
executable = True,
cfg = "host",
),

View File

@ -1,20 +1,16 @@
package(default_visibility = ["//visibility:public"])
filegroup(
name = "package_assets",
srcs = glob(["*"]),
visibility = ["//packages/bazel:__subpackages__"],
)
load("@build_bazel_rules_nodejs//:defs.bzl", "nodejs_binary")
load("@build_bazel_rules_typescript//:defs.bzl", "ts_library")
exports_files(["rollup.config.js"])
exports_files([
"rollup.config.js",
"ng_package.bzl",
])
ts_library(
name = "lib",
srcs = glob(["*.ts"]),
compiler = "//:@bazel/typescript/tsc_wrapped",
node_modules = "@angular_packager_deps//:node_modules",
tsconfig = ":tsconfig.json",
)

View File

@ -31,6 +31,8 @@ load("@build_bazel_rules_nodejs//:internal/node.bzl", "sources_aspect")
load("@build_bazel_rules_nodejs//internal/common:node_module_info.bzl", "NodeModuleInfo")
load("//packages/bazel/src:esm5.bzl", "esm5_outputs_aspect", "esm5_root_dir", "flatten_esm5")
_DEFAULT_NG_PACKAGER = "@npm//@angular/bazel/bin:packager"
# Convert from some-dash-case to someCamelCase
def _convert_dash_case_to_camel_case(s):
parts = s.split("-")
@ -341,7 +343,7 @@ def _ng_package_impl(ctx):
mnemonic = "AngularPackage",
inputs = packager_inputs,
outputs = [npm_package_directory],
executable = ctx.executable._ng_packager,
executable = ctx.executable.ng_packager,
arguments = [packager_args],
)
@ -379,8 +381,8 @@ NG_PACKAGE_ATTRS = dict(NPM_PACKAGE_ATTRS, **dict(ROLLUP_ATTRS, **{
"entry_point_name": attr.string(
doc = "Name to use when generating bundle files for the primary entry-point.",
),
"_ng_packager": attr.label(
default = Label("//packages/bazel/src/ng_package:packager"),
"ng_packager": attr.label(
default = Label(_DEFAULT_NG_PACKAGER),
executable = True,
cfg = "host",
),

View File

@ -1,23 +1,19 @@
load("@build_bazel_rules_nodejs//:defs.bzl", "nodejs_binary")
load("@build_bazel_rules_typescript//:defs.bzl", "ts_library")
filegroup(
name = "package_assets",
srcs = glob(["*"]),
visibility = ["//packages/bazel:__subpackages__"],
)
ts_library(
name = "ngc_lib",
srcs = [
"extract_i18n.ts",
"index.ts",
],
compiler = "//:@bazel/typescript/tsc_wrapped",
module_name = "@angular/bazel",
node_modules = "@ngdeps//typescript:typescript__typings",
tsconfig = ":tsconfig.json",
visibility = ["//packages/bazel/test/ngc-wrapped:__subpackages__"],
visibility = [
"//packages/bazel:__pkg__",
"//packages/bazel/test/ngc-wrapped:__subpackages__",
],
deps = [
# BEGIN-INTERNAL
# Only needed when compiling within the Angular repo.
@ -47,6 +43,6 @@ nodejs_binary(
data = [
":ngc_lib",
],
entry_point = "angular/packages/bazel/src/ngc-wrapped/index.js/extract_i18n.js",
entry_point = "angular/packages/bazel/src/ngc-wrapped/extract_i18n.js",
visibility = ["//visibility:public"],
)

View File

@ -1,13 +1,6 @@
package(default_visibility = ["//visibility:public"])
filegroup(
name = "package_assets",
srcs = glob(["*"]) + [
"//packages/bazel/src/protractor/utils:package_assets",
],
visibility = ["//packages/bazel:__subpackages__"],
)
exports_files([
"protractor.conf.js",
"protractor_web_test.bzl",
])

View File

@ -1,17 +1,10 @@
package(default_visibility = ["//visibility:public"])
filegroup(
name = "package_assets",
srcs = glob(["*"]),
visibility = ["//packages/bazel:__subpackages__"],
)
load("@build_bazel_rules_typescript//:defs.bzl", "ts_library")
ts_library(
name = "utils",
srcs = ["index.ts"],
compiler = "//:@bazel/typescript/tsc_wrapped",
module_name = "@angular/bazel/protractor-utils",
node_modules = "@ngdeps//typescript:typescript__typings",
tsconfig = ":tsconfig.json",