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
This commit is contained in:
Greg Magolan
2019-10-09 16:00:08 -07:00
committed by Miško Hevery
parent cd7b199219
commit 5e694e519b
11 changed files with 86 additions and 78 deletions

View File

@ -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,

View File

@ -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

View File

@ -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]

View File

@ -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]

View File

@ -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',
};