diff --git a/packages/bazel/src/rules_typescript.bzl b/packages/bazel/src/external.bzl similarity index 64% rename from packages/bazel/src/rules_typescript.bzl rename to packages/bazel/src/external.bzl index 33095c44c0..a054142fa2 100644 --- a/packages/bazel/src/rules_typescript.bzl +++ b/packages/bazel/src/external.bzl @@ -13,10 +13,20 @@ load( _compile_ts = "compile_ts", _ts_providers_dict_to_struct = "ts_providers_dict_to_struct", ) +load( + "@build_bazel_rules_nodejs//internal/common:node_module_info.bzl", + _NodeModuleInfo = "NodeModuleInfo", + _collect_node_modules_aspect = "collect_node_modules_aspect", +) +NodeModuleInfo = _NodeModuleInfo +collect_node_modules_aspect = _collect_node_modules_aspect tsc_wrapped_tsconfig = _tsc_wrapped_tsconfig COMMON_ATTRIBUTES = _COMMON_ATTRIBUTES COMMON_OUTPUTS = _COMMON_OUTPUTS compile_ts = _compile_ts DEPS_ASPECTS = _DEPS_ASPECTS ts_providers_dict_to_struct = _ts_providers_dict_to_struct + +DEFAULT_NG_COMPILER = "@angular//:@angular/bazel/ngc-wrapped" +DEFAULT_NG_XI18N = "@npm//@angular/bazel/bin:xi18n" diff --git a/packages/bazel/src/ng_module.bzl b/packages/bazel/src/ng_module.bzl index 47e9cf613a..20971916ff 100644 --- a/packages/bazel/src/ng_module.bzl +++ b/packages/bazel/src/ng_module.bzl @@ -6,18 +6,18 @@ """ load( - ":rules_typescript.bzl", + ":external.bzl", "COMMON_ATTRIBUTES", "COMMON_OUTPUTS", "DEPS_ASPECTS", + "DEFAULT_NG_COMPILER", + "DEFAULT_NG_XI18N", + "collect_node_modules_aspect", "compile_ts", "ts_providers_dict_to_struct", "tsc_wrapped_tsconfig", + "NodeModuleInfo", ) -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. @@ -396,7 +396,8 @@ def _compile_action(ctx, inputs, outputs, messages_out, tsconfig_file, node_opts # Give the Angular compiler all the user-listed assets file_inputs = list(ctx.files.assets) - file_inputs.extend(_filter_ts_inputs(ctx.files.node_modules)) + if hasattr(ctx.attr, "node_modules"): + file_inputs.extend(_filter_ts_inputs(ctx.files.node_modules)) # If the user supplies a tsconfig.json file, the Angular compiler needs to read it if hasattr(ctx.attr, "tsconfig") and ctx.file.tsconfig: @@ -533,12 +534,12 @@ NG_MODULE_ATTRIBUTES = { compiler works out of the box. Otherwise, you'll have to override the compiler attribute manually. """, - default = Label(_DEFAULT_COMPILER), + default = Label(DEFAULT_NG_COMPILER), executable = True, cfg = "host", ), "ng_xi18n": attr.label( - default = Label(_DEFAULT_NG_XI18N), + default = Label(DEFAULT_NG_XI18N), executable = True, cfg = "host", ),