From 5e694e519b9be3c9b770ac6178e8cba7909ec905 Mon Sep 17 00:00:00 2001 From: Greg Magolan Date: Wed, 9 Oct 2019 16:00:08 -0700 Subject: [PATCH] build: update to nodejs rules 0.38.2 (#33073) Some changes in rules_nodejs providers folded into @angular/bazel package: * `NodeModuleSources` renamed to `NpmPackageInfo` and now loaded from `//internal/common:npm_package_info.bzl` * `collect_node_modules_aspect` renamed to `node_modules_aspect` * new JS provider `JSNamedModuleInfo` now available and ng_module provides it using the `js_named_module_info` factory function * sources_aspect has also been removed so the use of the `node_sources` legacy provider has been replaced with `JSNamedModuleInfo`. PR Close #33073 --- WORKSPACE | 7 +-- integration/bazel/WORKSPACE | 4 +- integration/bazel/package.json | 6 +-- integration/bazel/yarn.lock | 44 +++++++++---------- package.json | 8 ++-- .../src/builders/files/WORKSPACE.template | 4 +- packages/bazel/src/external.bzl | 16 ++++--- packages/bazel/src/ng_module.bzl | 21 +++++---- packages/bazel/src/ng_package/ng_package.bzl | 16 +++---- packages/bazel/src/schematics/ng-add/index.ts | 6 +-- yarn.lock | 32 +++++++------- 11 files changed, 86 insertions(+), 78 deletions(-) diff --git a/WORKSPACE b/WORKSPACE index 9b0c072690..ff14b864db 100644 --- a/WORKSPACE +++ b/WORKSPACE @@ -21,8 +21,8 @@ http_archive( patch_args = ["-p1"], # Patch https://github.com/bazelbuild/rules_nodejs/pull/903 patches = ["//tools:rollup_bundle_commonjs_ignoreGlobal.patch"], - sha256 = "0942d188f4d0de6ddb743b9f6642a26ce1ad89f09c0035a9a5ca5ba9615c96aa", - urls = ["https://github.com/bazelbuild/rules_nodejs/releases/download/0.38.1/rules_nodejs-0.38.1.tar.gz"], + sha256 = "1447312c8570e8916da0f5f415186e7098cdd4ce48e04b8e864f793c766959c3", + urls = ["https://github.com/bazelbuild/rules_nodejs/releases/download/0.38.2/rules_nodejs-0.38.2.tar.gz"], ) # Check the bazel version and download npm dependencies @@ -55,7 +55,8 @@ Try running `yarn bazel` instead. # - 0.32.2 resolves bug in @bazel/hide-bazel-files postinstall step # - 0.34.0 introduces protractor rule # - 0.37.1 windows fixes -check_rules_nodejs_version(minimum_version_string = "0.37.1") +# - 0.38.2 Adds NpmPackageInfo & JSNamedModuleInfo providers +check_rules_nodejs_version(minimum_version_string = "0.38.2") # Setup the Node.js toolchain node_repositories( diff --git a/integration/bazel/WORKSPACE b/integration/bazel/WORKSPACE index 12acc35d97..37baf8c3fd 100644 --- a/integration/bazel/WORKSPACE +++ b/integration/bazel/WORKSPACE @@ -8,8 +8,8 @@ load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive") # Fetch rules_nodejs so we can install our npm dependencies http_archive( name = "build_bazel_rules_nodejs", - sha256 = "0942d188f4d0de6ddb743b9f6642a26ce1ad89f09c0035a9a5ca5ba9615c96aa", - urls = ["https://github.com/bazelbuild/rules_nodejs/releases/download/0.38.1/rules_nodejs-0.38.1.tar.gz"], + sha256 = "1447312c8570e8916da0f5f415186e7098cdd4ce48e04b8e864f793c766959c3", + urls = ["https://github.com/bazelbuild/rules_nodejs/releases/download/0.38.2/rules_nodejs-0.38.2.tar.gz"], ) # Fetch sass rules for compiling sass files diff --git a/integration/bazel/package.json b/integration/bazel/package.json index 59fa3738e0..991164ebfc 100644 --- a/integration/bazel/package.json +++ b/integration/bazel/package.json @@ -23,9 +23,9 @@ "@angular/compiler": "file:../../dist/packages-dist/compiler", "@angular/compiler-cli": "file:../../dist/packages-dist/compiler-cli", "@bazel/bazel": "file:../../node_modules/@bazel/bazel", - "@bazel/karma": "0.38.1", - "@bazel/protractor": "0.38.1", - "@bazel/typescript": "0.38.1", + "@bazel/karma": "0.38.2", + "@bazel/protractor": "0.38.2", + "@bazel/typescript": "0.38.2", "@types/jasmine": "2.8.8", "http-server": "^0.11.1", "typescript": "3.4.2" diff --git a/integration/bazel/yarn.lock b/integration/bazel/yarn.lock index 8610f573db..f5f8dc0732 100644 --- a/integration/bazel/yarn.lock +++ b/integration/bazel/yarn.lock @@ -30,12 +30,12 @@ rxjs "6.4.0" "@angular/animations@file:../../dist/packages-dist/animations": - version "9.0.0-next.8" + version "9.0.0-next.10" dependencies: tslib "^1.9.0" "@angular/bazel@file:../../dist/packages-dist/bazel": - version "9.0.0-next.9" + version "9.0.0-next.10" dependencies: "@angular-devkit/architect" "^0.800.0-beta.15" "@angular-devkit/core" "^8.0.0-beta.15" @@ -57,12 +57,12 @@ parse5 "^5.0.0" "@angular/common@file:../../dist/packages-dist/common": - version "9.0.0-next.8" + version "9.0.0-next.10" dependencies: tslib "^1.9.0" "@angular/compiler-cli@file:../../dist/packages-dist/compiler-cli": - version "9.0.0-next.8" + version "9.0.0-next.10" dependencies: canonical-path "1.0.0" chokidar "^2.1.1" @@ -76,17 +76,17 @@ yargs "13.1.0" "@angular/compiler@file:../../dist/packages-dist/compiler": - version "9.0.0-next.8" + version "9.0.0-next.10" dependencies: tslib "^1.9.0" "@angular/core@file:../../dist/packages-dist/core": - version "9.0.0-next.8" + version "9.0.0-next.10" dependencies: tslib "^1.9.0" "@angular/forms@file:../../dist/packages-dist/forms": - version "9.0.0-next.8" + version "9.0.0-next.10" dependencies: tslib "^1.9.0" @@ -98,17 +98,17 @@ tslib "^1.7.1" "@angular/platform-browser-dynamic@file:../../dist/packages-dist/platform-browser-dynamic": - version "9.0.0-next.8" + version "9.0.0-next.10" dependencies: tslib "^1.9.0" "@angular/platform-browser@file:../../dist/packages-dist/platform-browser": - version "9.0.0-next.8" + version "9.0.0-next.10" dependencies: tslib "^1.9.0" "@angular/router@file:../../dist/packages-dist/router": - version "9.0.0-next.8" + version "9.0.0-next.10" dependencies: tslib "^1.9.0" @@ -141,10 +141,10 @@ resolved "https://registry.yarnpkg.com/@bazel/hide-bazel-files/-/hide-bazel-files-0.34.0.tgz#368ea84db2756ff80ead23bb9eb179e9ed24b462" integrity sha512-suyO6cZf8iV6W2LkM1X1spWBt7CsRRXH7gU1wYNuAuHYkkfI0A6qj84yPiIXiOt/2G44kbioGyC1bUsI3fKv7A== -"@bazel/karma@0.38.1": - version "0.38.1" - resolved "https://registry.yarnpkg.com/@bazel/karma/-/karma-0.38.1.tgz#7175b2284d21b1a725f24d8ca24577ec7c54c222" - integrity sha512-Hz6+7tm70Qv59iX+iryln7WC1GT8R2Jc93zu6EdqlkyVSWbTb6J+pmp3hcBKG+4Y2iAlLk+Czaj8cQu1DRt8GQ== +"@bazel/karma@0.38.2": + version "0.38.2" + resolved "https://registry.yarnpkg.com/@bazel/karma/-/karma-0.38.2.tgz#13c0eb8f09fdc579ef3a2493d6014d77cdc03670" + integrity sha512-pTeHciOyg5ViCCl8Vn5N/wSJSTrxh+26+drlh0GBW8gzUTGIfWDVnma3oA6lLp8zyaCzkpoMP2ukrwBky3nk1Q== dependencies: jasmine-core "2.8.0" karma "~4.1.0" @@ -158,17 +158,17 @@ semver "5.6.0" tmp "0.0.33" -"@bazel/protractor@0.38.1": - version "0.38.1" - resolved "https://registry.yarnpkg.com/@bazel/protractor/-/protractor-0.38.1.tgz#0785c863254071f6d848d1d78c7ceb47af9ae218" - integrity sha512-bAixjddJyGA4OKxkhKIWNH1u5atOm7qCQKTR5GFhEEECuxwabwuyZGDtGzWGKgngCwy7UZitG8BTX2CKU4cknw== +"@bazel/protractor@0.38.2": + version "0.38.2" + resolved "https://registry.yarnpkg.com/@bazel/protractor/-/protractor-0.38.2.tgz#be0804c246d412f8b285fc22a320ab9b471c7a5d" + integrity sha512-bo5v7CpG9TlPX2lx/XueviMt8KY7KDaL7rcw5SR3uU+4w+gX6bTjdnSsVXCUH2YrTTz6VgZaBZO3O0GTbjDP+w== dependencies: protractor "^5.4.2" -"@bazel/typescript@0.38.1": - version "0.38.1" - resolved "https://registry.yarnpkg.com/@bazel/typescript/-/typescript-0.38.1.tgz#fe9a84e0992580a4b67cbc48fbe72f9154bacf56" - integrity sha512-etTftAm6jN0cdHS9Pgb6fJXgHaot+nRhgr8VjUKZr/ITs31U7iDA/9ehjoVFVbqzJzQy4BfdicbydP+cqXz2Xg== +"@bazel/typescript@0.38.2": + version "0.38.2" + resolved "https://registry.yarnpkg.com/@bazel/typescript/-/typescript-0.38.2.tgz#d07e20c910e0e7250ebbdf64f3ef3014ad8e3039" + integrity sha512-KATYNcRaF5JxtmEAczpr1CRZwmPSTAWUA/3Ogp8R17SA7ts9P+K8WPr3eml1b9JkiUzmNvERMU8HNEslDMuhvg== dependencies: protobufjs "6.8.8" semver "5.6.0" diff --git a/package.json b/package.json index 6472902b26..95b589f61f 100644 --- a/package.json +++ b/package.json @@ -40,10 +40,10 @@ "@angular-devkit/schematics": "^8.0.0-beta.15", "@angular/bazel": "file:./tools/npm/@angular_bazel", "@babel/core": "^7.5.5", - "@bazel/jasmine": "0.38.1", - "@bazel/karma": "0.38.1", - "@bazel/protractor": "0.38.1", - "@bazel/typescript": "0.38.1", + "@bazel/jasmine": "0.38.2", + "@bazel/karma": "0.38.2", + "@bazel/protractor": "0.38.2", + "@bazel/typescript": "0.38.2", "@microsoft/api-extractor": "^7.3.9", "@schematics/angular": "^8.0.0-beta.15", "@types/angular": "^1.6.47", diff --git a/packages/bazel/src/builders/files/WORKSPACE.template b/packages/bazel/src/builders/files/WORKSPACE.template index 8185e067a7..06d41b0706 100644 --- a/packages/bazel/src/builders/files/WORKSPACE.template +++ b/packages/bazel/src/builders/files/WORKSPACE.template @@ -15,8 +15,8 @@ workspace( load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive") -RULES_NODEJS_VERSION = "0.38.1" -RULES_NODEJS_SHA256 = "0942d188f4d0de6ddb743b9f6642a26ce1ad89f09c0035a9a5ca5ba9615c96aa" +RULES_NODEJS_VERSION = "0.38.2" +RULES_NODEJS_SHA256 = "1447312c8570e8916da0f5f415186e7098cdd4ce48e04b8e864f793c766959c3" http_archive( name = "build_bazel_rules_nodejs", sha256 = RULES_NODEJS_SHA256, diff --git a/packages/bazel/src/external.bzl b/packages/bazel/src/external.bzl index 9cdb543cfb..8b8d4d62c1 100644 --- a/packages/bazel/src/external.bzl +++ b/packages/bazel/src/external.bzl @@ -14,9 +14,9 @@ load( _ts_providers_dict_to_struct = "ts_providers_dict_to_struct", ) load( - "@build_bazel_rules_nodejs//internal/common:node_module_info.bzl", - _NodeModuleSources = "NodeModuleSources", - _collect_node_modules_aspect = "collect_node_modules_aspect", + "@build_bazel_rules_nodejs//internal/common:npm_package_info.bzl", + _NpmPackageInfo = "NpmPackageInfo", + _node_modules_aspect = "node_modules_aspect", ) load( "@npm_bazel_typescript//internal:ts_config.bzl", @@ -24,11 +24,12 @@ load( ) load( "@build_bazel_rules_nodejs//:providers.bzl", - _transitive_js_ecma_script_module_info = "transitive_js_ecma_script_module_info", + _js_ecma_script_module_info = "js_ecma_script_module_info", + _js_named_module_info = "js_named_module_info", ) -NodeModuleSources = _NodeModuleSources -collect_node_modules_aspect = _collect_node_modules_aspect +NpmPackageInfo = _NpmPackageInfo +node_modules_aspect = _node_modules_aspect tsc_wrapped_tsconfig = _tsc_wrapped_tsconfig COMMON_ATTRIBUTES = _COMMON_ATTRIBUTES @@ -42,4 +43,5 @@ DEFAULT_NG_COMPILER = "@npm//@angular/bazel/bin:ngc-wrapped" DEFAULT_NG_XI18N = "@npm//@angular/bazel/bin:xi18n" FLAT_DTS_FILE_SUFFIX = ".bundle.d.ts" TsConfigInfo = _TsConfigInfo -transitive_js_ecma_script_module_info = _transitive_js_ecma_script_module_info +js_ecma_script_module_info = _js_ecma_script_module_info +js_named_module_info = _js_named_module_info diff --git a/packages/bazel/src/ng_module.bzl b/packages/bazel/src/ng_module.bzl index 2b3196327b..133ac0b3e4 100644 --- a/packages/bazel/src/ng_module.bzl +++ b/packages/bazel/src/ng_module.bzl @@ -13,11 +13,12 @@ load( "DEFAULT_NG_COMPILER", "DEFAULT_NG_XI18N", "DEPS_ASPECTS", - "NodeModuleSources", + "NpmPackageInfo", "TsConfigInfo", - "collect_node_modules_aspect", "compile_ts", - "transitive_js_ecma_script_module_info", + "js_ecma_script_module_info", + "js_named_module_info", + "node_modules_aspect", "ts_providers_dict_to_struct", "tsc_wrapped_tsconfig", ) @@ -527,11 +528,11 @@ def _compile_action( file_inputs += ctx.attr.tsconfig[TsConfigInfo].deps # Also include files from npm fine grained deps as action_inputs. - # These deps are identified by the NodeModuleSources provider. + # These deps are identified by the NpmPackageInfo provider. for d in ctx.attr.deps: - if NodeModuleSources in d: + if NpmPackageInfo in d: # Note: we can't avoid calling .to_list() on sources - file_inputs.extend(_filter_ts_inputs(d[NodeModuleSources].sources.to_list())) + file_inputs.extend(_filter_ts_inputs(d[NpmPackageInfo].sources.to_list())) # Collect the inputs and summary files from our deps action_inputs = depset( @@ -617,7 +618,11 @@ def _ng_module_impl(ctx): # Add in new JS providers ts_providers["providers"].extend([ - transitive_js_ecma_script_module_info( + js_named_module_info( + sources = ts_providers["typescript"]["es5_sources"], + deps = ctx.attr.deps, + ), + js_ecma_script_module_info( sources = ts_providers["typescript"]["es6_sources"], deps = ctx.attr.deps, ), @@ -625,7 +630,7 @@ def _ng_module_impl(ctx): return ts_providers_dict_to_struct(ts_providers) -local_deps_aspects = [collect_node_modules_aspect, _collect_summaries_aspect] +local_deps_aspects = [node_modules_aspect, _collect_summaries_aspect] # Workaround skydoc bug which assumes DEPS_ASPECTS is a str type [local_deps_aspects.append(a) for a in DEPS_ASPECTS] diff --git a/packages/bazel/src/ng_package/ng_package.bzl b/packages/bazel/src/ng_package/ng_package.bzl index f332ec054e..75d8d6e129 100644 --- a/packages/bazel/src/ng_package/ng_package.bzl +++ b/packages/bazel/src/ng_package/ng_package.bzl @@ -14,8 +14,8 @@ specification of this format at https://goo.gl/jB3GVv """ load("@build_bazel_rules_nodejs//internal/common:collect_es6_sources.bzl", "collect_es6_sources") -load("@build_bazel_rules_nodejs//internal/common:node_module_info.bzl", "NodeModuleSources") -load("@build_bazel_rules_nodejs//internal/common:sources_aspect.bzl", "sources_aspect") +load("@build_bazel_rules_nodejs//:providers.bzl", "JSNamedModuleInfo") +load("@build_bazel_rules_nodejs//internal/common:npm_package_info.bzl", "NpmPackageInfo") load( "@build_bazel_rules_nodejs//internal/rollup:rollup_bundle.bzl", "ROLLUP_ATTRS", @@ -347,9 +347,9 @@ def _ng_package_impl(ctx): node_modules_files = _filter_js_inputs(ctx.files.node_modules) # Also include files from npm fine grained deps as inputs. - # These deps are identified by the NodeModuleSources provider. + # These deps are identified by the NpmPackageInfo provider. for d in ctx.attr.deps: - if NodeModuleSources in d: + if NpmPackageInfo in d: node_modules_files += _filter_js_inputs(d.files) esm5_rollup_inputs = depset(node_modules_files, transitive = [esm5_sources]) @@ -455,9 +455,9 @@ def _ng_package_impl(ctx): devfiles = depset() if ctx.attr.include_devmode_srcs: - for d in ctx.attr.deps: - if hasattr(d, "node_sources"): - devfiles = depset(transitive = [devfiles, d.node_sources]) + for dep in ctx.attr.deps: + if JSNamedModuleInfo in dep: + devfiles = depset(transitive = [devfiles, dep[JSNamedModuleInfo].sources]) # Re-use the create_package function from the nodejs npm_package rule. package_dir = create_package( @@ -469,7 +469,7 @@ def _ng_package_impl(ctx): files = depset([package_dir]), )] -DEPS_ASPECTS = [esm5_outputs_aspect, sources_aspect] +DEPS_ASPECTS = [esm5_outputs_aspect] # Workaround skydoc bug which assumes ROLLUP_DEPS_ASPECTS is a str type [DEPS_ASPECTS.append(a) for a in ROLLUP_DEPS_ASPECTS] diff --git a/packages/bazel/src/schematics/ng-add/index.ts b/packages/bazel/src/schematics/ng-add/index.ts index 2cca75c314..d8bb15df0e 100755 --- a/packages/bazel/src/schematics/ng-add/index.ts +++ b/packages/bazel/src/schematics/ng-add/index.ts @@ -50,9 +50,9 @@ function addDevDependenciesToPackageJson(options: Schema) { '@angular/bazel': angularCoreVersion, '@bazel/bazel': '^0.28.1', '@bazel/ibazel': '^0.10.2', - '@bazel/karma': '0.38.1', - '@bazel/protractor': '0.38.1', - '@bazel/typescript': '0.38.1', + '@bazel/karma': '0.38.2', + '@bazel/protractor': '0.38.2', + '@bazel/typescript': '0.38.2', 'history-server': '^1.3.1', }; diff --git a/yarn.lock b/yarn.lock index 58c05f3e7e..322883639e 100644 --- a/yarn.lock +++ b/yarn.lock @@ -319,19 +319,19 @@ resolved "https://registry.yarnpkg.com/@bazel/ibazel/-/ibazel-0.10.3.tgz#2e2b8a1d3e885946eac41db2b1aa6801fb319887" integrity sha512-v1nXbMTHVlMM4z4uWp6XiRoHAyUlYggF1SOboLLWRp0+D22kWixqArWqnozLw2mOtnxr97BdLjluWiho6A8Hjg== -"@bazel/jasmine@0.38.1": - version "0.38.1" - resolved "https://registry.yarnpkg.com/@bazel/jasmine/-/jasmine-0.38.1.tgz#0741e090de1d69a9ef0a961a88e4fdfb6c7d6c77" - integrity sha512-tUVVBceOt3Of2RsY/ys298HfVkPyz44nO+quZ5eU5hwf16KW62rFZsIo+ZgVguUsDmzjjWFN+pUcfA535rPsiw== +"@bazel/jasmine@0.38.2": + version "0.38.2" + resolved "https://registry.yarnpkg.com/@bazel/jasmine/-/jasmine-0.38.2.tgz#567a7b5f9639d8c0b757f8ab41bfff6b84029484" + integrity sha512-O5J/vSQBUwsUqV5dTqOg9SJUuQgLlYAY2NPkC6asYQ+IgtmrtZV+IxWoCC8eZEiu0ZWhV/EwgzXS1FjXI9GR0Q== dependencies: jasmine "~3.4.0" jasmine-core "~3.4.0" v8-coverage "1.0.9" -"@bazel/karma@0.38.1": - version "0.38.1" - resolved "https://registry.yarnpkg.com/@bazel/karma/-/karma-0.38.1.tgz#7175b2284d21b1a725f24d8ca24577ec7c54c222" - integrity sha512-Hz6+7tm70Qv59iX+iryln7WC1GT8R2Jc93zu6EdqlkyVSWbTb6J+pmp3hcBKG+4Y2iAlLk+Czaj8cQu1DRt8GQ== +"@bazel/karma@0.38.2": + version "0.38.2" + resolved "https://registry.yarnpkg.com/@bazel/karma/-/karma-0.38.2.tgz#13c0eb8f09fdc579ef3a2493d6014d77cdc03670" + integrity sha512-pTeHciOyg5ViCCl8Vn5N/wSJSTrxh+26+drlh0GBW8gzUTGIfWDVnma3oA6lLp8zyaCzkpoMP2ukrwBky3nk1Q== dependencies: jasmine-core "2.8.0" karma "~4.1.0" @@ -345,17 +345,17 @@ semver "5.6.0" tmp "0.0.33" -"@bazel/protractor@0.38.1": - version "0.38.1" - resolved "https://registry.yarnpkg.com/@bazel/protractor/-/protractor-0.38.1.tgz#0785c863254071f6d848d1d78c7ceb47af9ae218" - integrity sha512-bAixjddJyGA4OKxkhKIWNH1u5atOm7qCQKTR5GFhEEECuxwabwuyZGDtGzWGKgngCwy7UZitG8BTX2CKU4cknw== +"@bazel/protractor@0.38.2": + version "0.38.2" + resolved "https://registry.yarnpkg.com/@bazel/protractor/-/protractor-0.38.2.tgz#be0804c246d412f8b285fc22a320ab9b471c7a5d" + integrity sha512-bo5v7CpG9TlPX2lx/XueviMt8KY7KDaL7rcw5SR3uU+4w+gX6bTjdnSsVXCUH2YrTTz6VgZaBZO3O0GTbjDP+w== dependencies: protractor "^5.4.2" -"@bazel/typescript@0.38.1": - version "0.38.1" - resolved "https://registry.yarnpkg.com/@bazel/typescript/-/typescript-0.38.1.tgz#fe9a84e0992580a4b67cbc48fbe72f9154bacf56" - integrity sha512-etTftAm6jN0cdHS9Pgb6fJXgHaot+nRhgr8VjUKZr/ITs31U7iDA/9ehjoVFVbqzJzQy4BfdicbydP+cqXz2Xg== +"@bazel/typescript@0.38.2": + version "0.38.2" + resolved "https://registry.yarnpkg.com/@bazel/typescript/-/typescript-0.38.2.tgz#d07e20c910e0e7250ebbdf64f3ef3014ad8e3039" + integrity sha512-KATYNcRaF5JxtmEAczpr1CRZwmPSTAWUA/3Ogp8R17SA7ts9P+K8WPr3eml1b9JkiUzmNvERMU8HNEslDMuhvg== dependencies: protobufjs "6.8.8" semver "5.6.0"