Skip to content

Commit 5cbb18d

Browse files
committed
chore: update to nodejs rules 0.38.2
1 parent 885d06a commit 5cbb18d

File tree

7 files changed

+235
-104
lines changed

7 files changed

+235
-104
lines changed

WORKSPACE

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,11 @@ workspace(name = "angular_material")
22

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

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

1212
# Add sass rules
@@ -39,7 +39,7 @@ yarn_install(
3939
# are executed in the Bazel sandbox.
4040
data = [
4141
"//:angular-tsconfig.json",
42-
"//:tools/bazel/angular_bazel_0.38.0.patch",
42+
"//:tools/bazel/angular_bazel_0.38.2.patch",
4343
"//:tools/bazel/flat_module_factory_resolution.patch",
4444
"//:tools/bazel/manifest_externs_hermeticity.patch",
4545
"//:tools/bazel/postinstall-patches.js",

package.json

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@
6262
"devDependencies": {
6363
"@angular-devkit/core": "^9.0.0-next.5",
6464
"@angular-devkit/schematics": "^9.0.0-next.5",
65-
"@angular/bazel": "^9.0.0-next.7",
65+
"@angular/bazel": "^9.0.0-next.10",
6666
"@angular/compiler-cli": "^9.0.0-next.7",
6767
"@angular/platform-browser-dynamic": "^9.0.0-next.7",
6868
"@angular/platform-server": "^9.0.0-next.7",
@@ -71,10 +71,10 @@
7171
"@bazel/bazel": "^0.29.0",
7272
"@bazel/buildifier": "^0.29.0",
7373
"@bazel/ibazel": "^0.10.3",
74-
"@bazel/jasmine": "^0.38.0",
75-
"@bazel/karma": "^0.38.0",
76-
"@bazel/typescript": "^0.38.0",
77-
"@bazel/protractor": "^0.38.0",
74+
"@bazel/jasmine": "^0.38.2",
75+
"@bazel/karma": "^0.38.2",
76+
"@bazel/typescript": "^0.38.2",
77+
"@bazel/protractor": "^0.38.2",
7878
"@firebase/app-types": "^0.3.2",
7979
"@octokit/rest": "^16.28.7",
8080
"@schematics/angular": "^9.0.0-next.5",

tools/bazel/angular_bazel_0.38.0.patch

Lines changed: 0 additions & 48 deletions
This file was deleted.
Lines changed: 146 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,146 @@
1+
diff --git node_modules/@angular/bazel/src/external.bzl node_modules/@angular/bazel/src/external.bzl
2+
index 9cdb543..8b8d4d6 100755
3+
--- node_modules/@angular/bazel/src/external.bzl
4+
+++ node_modules/@angular/bazel/src/external.bzl
5+
@@ -14,9 +14,9 @@ load(
6+
_ts_providers_dict_to_struct = "ts_providers_dict_to_struct",
7+
)
8+
load(
9+
- "@build_bazel_rules_nodejs//internal/common:node_module_info.bzl",
10+
- _NodeModuleSources = "NodeModuleSources",
11+
- _collect_node_modules_aspect = "collect_node_modules_aspect",
12+
+ "@build_bazel_rules_nodejs//internal/common:npm_package_info.bzl",
13+
+ _NpmPackageInfo = "NpmPackageInfo",
14+
+ _node_modules_aspect = "node_modules_aspect",
15+
)
16+
load(
17+
"@npm_bazel_typescript//internal:ts_config.bzl",
18+
@@ -24,11 +24,12 @@ load(
19+
)
20+
load(
21+
"@build_bazel_rules_nodejs//:providers.bzl",
22+
- _transitive_js_ecma_script_module_info = "transitive_js_ecma_script_module_info",
23+
+ _js_ecma_script_module_info = "js_ecma_script_module_info",
24+
+ _js_named_module_info = "js_named_module_info",
25+
)
26+
27+
-NodeModuleSources = _NodeModuleSources
28+
-collect_node_modules_aspect = _collect_node_modules_aspect
29+
+NpmPackageInfo = _NpmPackageInfo
30+
+node_modules_aspect = _node_modules_aspect
31+
32+
tsc_wrapped_tsconfig = _tsc_wrapped_tsconfig
33+
COMMON_ATTRIBUTES = _COMMON_ATTRIBUTES
34+
@@ -42,4 +43,5 @@ DEFAULT_NG_COMPILER = "@npm//@angular/bazel/bin:ngc-wrapped"
35+
DEFAULT_NG_XI18N = "@npm//@angular/bazel/bin:xi18n"
36+
FLAT_DTS_FILE_SUFFIX = ".bundle.d.ts"
37+
TsConfigInfo = _TsConfigInfo
38+
-transitive_js_ecma_script_module_info = _transitive_js_ecma_script_module_info
39+
+js_ecma_script_module_info = _js_ecma_script_module_info
40+
+js_named_module_info = _js_named_module_info
41+
diff --git node_modules/@angular/bazel/src/ng_module.bzl node_modules/@angular/bazel/src/ng_module.bzl
42+
index 2b31963..98479f7 100755
43+
--- node_modules/@angular/bazel/src/ng_module.bzl
44+
+++ node_modules/@angular/bazel/src/ng_module.bzl
45+
@@ -13,11 +13,12 @@ load(
46+
"DEFAULT_NG_COMPILER",
47+
"DEFAULT_NG_XI18N",
48+
"DEPS_ASPECTS",
49+
- "NodeModuleSources",
50+
+ "NpmPackageInfo",
51+
"TsConfigInfo",
52+
- "collect_node_modules_aspect",
53+
+ "node_modules_aspect",
54+
"compile_ts",
55+
- "transitive_js_ecma_script_module_info",
56+
+ "js_ecma_script_module_info",
57+
+ "js_named_module_info",
58+
"ts_providers_dict_to_struct",
59+
"tsc_wrapped_tsconfig",
60+
)
61+
@@ -527,11 +528,11 @@ def _compile_action(
62+
file_inputs += ctx.attr.tsconfig[TsConfigInfo].deps
63+
64+
# Also include files from npm fine grained deps as action_inputs.
65+
- # These deps are identified by the NodeModuleSources provider.
66+
+ # These deps are identified by the NpmPackageInfo provider.
67+
for d in ctx.attr.deps:
68+
- if NodeModuleSources in d:
69+
+ if NpmPackageInfo in d:
70+
# Note: we can't avoid calling .to_list() on sources
71+
- file_inputs.extend(_filter_ts_inputs(d[NodeModuleSources].sources.to_list()))
72+
+ file_inputs.extend(_filter_ts_inputs(d[NpmPackageInfo].sources.to_list()))
73+
74+
# Collect the inputs and summary files from our deps
75+
action_inputs = depset(
76+
@@ -617,7 +618,11 @@ def _ng_module_impl(ctx):
77+
78+
# Add in new JS providers
79+
ts_providers["providers"].extend([
80+
- transitive_js_ecma_script_module_info(
81+
+ js_named_module_info(
82+
+ sources = ts_providers["typescript"]["es5_sources"],
83+
+ deps = ctx.attr.deps,
84+
+ ),
85+
+ js_ecma_script_module_info(
86+
sources = ts_providers["typescript"]["es6_sources"],
87+
deps = ctx.attr.deps,
88+
),
89+
@@ -625,7 +630,7 @@ def _ng_module_impl(ctx):
90+
91+
return ts_providers_dict_to_struct(ts_providers)
92+
93+
-local_deps_aspects = [collect_node_modules_aspect, _collect_summaries_aspect]
94+
+local_deps_aspects = [node_modules_aspect, _collect_summaries_aspect]
95+
96+
# Workaround skydoc bug which assumes DEPS_ASPECTS is a str type
97+
[local_deps_aspects.append(a) for a in DEPS_ASPECTS]
98+
diff --git node_modules/@angular/bazel/src/ng_package/ng_package.bzl node_modules/@angular/bazel/src/ng_package/ng_package.bzl
99+
index 2eb79b1..bde9e0d 100755
100+
--- node_modules/@angular/bazel/src/ng_package/ng_package.bzl
101+
+++ node_modules/@angular/bazel/src/ng_package/ng_package.bzl
102+
@@ -14,8 +14,8 @@ specification of this format at https://goo.gl/jB3GVv
103+
"""
104+
105+
load("@build_bazel_rules_nodejs//internal/common:collect_es6_sources.bzl", "collect_es6_sources")
106+
-load("@build_bazel_rules_nodejs//internal/common:node_module_info.bzl", "NodeModuleSources")
107+
-load("@build_bazel_rules_nodejs//internal/common:sources_aspect.bzl", "sources_aspect")
108+
+load("@build_bazel_rules_nodejs//:providers.bzl", "JSNamedModuleInfo")
109+
+load("@build_bazel_rules_nodejs//internal/common:npm_package_info.bzl", "NpmPackageInfo")
110+
load(
111+
"@build_bazel_rules_nodejs//internal/rollup:rollup_bundle.bzl",
112+
"ROLLUP_ATTRS",
113+
@@ -347,9 +347,9 @@ def _ng_package_impl(ctx):
114+
node_modules_files = _filter_js_inputs(ctx.files.node_modules)
115+
116+
# Also include files from npm fine grained deps as inputs.
117+
- # These deps are identified by the NodeModuleSources provider.
118+
+ # These deps are identified by the NpmPackageInfo provider.
119+
for d in ctx.attr.deps:
120+
- if NodeModuleSources in d:
121+
+ if NpmPackageInfo in d:
122+
node_modules_files += _filter_js_inputs(d.files)
123+
esm5_rollup_inputs = depset(node_modules_files, transitive = [esm5_sources])
124+
125+
@@ -455,9 +455,9 @@ def _ng_package_impl(ctx):
126+
127+
devfiles = depset()
128+
if ctx.attr.include_devmode_srcs:
129+
- for d in ctx.attr.deps:
130+
- if hasattr(d, "node_sources"):
131+
- devfiles = depset(transitive = [devfiles, d.node_sources])
132+
+ for dep in ctx.attr.deps:
133+
+ if JSNamedModuleInfo in dep:
134+
+ devfiles = depset(transitive = [devfiles, dep[JSNamedModuleInfo].sources])
135+
136+
# Re-use the create_package function from the nodejs npm_package rule.
137+
package_dir = create_package(
138+
@@ -469,7 +469,7 @@ def _ng_package_impl(ctx):
139+
files = depset([package_dir]),
140+
)]
141+
142+
-DEPS_ASPECTS = [esm5_outputs_aspect, sources_aspect]
143+
+DEPS_ASPECTS = [esm5_outputs_aspect]
144+
145+
# Workaround skydoc bug which assumes ROLLUP_DEPS_ASPECTS is a str type
146+
[DEPS_ASPECTS.append(a) for a in ROLLUP_DEPS_ASPECTS]

tools/bazel/postinstall-patches.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -101,9 +101,9 @@ shelljs.cat(path.join(__dirname, './manifest_externs_hermeticity.patch')).exec('
101101

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

108108
/**
109109
* Reads the specified file and replaces matches of the search expression

tools/dev-server/index.bzl

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
load("@build_bazel_rules_nodejs//internal/common:sources_aspect.bzl", "sources_aspect")
1+
load("@build_bazel_rules_nodejs//:providers.bzl", "JSNamedModuleInfo")
22

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

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

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

0 commit comments

Comments
 (0)