diff --git a/.bazelrc b/.bazelrc index 0000bcc033..32e3e4c633 100644 --- a/.bazelrc +++ b/.bazelrc @@ -154,6 +154,11 @@ build:remote --bes_results_url="https://source.cloud.google.com/results/invocati # This allows us to avoid installing a second copy of node_modules common --experimental_allow_incremental_repository_updates +# This option is changed to true in Bazel 0.27 but exposes a known worker mode bug: +# https://github.com/bazelbuild/rules_typescript/issues/449 +# While we are fixing that issue, we need to keep this breaking change disabled +build --incompatible_list_based_execution_strategy_selection=false + #################################################### # User bazel configuration # NOTE: This needs to be the *last* entry in the config. diff --git a/WORKSPACE b/WORKSPACE index dc2ec560b7..6a6dc35d7b 100644 --- a/WORKSPACE +++ b/WORKSPACE @@ -27,6 +27,7 @@ load("@build_bazel_rules_nodejs//:defs.bzl", "check_bazel_version", "check_rules # Bazel version must be at least the following version because: # - 0.26.0 managed_directories feature added which is required for nodejs rules 0.30.0 +# - 0.27.0 has a fix for managed_directories after `rm -rf node_modules` check_bazel_version( message = """ You no longer need to install Bazel on your machine. @@ -35,7 +36,7 @@ Try running `yarn bazel` instead. (If you did run that, check that you've got a fresh `yarn install`) """, - minimum_bazel_version = "0.26.0", + minimum_bazel_version = "0.27.0", ) # The NodeJS rules version must be at least the following version because: diff --git a/integration/bazel/.bazelrc b/integration/bazel/.bazelrc index 1e2c660e9c..14e35c64a3 100644 --- a/integration/bazel/.bazelrc +++ b/integration/bazel/.bazelrc @@ -20,3 +20,7 @@ build --symlink_prefix=/ # Turn on managed directories feature in Bazel # This allows us to avoid installing a second copy of node_modules common --experimental_allow_incremental_repository_updates + +# Temporary flag to for using nodejs rules 0.31.1 with Bazel 0.27.0 +# TODO(gregmagolan): remove after updating to next nodejs rules release +common --incompatible_depset_is_not_iterable=false diff --git a/integration/bazel/WORKSPACE b/integration/bazel/WORKSPACE index 8cdd0d2786..5d51f8ccd5 100644 --- a/integration/bazel/WORKSPACE +++ b/integration/bazel/WORKSPACE @@ -25,6 +25,7 @@ load("@build_bazel_rules_nodejs//:defs.bzl", "check_bazel_version", "node_reposi # Bazel version must be at least the following version because: # - 0.26.0 managed_directories feature added which is required for nodejs rules 0.30.0 +# - 0.27.0 has a fix for managed_directories after `rm -rf node_modules` check_bazel_version( message = """ You no longer need to install Bazel on your machine. @@ -33,7 +34,7 @@ Try running `yarn bazel` instead. (If you did run that, check that you've got a fresh `yarn install`) """, - minimum_bazel_version = "0.26.0", + minimum_bazel_version = "0.27.0", ) # Setup the Node.js toolchain diff --git a/package.json b/package.json index f3d7e2457f..feb286dbef 100644 --- a/package.json +++ b/package.json @@ -120,7 +120,7 @@ "// 3": "when updating @bazel/bazel version you also need to update the RBE settings in .bazelrc (see https://github.com/angular/angular/pull/27935)", "devDependencies": { "@angular/cli": "^8.0.0-beta.15", - "@bazel/bazel": "0.26.1", + "@bazel/bazel": "0.27.0", "@bazel/buildifier": "^0.26.0", "@bazel/ibazel": "~0.9.0", "@types/minimist": "^1.2.0", diff --git a/packages/bazel/src/builders/files/WORKSPACE.template b/packages/bazel/src/builders/files/WORKSPACE.template index f9cf922859..758344fd6b 100644 --- a/packages/bazel/src/builders/files/WORKSPACE.template +++ b/packages/bazel/src/builders/files/WORKSPACE.template @@ -49,7 +49,7 @@ Try running `yarn bazel` instead. (If you did run that, check that you've got a fresh `yarn install`) """, - minimum_bazel_version = "0.26.0", + minimum_bazel_version = "0.27.0", ) # Setup the Node repositories. We need a NodeJS version that is more recent than v10.15.0 diff --git a/packages/bazel/src/builders/files/__dot__bazelrc.template b/packages/bazel/src/builders/files/__dot__bazelrc.template index 215e72a24e..97c4667f1d 100644 --- a/packages/bazel/src/builders/files/__dot__bazelrc.template +++ b/packages/bazel/src/builders/files/__dot__bazelrc.template @@ -33,3 +33,6 @@ build --define=compile=legacy # Turn on managed directories feature in Bazel # This allows us to avoid installing a second copy of node_modules common --experimental_allow_incremental_repository_updates + +# Compatibility flag for Bazel 0.27.0 +common --incompatible_depset_is_not_iterable=false diff --git a/packages/bazel/src/ng_module.bzl b/packages/bazel/src/ng_module.bzl index c587f76bba..bd1b908f00 100644 --- a/packages/bazel/src/ng_module.bzl +++ b/packages/bazel/src/ng_module.bzl @@ -269,7 +269,7 @@ def _expected_outs(ctx): # TODO(alxhub): i18n is only produced by the legacy compiler currently. This should be re-enabled # when ngtsc can extract messages if is_legacy_ngc: - i18n_messages_files = [ctx.new_file(ctx.genfiles_dir, ctx.label.name + "_ngc_messages.xmb")] + i18n_messages_files = [ctx.actions.declare_file(ctx.label.name + "_ngc_messages.xmb")] else: i18n_messages_files = [] @@ -432,17 +432,14 @@ def ngc_compile_action( 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 - # compiler host is configured. So we need to explicitly - # point to genfiles/ to redirect the output. - ["../genfiles/" + messages_out[0].short_path]), + [messages_out[0].short_path]), progress_message = "Extracting Angular 2 messages (ng_xi18n)", mnemonic = "Angular2MessageExtractor", ) if dts_bundles_out != None: # combine the inputs and outputs and filter .d.ts and json files - filter_inputs = [f for f in list(inputs) + outputs if f.path.endswith(".d.ts") or f.path.endswith(".json")] + filter_inputs = [f for f in inputs.to_list() + outputs if f.path.endswith(".d.ts") or f.path.endswith(".json")] if _should_produce_flat_module_outs(ctx): dts_entry_points = ["%s.d.ts" % _flat_module_out_file(ctx)] diff --git a/packages/bazel/src/ng_package/ng_package.bzl b/packages/bazel/src/ng_package/ng_package.bzl index 3abcf247a8..c984032559 100644 --- a/packages/bazel/src/ng_package/ng_package.bzl +++ b/packages/bazel/src/ng_package/ng_package.bzl @@ -94,6 +94,10 @@ WELL_KNOWN_GLOBALS = {p: _global_name(p) for p in [ "rxjs/operators", ]} +# skydoc fails with type(depset()) so using "depset" here instead +# TODO(gregmagolan): clean this up +_DEPSET_TYPE = "depset" + def _rollup(ctx, bundle_name, rollup_config, entry_point, inputs, js_output, format = "es", package_name = "", include_tslib = False): map_output = ctx.actions.declare_file(js_output.basename + ".map", sibling = js_output) @@ -133,7 +137,7 @@ def _rollup(ctx, bundle_name, rollup_config, entry_point, inputs, js_output, for args.add("--silent") - other_inputs = [ctx.executable._rollup, rollup_config] + other_inputs = [rollup_config] if ctx.file.license_banner: other_inputs.append(ctx.file.license_banner) if ctx.version_file: @@ -144,6 +148,7 @@ def _rollup(ctx, bundle_name, rollup_config, entry_point, inputs, js_output, for inputs = inputs.to_list() + other_inputs, outputs = [js_output, map_output], executable = ctx.executable._rollup, + tools = [ctx.executable._rollup], arguments = [args], ) return struct( @@ -165,7 +170,8 @@ def _flatten_paths(directory): # Optionally can filter out files that do not belong to a specified package path. def _filter_out_generated_files(files, extension, package_path = None): result = [] - for file in files: + files_list = files.to_list() if type(files) == _DEPSET_TYPE else files + for file in files_list: # If the "package_path" parameter has been specified, filter out files # that do not start with the the specified package path. if package_path and not file.short_path.startswith(package_path): @@ -183,9 +189,10 @@ def _esm2015_root_dir(ctx): return ctx.label.name + ".es6" def _filter_js_inputs(all_inputs): + all_inputs_list = all_inputs.to_list() if type(all_inputs) == _DEPSET_TYPE else all_inputs return [ f - for f in all_inputs + for f in all_inputs_list if f.path.endswith(".js") or f.path.endswith(".json") ] diff --git a/packages/bazel/src/schematics/ng-add/index.ts b/packages/bazel/src/schematics/ng-add/index.ts index c811ab04b2..e40d2dbe5d 100755 --- a/packages/bazel/src/schematics/ng-add/index.ts +++ b/packages/bazel/src/schematics/ng-add/index.ts @@ -48,7 +48,7 @@ function addDevDependenciesToPackageJson(options: Schema) { const devDependencies: {[k: string]: string} = { '@angular/bazel': angularCoreVersion, - '@bazel/bazel': '^0.26.0', + '@bazel/bazel': '^0.27.0', '@bazel/ibazel': '^0.10.2', '@bazel/karma': '0.31.1', '@bazel/typescript': '0.31.1', diff --git a/packages/bazel/src/schematics/ng-add/index_spec.ts b/packages/bazel/src/schematics/ng-add/index_spec.ts index 07ab0bbe84..888ebb0e78 100644 --- a/packages/bazel/src/schematics/ng-add/index_spec.ts +++ b/packages/bazel/src/schematics/ng-add/index_spec.ts @@ -113,6 +113,7 @@ describe('ng-add schematic', () => { const json = JSON.parse(content); const devDeps = Object.keys(json.devDependencies); expect(devDeps).toContain('@bazel/bazel'); + expect(devDeps).toContain('@bazel/hide-bazel-files'); expect(devDeps).toContain('@bazel/ibazel'); expect(devDeps).toContain('@bazel/karma'); }); diff --git a/yarn.lock b/yarn.lock index c4df17ddbe..a734fc2876 100644 --- a/yarn.lock +++ b/yarn.lock @@ -90,29 +90,29 @@ esutils "^2.0.2" js-tokens "^4.0.0" -"@bazel/bazel-darwin_x64@0.26.1": - version "0.26.1" - resolved "https://registry.yarnpkg.com/@bazel/bazel-darwin_x64/-/bazel-darwin_x64-0.26.1.tgz#1b5c69b635e5c2a8c3090fa5f6bcb45735f06045" - integrity sha512-9VjrR+ce+iS9xS1lgeAo1RAPXlxCvez/r3smN1lP4s4YNF0s5LAT0cevIl6Zz2nwyEha/6JvY3v6Euemy36F0w== +"@bazel/bazel-darwin_x64@0.27.0": + version "0.27.0" + resolved "https://registry.yarnpkg.com/@bazel/bazel-darwin_x64/-/bazel-darwin_x64-0.27.0.tgz#83a03c92d52ae60e48e86a1ee697e69e12ddbdf6" + integrity sha512-CyavIbRKRa/55aMyfEM9hjbt4TVISfv7HLeymHTGTLWzS8uQokQ8W9tR/pgc7YJn8F0x64dd7nQKxhbYHM1Qfg== -"@bazel/bazel-linux_x64@0.26.1": - version "0.26.1" - resolved "https://registry.yarnpkg.com/@bazel/bazel-linux_x64/-/bazel-linux_x64-0.26.1.tgz#04dd194bdcd6b9d45bd865a9a60c280d0d600251" - integrity sha512-oZooDxI1C4p7o18zx2Uns2cK/NN2hgF2YSBKH0aVDPAAxQA85h+g124CWDEbsghOdRMSBM0Hd0SSeIqwZcqLSw== +"@bazel/bazel-linux_x64@0.27.0": + version "0.27.0" + resolved "https://registry.yarnpkg.com/@bazel/bazel-linux_x64/-/bazel-linux_x64-0.27.0.tgz#2358292aa4901f526ba9b90874256f63d6d6608c" + integrity sha512-hO04v7C6M3Jf+qNlLE+IticZZKkkS7Nv6+pXDnENgFWrqLV2H93un6kNQnk83B0hP2cEqRQ8rw5yrIcqXNNuSQ== -"@bazel/bazel-win32_x64@0.26.1": - version "0.26.1" - resolved "https://registry.yarnpkg.com/@bazel/bazel-win32_x64/-/bazel-win32_x64-0.26.1.tgz#9351f07313173b1f98006da8131c94db7aa7c506" - integrity sha512-0FkOo8+bxw13X2m6ALhXX2241gG9ZXgcLu0E/IbCWy/TmOB5bR0Z73CslszWbXIldVYnANuhFmnkxIa745Du5Q== +"@bazel/bazel-win32_x64@0.27.0": + version "0.27.0" + resolved "https://registry.yarnpkg.com/@bazel/bazel-win32_x64/-/bazel-win32_x64-0.27.0.tgz#0e5e498de5ccccc9a6cf481cd46904ee938ab6c2" + integrity sha512-7hIGNhdgaxRt9ceSOCs3eSTtCNi4GXz3nu6OjfgSp+QiqLbW/iAVWa8M8vD5aemZ1BSHek4/LISdWUTncLJk+w== -"@bazel/bazel@0.26.1": - version "0.26.1" - resolved "https://registry.yarnpkg.com/@bazel/bazel/-/bazel-0.26.1.tgz#de5febbd1f4b457aa870fb69492f474850283e5d" - integrity sha512-x0IR0KEML4JGG6QpAOpHQHWpMqM1YQjOi8zY1jjLwiRHhC3Y8Tc/Mcspnd6zUnjfs7MerPfppkyx2jaEnZwUuQ== +"@bazel/bazel@0.27.0": + version "0.27.0" + resolved "https://registry.yarnpkg.com/@bazel/bazel/-/bazel-0.27.0.tgz#4e72c8e1cbb4da41022b6de1afe28731f5f58e09" + integrity sha512-yIj64IkesNzjHsoeehQUMBOgrCK/JMSuon5CvBqo6+izPXAmt+OW05uqaLL/FPAYAFQ2mHxsYtDsPxsM8DUbqA== optionalDependencies: - "@bazel/bazel-darwin_x64" "0.26.1" - "@bazel/bazel-linux_x64" "0.26.1" - "@bazel/bazel-win32_x64" "0.26.1" + "@bazel/bazel-darwin_x64" "0.27.0" + "@bazel/bazel-linux_x64" "0.27.0" + "@bazel/bazel-win32_x64" "0.27.0" "@bazel/buildifier-darwin_x64@0.26.0": version "0.26.0"