fix(bazel): add missing binary path for api-extractor (#29202)

`api-extractor` binary is required for external consumers of `ng_module` that want to use the `bundle_dts` flag.

This also sets a different api-exttractor binary to use for ng_module, based if it's internal or external.

PR Close #29202
This commit is contained in:
Alan Agius 2019-03-09 13:24:20 +01:00 committed by Kara Erickson
parent 4227126305
commit df354d1b34
5 changed files with 9 additions and 3 deletions

View File

@ -5,6 +5,7 @@
"author": "angular", "author": "angular",
"license": "MIT", "license": "MIT",
"bin": { "bin": {
"api-extractor": "./src/api-extractor/index.js",
"ngc-wrapped": "./src/ngc-wrapped/index.js", "ngc-wrapped": "./src/ngc-wrapped/index.js",
"packager": "./src/ng_package/packager.js", "packager": "./src/ng_package/packager.js",
"xi18n": "./src/ngc-wrapped/extract_i18n.js", "xi18n": "./src/ngc-wrapped/extract_i18n.js",

View File

@ -33,6 +33,7 @@ compile_ts = _compile_ts
DEPS_ASPECTS = _DEPS_ASPECTS DEPS_ASPECTS = _DEPS_ASPECTS
ts_providers_dict_to_struct = _ts_providers_dict_to_struct ts_providers_dict_to_struct = _ts_providers_dict_to_struct
DEFAULT_API_EXTRACTOR = "@npm//@angular/bazel/bin:api-extractor"
DEFAULT_NG_COMPILER = "@npm//@angular/bazel/bin:ngc-wrapped" DEFAULT_NG_COMPILER = "@npm//@angular/bazel/bin:ngc-wrapped"
DEFAULT_NG_XI18N = "@npm//@angular/bazel/bin:xi18n" DEFAULT_NG_XI18N = "@npm//@angular/bazel/bin:xi18n"
FLAT_DTS_FILE_SUFFIX = ".bundle.d.ts" FLAT_DTS_FILE_SUFFIX = ".bundle.d.ts"

View File

@ -9,6 +9,7 @@ load(
":external.bzl", ":external.bzl",
"COMMON_ATTRIBUTES", "COMMON_ATTRIBUTES",
"COMMON_OUTPUTS", "COMMON_OUTPUTS",
"DEFAULT_API_EXTRACTOR",
"DEFAULT_NG_COMPILER", "DEFAULT_NG_COMPILER",
"DEFAULT_NG_XI18N", "DEFAULT_NG_XI18N",
"DEPS_ASPECTS", "DEPS_ASPECTS",
@ -450,7 +451,7 @@ def ngc_compile_action(
ctx.actions.run( ctx.actions.run(
progress_message = "Bundling DTS %s" % str(ctx.label), progress_message = "Bundling DTS %s" % str(ctx.label),
mnemonic = "APIExtractor", mnemonic = "APIExtractor",
executable = ctx.executable._api_extractor, executable = ctx.executable.api_extractor,
inputs = filter_inputs, inputs = filter_inputs,
outputs = dts_bundles_out, outputs = dts_bundles_out,
arguments = [ arguments = [
@ -716,8 +717,8 @@ NG_MODULE_RULE_ATTRS = dict(dict(COMMON_ATTRIBUTES, **NG_MODULE_ATTRIBUTES), **{
# https://github.com/angular/angular/blob/master/packages/compiler-cli/src/transformers/api.ts # https://github.com/angular/angular/blob/master/packages/compiler-cli/src/transformers/api.ts
"flat_module_out_file": attr.string(), "flat_module_out_file": attr.string(),
"bundle_dts": attr.bool(default = False), "bundle_dts": attr.bool(default = False),
"_api_extractor": attr.label( "api_extractor": attr.label(
default = Label("//packages/bazel/src/api-extractor:api_extractor"), default = Label(DEFAULT_API_EXTRACTOR),
executable = True, executable = True,
cfg = "host", cfg = "host",
), ),

View File

@ -6,6 +6,7 @@ ng_module(
name = "test_module", name = "test_module",
testonly = True, testonly = True,
srcs = glob(["*.ts"]), srcs = glob(["*.ts"]),
api_extractor = "//packages/bazel/src/api-extractor:api_extractor",
compiler = "//packages/bazel/src/ngc-wrapped", compiler = "//packages/bazel/src/ngc-wrapped",
entry_point = "index.ts", entry_point = "index.ts",
flat_module_out_file = "flat_module_filename", flat_module_out_file = "flat_module_filename",

View File

@ -9,6 +9,7 @@ load("//packages/bazel/src:ng_rollup_bundle.bzl", _ng_rollup_bundle = "ng_rollup
_DEFAULT_TSCONFIG_BUILD = "//packages:tsconfig-build.json" _DEFAULT_TSCONFIG_BUILD = "//packages:tsconfig-build.json"
_DEFAULT_TSCONFIG_TEST = "//packages:tsconfig-test" _DEFAULT_TSCONFIG_TEST = "//packages:tsconfig-test"
_INTERNAL_NG_MODULE_API_EXTRACTOR = "//packages/bazel/src/api-extractor:api_extractor"
_INTERNAL_NG_MODULE_COMPILER = "//packages/bazel/src/ngc-wrapped" _INTERNAL_NG_MODULE_COMPILER = "//packages/bazel/src/ngc-wrapped"
_INTERNAL_NG_MODULE_XI18N = "//packages/bazel/src/ngc-wrapped:xi18n" _INTERNAL_NG_MODULE_XI18N = "//packages/bazel/src/ngc-wrapped:xi18n"
_INTERNAL_NG_PACKAGER_PACKAGER = "//packages/bazel/src/ng_package:packager" _INTERNAL_NG_PACKAGER_PACKAGER = "//packages/bazel/src/ng_package:packager"
@ -124,6 +125,7 @@ def ng_module(name, tsconfig = None, entry_point = None, testonly = False, deps
bundle_dts = bundle_dts, bundle_dts = bundle_dts,
deps = deps, deps = deps,
compiler = _INTERNAL_NG_MODULE_COMPILER, compiler = _INTERNAL_NG_MODULE_COMPILER,
api_extractor = _INTERNAL_NG_MODULE_API_EXTRACTOR,
ng_xi18n = _INTERNAL_NG_MODULE_XI18N, ng_xi18n = _INTERNAL_NG_MODULE_XI18N,
module_name = module_name, module_name = module_name,
**kwargs **kwargs