Skip to content

chore: update to nodejs rules 0.38.2 #17361

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Oct 10, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions WORKSPACE
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@ workspace(name = "angular_material")

load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")

# Add NodeJS rules (explicitly used for sass bundle rules)
# Add NodeJS rules
http_archive(
name = "build_bazel_rules_nodejs",
sha256 = "1249a60f88e4c0a46d78de06be04d3d41e7421dcfa0c956de65309a7b7ecf6f4",
urls = ["https://github.com/bazelbuild/rules_nodejs/releases/download/0.38.0/rules_nodejs-0.38.0.tar.gz"],
sha256 = "1447312c8570e8916da0f5f415186e7098cdd4ce48e04b8e864f793c766959c3",
urls = ["https://github.com/bazelbuild/rules_nodejs/releases/download/0.38.2/rules_nodejs-0.38.2.tar.gz"],
)

# Add sass rules
Expand Down Expand Up @@ -39,7 +39,7 @@ yarn_install(
# are executed in the Bazel sandbox.
data = [
"//:angular-tsconfig.json",
"//:tools/bazel/angular_bazel_0.38.0.patch",
"//:tools/bazel/angular_bazel_0.38.2.patch",
"//:tools/bazel/flat_module_factory_resolution.patch",
"//:tools/bazel/manifest_externs_hermeticity.patch",
"//:tools/bazel/postinstall-patches.js",
Expand Down
10 changes: 5 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@
"devDependencies": {
"@angular-devkit/core": "^9.0.0-next.5",
"@angular-devkit/schematics": "^9.0.0-next.5",
"@angular/bazel": "^9.0.0-next.7",
"@angular/bazel": "^9.0.0-next.10",
"@angular/compiler-cli": "^9.0.0-next.7",
"@angular/platform-browser-dynamic": "^9.0.0-next.7",
"@angular/platform-server": "^9.0.0-next.7",
Expand All @@ -71,10 +71,10 @@
"@bazel/bazel": "^0.29.0",
"@bazel/buildifier": "^0.29.0",
"@bazel/ibazel": "^0.10.3",
"@bazel/jasmine": "^0.38.0",
"@bazel/karma": "^0.38.0",
"@bazel/typescript": "^0.38.0",
"@bazel/protractor": "^0.38.0",
"@bazel/jasmine": "^0.38.2",
"@bazel/karma": "^0.38.2",
"@bazel/typescript": "^0.38.2",
"@bazel/protractor": "^0.38.2",
"@firebase/app-types": "^0.3.2",
"@octokit/rest": "^16.28.7",
"@schematics/angular": "^9.0.0-next.5",
Expand Down
48 changes: 0 additions & 48 deletions tools/bazel/angular_bazel_0.38.0.patch

This file was deleted.

146 changes: 146 additions & 0 deletions tools/bazel/angular_bazel_0.38.2.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,146 @@
diff --git node_modules/@angular/bazel/src/external.bzl node_modules/@angular/bazel/src/external.bzl
index 9cdb543..8b8d4d6 100755
--- node_modules/@angular/bazel/src/external.bzl
+++ node_modules/@angular/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 node_modules/@angular/bazel/src/ng_module.bzl node_modules/@angular/bazel/src/ng_module.bzl
index 2b31963..98479f7 100755
--- node_modules/@angular/bazel/src/ng_module.bzl
+++ node_modules/@angular/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",
+ "node_modules_aspect",
"compile_ts",
- "transitive_js_ecma_script_module_info",
+ "js_ecma_script_module_info",
+ "js_named_module_info",
"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 node_modules/@angular/bazel/src/ng_package/ng_package.bzl node_modules/@angular/bazel/src/ng_package/ng_package.bzl
index 2eb79b1..bde9e0d 100755
--- node_modules/@angular/bazel/src/ng_package/ng_package.bzl
+++ node_modules/@angular/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]
4 changes: 2 additions & 2 deletions tools/bazel/postinstall-patches.js
Original file line number Diff line number Diff line change
Expand Up @@ -101,9 +101,9 @@ shelljs.cat(path.join(__dirname, './manifest_externs_hermeticity.patch')).exec('

// Patches https://github.com/angular/angular/pull/32889 into our "@angular/bazel"
// installation. We need to patch it because otherwise the @angular/bazel PR cannot land
// as the "component-unit-tests" job will fail due to not being updated to 0.38.0. Either
// as the "component-unit-tests" job will fail due to not being updated to 0.38.2. Either
// the framework or component repo needs to be patched to unblock the cyclic dependency.
shelljs.cat(path.join(__dirname, './angular_bazel_0.38.0.patch')).exec('patch -p0');
shelljs.cat(path.join(__dirname, './angular_bazel_0.38.2.patch')).exec('patch -p0');

/**
* Reads the specified file and replaces matches of the search expression
Expand Down
13 changes: 4 additions & 9 deletions tools/dev-server/index.bzl
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
load("@build_bazel_rules_nodejs//internal/common:sources_aspect.bzl", "sources_aspect")
load("@build_bazel_rules_nodejs//:providers.bzl", "JSNamedModuleInfo")

"""Gets the workspace name of the given rule context."""

Expand Down Expand Up @@ -27,16 +27,12 @@ def _dev_server_rule_impl(ctx):
# Walk through all dependencies specified in the "deps" attribute. These labels need to be
# unwrapped in case there are built using TypeScript-specific rules. This is because targets
# built using "ts_library" or "ng_module" do not declare the generated JS files as default
# rule output. The output aspect that is applied to the "deps" attribute, provides two struct
# fields which resolve to the unwrapped JS output files.
# https://github.com/bazelbuild/rules_nodejs/blob/e04c8c31f3cb859754ea5c5e97f331a3932b725d/internal/common/sources_aspect.bzl#L53-L55
# rule output.
for d in ctx.attr.deps:
if hasattr(d, "node_sources"):
files = depset(transitive = [files, d.node_sources])
if JSNamedModuleInfo in d:
files = depset(transitive = [files, d[JSNamedModuleInfo].sources])
elif hasattr(d, "files"):
files = depset(transitive = [files, d.files])
if hasattr(d, "dev_scripts"):
files = depset(transitive = [files, d.dev_scripts])

workspace_name = _get_workspace_name(ctx)
root_paths = ["", "/".join([workspace_name, ctx.label.package])] + ctx.attr.additional_root_paths
Expand Down Expand Up @@ -95,7 +91,6 @@ dev_server_rule = rule(
),
"deps": attr.label_list(
allow_files = True,
aspects = [sources_aspect],
doc = """
Dependencies that need to be available to the dev-server. This attribute can be
used for TypeScript targets which provide multiple flavors of output.
Expand Down
Loading