Skip to content

Commit 15efb67

Browse files
authored
build: update to rules_nodejs 1.6.0 (#19185)
1 parent 58b8d30 commit 15efb67

File tree

7 files changed

+93
-50
lines changed

7 files changed

+93
-50
lines changed

WORKSPACE

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@ load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")
88
# Add NodeJS rules
99
http_archive(
1010
name = "build_bazel_rules_nodejs",
11-
sha256 = "d0c4bb8b902c1658f42eb5563809c70a06e46015d64057d25560b0eb4bdc9007",
12-
urls = ["https://github.com/bazelbuild/rules_nodejs/releases/download/1.5.0/rules_nodejs-1.5.0.tar.gz"],
11+
sha256 = "f9e7b9f42ae202cc2d2ce6d698ccb49a9f7f7ea572a78fd451696d03ef2ee116",
12+
urls = ["https://github.com/bazelbuild/rules_nodejs/releases/download/1.6.0/rules_nodejs-1.6.0.tar.gz"],
1313
)
1414

1515
# Add sass rules

package.json

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -76,10 +76,10 @@
7676
"@bazel/bazelisk": "^1.4.0",
7777
"@bazel/buildifier": "^2.2.1",
7878
"@bazel/ibazel": "^0.12.3",
79-
"@bazel/jasmine": "^1.5.0",
80-
"@bazel/karma": "^1.5.0",
81-
"@bazel/protractor": "^1.5.0",
82-
"@bazel/typescript": "^1.5.0",
79+
"@bazel/jasmine": "^1.6.0",
80+
"@bazel/karma": "^1.6.0",
81+
"@bazel/protractor": "^1.6.0",
82+
"@bazel/typescript": "^1.6.0",
8383
"@firebase/app-types": "^0.3.2",
8484
"@octokit/rest": "16.28.7",
8585
"@schematics/angular": "^9.0.7",

src/dev-app/BUILD.bazel

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
load("@build_bazel_rules_nodejs//:index.bzl", "pkg_web")
2-
load("@build_bazel_rules_nodejs//internal/common:devmode_js_sources.bzl", "devmode_js_sources")
32
load("//tools:create-system-config.bzl", "create_system_config")
43
load("//tools:defaults.bzl", "ng_module", "sass_binary")
4+
load("//tools:es5-named-output.bzl", "es5_named_output")
55
load("//tools/dev-server:index.bzl", "dev_server")
66

77
package(default_visibility = ["//visibility:public"])
@@ -176,7 +176,7 @@ dev_server(
176176

177177
# Collects all ES5 JavaScript files which are required to serve the dev-app. By default,
178178
# ts_library and ng_module targets only expose the type definition files as outputs.
179-
devmode_js_sources(
179+
es5_named_output(
180180
name = "dev_app_js_sources",
181181
tags = ["manual"],
182182
deps = [":dev-app"],

tools/es5-named-output.bzl

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
load("@build_bazel_rules_nodejs//:providers.bzl", "JSNamedModuleInfo")
2+
3+
"""Implementation of the es5_named_output rule.
4+
Direct and transitive JavaScript files and sourcemaps are collected via ts_library
5+
JSNamedModuleInfo provider.
6+
https://github.com/bazelbuild/rules_nodejs/blob/a167311c025be2a77ba0d84e6a2ddcafe1c0564d/packages/typescript/src/internal/build_defs.bzl#L312
7+
"""
8+
9+
def _es5_named_output_impl(ctx):
10+
depsets = []
11+
for dep in ctx.attr.deps:
12+
if JSNamedModuleInfo in dep:
13+
depsets.append(dep[JSNamedModuleInfo].sources)
14+
if hasattr(dep, "files"):
15+
depsets.append(dep.files)
16+
sources = depset(transitive = depsets)
17+
18+
return [DefaultInfo(files = sources)]
19+
20+
"""Rule that collects all ES5 named outputs from a list of deps.
21+
It can be used as input for all those rules that require named JavaScript sources (such as
22+
pkg_web).
23+
We need this because ts_library and ng_module targets output only expose the type definition files
24+
as outputs.
25+
"""
26+
es5_named_output = rule(
27+
implementation = _es5_named_output_impl,
28+
attrs = {
29+
"deps": attr.label_list(
30+
allow_files = True,
31+
),
32+
},
33+
)

tools/postinstall/apply-patches.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ const fs = require('fs');
1212
* Version of the post install patch. Needs to be incremented when
1313
* existing patches or edits have been modified.
1414
*/
15-
const PATCH_VERSION = 4;
15+
const PATCH_VERSION = 5;
1616

1717
/** Path to the project directory. */
1818
const projectDir = path.join(__dirname, '../..');

tools/postinstall/manifest_externs_hermeticity.patch

Lines changed: 32 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
diff --git node_modules/@bazel/typescript/internal/build_defs.bzl node_modules/@bazel/typescript/internal/build_defs.bzl
2-
index 7fef44c..4e25ed7 100644
2+
index 03cb68fdf..2f604234c 100755
33
--- node_modules/@bazel/typescript/internal/build_defs.bzl
44
+++ node_modules/@bazel/typescript/internal/build_defs.bzl
5-
@@ -93,25 +93,23 @@ def _filter_ts_inputs(all_inputs):
6-
if f.path.endswith(".js") or f.path.endswith(".ts") or f.path.endswith(".json")
5+
@@ -102,17 +102,17 @@ def _filter_ts_inputs(all_inputs):
6+
if f.extension in ["js", "jsx", "ts", "tsx", "json"]
77
]
8-
8+
99
+def _filter_compile_outputs(all_outputs):
1010
+ return [
1111
+ f
@@ -24,41 +24,51 @@ index 7fef44c..4e25ed7 100644
2424
- ctx.actions.write(output, content = "")
2525
- else:
2626
- action_outputs.append(output)
27-
-
28-
- # TODO(plf): For now we mock creation of files other than {name}.js.
29-
- for externs_file in externs_files:
30-
- ctx.actions.write(output = externs_file, content = "")
3127
+ compile_outputs = _filter_compile_outputs(outputs)
32-
28+
29+
# TODO(plf): For now we mock creation of files other than {name}.js.
30+
for externs_file in externs_files:
31+
@@ -120,7 +120,9 @@ def _compile_action(ctx, inputs, outputs, tsconfig_file, node_opts, description
32+
3333
# A ts_library that has only .d.ts inputs will have no outputs,
3434
# therefore there are no actions to execute
3535
- if not action_outputs:
3636
+ if not compile_outputs:
3737
+ for file in [f for f in outputs if not f in compile_outputs]:
38-
+ ctx.actions.write(output = file, content = "")
38+
+ ctx.actions.write(output = file, content = "")
3939
return None
40-
40+
4141
action_inputs.extend(_filter_ts_inputs(ctx.files.node_modules))
42-
@@ -146,7 +142,7 @@ def _compile_action(ctx, inputs, outputs, tsconfig_file, node_opts, description
43-
progress_message = "Compiling TypeScript (%s) %s" % (description, ctx.label),
44-
mnemonic = mnemonic,
45-
inputs = action_inputs,
46-
- outputs = action_outputs,
47-
+ outputs = outputs,
48-
# Use the built-in shell environment
49-
# Allow for users who set a custom shell that can locate standard binaries like tr and uname
50-
# See https://github.com/NixOS/nixpkgs/issues/43955#issuecomment-407546331
51-
@@ -163,7 +159,7 @@ def _compile_action(ctx, inputs, outputs, tsconfig_file, node_opts, description
42+
@@ -156,7 +158,7 @@ def _compile_action(ctx, inputs, outputs, tsconfig_file, node_opts, description
43+
progress_message = "Compiling TypeScript (%s) %s" % (description, ctx.label),
44+
mnemonic = "TypeScriptCompile",
45+
inputs = action_inputs,
46+
- outputs = action_outputs,
47+
+ outputs = outputs,
48+
# Use the built-in shell environment
49+
# Allow for users who set a custom shell that can locate standard binaries like tr and uname
50+
# See https://github.com/NixOS/nixpkgs/issues/43955#issuecomment-407546331
51+
@@ -179,7 +181,7 @@ def _compile_action(ctx, inputs, outputs, tsconfig_file, node_opts, description
52+
progress_message = "Compiling TypeScript (%s) %s" % (description, ctx.label),
53+
mnemonic = "tsc",
54+
inputs = action_inputs,
55+
- outputs = action_outputs,
56+
+ outputs = compile_outputs,
57+
# Use the built-in shell environment
58+
# Allow for users who set a custom shell that can locate standard binaries like tr and uname
59+
# See https://github.com/NixOS/nixpkgs/issues/43955#issuecomment-407546331
60+
@@ -194,7 +196,7 @@ def _compile_action(ctx, inputs, outputs, tsconfig_file, node_opts, description
5261
label = ctx.label,
5362
tsconfig = tsconfig_file,
5463
inputs = action_inputs,
5564
- outputs = action_outputs,
5665
+ outputs = compile_outputs,
5766
compiler = ctx.executable.compiler,
5867
)
68+
5969

6070
diff --git node_modules/@bazel/typescript/internal/tsc_wrapped/tsc_wrapped.js node_modules/@bazel/typescript/internal/tsc_wrapped/tsc_wrapped.js
61-
index 0346123..3d9bc64 100644
71+
index ec813f654..738342a8f 100755
6272
--- node_modules/@bazel/typescript/internal/tsc_wrapped/tsc_wrapped.js
6373
+++ node_modules/@bazel/typescript/internal/tsc_wrapped/tsc_wrapped.js
6474
@@ -381,6 +381,23 @@ function createProgramAndEmit(fileLoader, options, bazelOpts, files, disabledTse

yarn.lock

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -320,36 +320,36 @@
320320
integrity sha512-fDWMV2x03/K5dZnAEBeKS0gpn0LWCiv5kjhMB6q0f1Q5x6S7/+xoownxgWyNRo+qHxn+a2CtQSCRUpSC8QNg/w==
321321

322322
"@bazel/ibazel@^0.12.3":
323-
version "0.12.3"
324-
resolved "https://registry.yarnpkg.com/@bazel/ibazel/-/ibazel-0.12.3.tgz#c8c82647f920cd529c7793c50e087e1a754a5973"
325-
integrity sha512-dyx62Uo5kogrxFmqFNpGvbavfr8yjmuQlOyZczOuA60piULwlUsO7Oh3/1OUWKDSXaMMqHhFQfpdl+z0HjI6TQ==
323+
version "0.12.4"
324+
resolved "https://registry.yarnpkg.com/@bazel/ibazel/-/ibazel-0.12.4.tgz#ddda7c8ead6e29dc8d637af446086a750f395218"
325+
integrity sha512-FzOy+esB/fXVDbAmL6Ce2yCEy+PESZih8GypKhi0B8XzoZHAAn3QNnQcMNwo9PrIfp3G1989nM/JQ1b8jwEinQ==
326326

327-
"@bazel/jasmine@^1.5.0":
328-
version "1.5.0"
329-
resolved "https://registry.yarnpkg.com/@bazel/jasmine/-/jasmine-1.5.0.tgz#be980cb8e9f82a87036e27f86278bd7a54d74c43"
330-
integrity sha512-r06GTWKxZYs6msPTbIJ+vcHLQke6wMULo3p4w3ecDybRzKq54syjSzlmejIm9wJ8OHrVyRRSvHgvygxCGJfhTA==
327+
"@bazel/jasmine@^1.6.0":
328+
version "1.6.0"
329+
resolved "https://registry.yarnpkg.com/@bazel/jasmine/-/jasmine-1.6.0.tgz#c469ab8725d9a2e48c0c3c965861ff8add9272ac"
330+
integrity sha512-WtOQDtIMHKTxlp0+FcdrADV6LMrpJV7eEGZippSNFPL5YhwwrPfCSOs5WkooatsrjL5YEszswzqQXFjvC7EZKQ==
331331
dependencies:
332332
jasmine "~3.5.0"
333333
jasmine-core "~3.5.0"
334334
jasmine-reporters "~2.3.2"
335335
v8-coverage "1.0.9"
336336

337-
"@bazel/karma@^1.5.0":
338-
version "1.5.0"
339-
resolved "https://registry.yarnpkg.com/@bazel/karma/-/karma-1.5.0.tgz#75ea27c3c2a8a7fadbb5c5ab644c3acd3bc22702"
340-
integrity sha512-j5S2Xya4Rr7vK0DzTaZ8FKDHBydtTNldwlx+rihjKJgbEBt76wQM7ucXD6aSA23lC+JM/dPRSKkpIIGeWf2JdQ==
337+
"@bazel/karma@^1.6.0":
338+
version "1.6.0"
339+
resolved "https://registry.yarnpkg.com/@bazel/karma/-/karma-1.6.0.tgz#98950b71114dd9ec169e6778a35d31ae1f578655"
340+
integrity sha512-9cX0E1SiMWwA70ZMFnMzeqSRn3biduGx03bGV77FSUYKocZpyfU2cOEygYGfxAqHnyM7x4cS8nflRv3+ZE0Aqg==
341341
dependencies:
342342
tmp "0.1.0"
343343

344-
"@bazel/protractor@^1.5.0":
345-
version "1.5.0"
346-
resolved "https://registry.yarnpkg.com/@bazel/protractor/-/protractor-1.5.0.tgz#ac92442bf38f5cd718812e4cca41ba2e5ebf1fa5"
347-
integrity sha512-nUwOOUjNGJUU18JiE3sPOBzIul0jvGApEEikntKTLLwQ7w7/1TnOdXDWvHXrXRW3nwit6flWIzEUoFtWgwtCeg==
344+
"@bazel/protractor@^1.6.0":
345+
version "1.6.0"
346+
resolved "https://registry.yarnpkg.com/@bazel/protractor/-/protractor-1.6.0.tgz#cf095a1dbc038def7031c513a3b87f4e79bedb00"
347+
integrity sha512-gPiRv0oUJbVPpQ9nrwe5vjkffAc8VsYJhpTGgG+8aPdOaTLWgmBP/sy4BdfijU9O1Z/mNYojQCZgMzQz6kAvdg==
348348

349-
"@bazel/typescript@^1.5.0":
350-
version "1.5.0"
351-
resolved "https://registry.yarnpkg.com/@bazel/typescript/-/typescript-1.5.0.tgz#d69324c08e7dbfe10b21a6fcb7b4d66c71c8d171"
352-
integrity sha512-Vi8n1p35EhxGC22TEnmnVPlyakrALyH2ccVN5J6YeZXE1oWlSMSqQEhXKTjqUfQ3FT76nW1K91AdH4TG3me5nQ==
349+
"@bazel/typescript@^1.6.0":
350+
version "1.6.0"
351+
resolved "https://registry.yarnpkg.com/@bazel/typescript/-/typescript-1.6.0.tgz#8dfd29e71bcf917d5f9cb67f19ac4dcfc9082439"
352+
integrity sha512-vAKuwy1Hgl+t3M3sH/G0oqHRYN35TdENj+0lsCI3x7EbSzyI6cbA3YQrLrlyvdScksqOpZa3PZ3UBGqfJJq2DA==
353353
dependencies:
354354
protobufjs "6.8.8"
355355
semver "5.6.0"

0 commit comments

Comments
 (0)