Skip to content

Commit 32c00ab

Browse files
josephperrottcrisbeto
authored andcommitted
build: standardize usage of js_binary (#62860)
Remove usages of nodejs_binary and use a commonly defined js_binary macro PR Close #62860
1 parent ecf2ad1 commit 32c00ab

File tree

30 files changed

+158
-167
lines changed

30 files changed

+158
-167
lines changed

adev/shared-docs/pipeline/_guides.bzl

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,7 @@ def _generate_guides(ctx):
2929
# For each input file "xxx.md", we want to write an output file "xxx.html"
3030
html_outputs += [ctx.actions.declare_file("%s.html" % relative_basepath)]
3131

32-
# Define an action that runs the nodejs_binary executable. This is the main thing that this
33-
# rule does. If mermaid blocks are enabled then a different executable is used.
32+
# Define an action that runs the executable.
3433
if (ctx.attr.mermaid_blocks):
3534
ctx.actions.run(
3635
inputs = depset(ctx.files.srcs + ctx.files.data),

adev/shared-docs/pipeline/api-gen/extraction/extract_api_to_json.bzl

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,8 +45,7 @@ def _extract_api_to_json(ctx):
4545
# Pass the set of (optional) extra entries
4646
args.add_joined(ctx.files.extra_entries, join_with = ",")
4747

48-
# Define an action that runs the nodejs_binary executable. This is
49-
# the main thing that this rule does.
48+
# Define an action that runs the executable.
5049
ctx.actions.run(
5150
inputs = depset(ctx.files.srcs + ctx.files.extra_entries),
5251
executable = ctx.executable._extract_api_to_json,

adev/shared-docs/pipeline/api-gen/manifest/generate_api_manifest.bzl

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,7 @@ def _generate_api_manifest(ctx):
1515
manifest = ctx.actions.declare_file("manifest.json")
1616
args.add(manifest.path)
1717

18-
# Define an action that runs the nodejs_binary executable. This is
19-
# the main thing that this rule does.
18+
# Define an action that runs the executable.
2019
ctx.actions.run(
2120
inputs = depset(ctx.files.srcs),
2221
executable = ctx.executable._generate_api_manifest,

adev/shared-docs/pipeline/api-gen/rendering/render_api_to_html.bzl

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,7 @@ def _render_api_to_html(ctx):
1818
args.add(html_output_directory.path)
1919
outputs = [html_output_directory]
2020

21-
# Define an action that runs the nodejs_binary executable. This is
22-
# the main thing that this rule does.
21+
# Define an action that runs the executable.
2322
ctx.actions.run(
2423
inputs = depset(ctx.files.srcs),
2524
executable = ctx.executable._render_api_to_html,

contributing-docs/building-with-bazel.md

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -136,11 +136,6 @@ See subcommands that bazel executes (helpful for debugging):
136136
yarn bazel build //packages/core:package -s
137137
```
138138

139-
To debug nodejs_binary executable paths uncomment `find . -name rollup 1>&2` (~ line 96) in
140-
```sh
141-
open $(yarn -s bazel info output_base)/external/build_bazel_rules_nodejs/internal/node_launcher.sh
142-
```
143-
144139
## Stamping
145140

146141
Bazel supports the ability to include non-hermetic information from the version control system in

integration/ng-modules-importability/index.bzl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
load("@aspect_rules_js//js:defs.bzl", "js_test")
21
load("@bazel_skylib//rules:write_file.bzl", "write_file")
2+
load("//tools:defaults2.bzl", "js_test")
33

44
def module_test(name, npm_packages, skipped_entry_points = [], additional_deps = [], **kwargs):
55
write_file(

packages/common/BUILD.bazel

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,14 @@
1-
load("@build_bazel_rules_nodejs//:index.bzl", "generated_file_test")
21
load("//packages/common/locales:index.bzl", "generate_base_currencies_file")
32
load("//tools:defaults.bzl", "generate_api_docs")
43
load("//tools:defaults2.bzl", "api_golden_test", "api_golden_test_npm_package", "ng_package", "ng_project", "npm_package")
54

65
package(default_visibility = ["//visibility:public"])
76

87
# This generates the `src/i18n/currencies.ts` file through the `generate-locales` tool. Since
9-
# the base currencies file is checked-in for Google3, we add a `generated_file_test` to ensure
10-
# the checked-in file is up-to-date. To disambiguate from the test, we use a more precise target
11-
# name here.
8+
# the base locale file is checked-in for Google3, it is additionally stored in a golden location.
129
generate_base_currencies_file(
13-
name = "base_currencies_file_generated",
14-
output_file = "base_currencies_generated.ts",
15-
)
16-
17-
generated_file_test(
1810
name = "base_currencies_file",
1911
src = "src/i18n/currencies.ts",
20-
generated = ":base_currencies_file_generated",
2112
)
2213

2314
ng_project(

packages/common/locales/BUILD.bazel

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,14 @@
1-
load("@build_bazel_rules_nodejs//:index.bzl", "generated_file_test")
21
load("//packages/common/locales:index.bzl", "LOCALES", "generate_all_locale_files", "generate_closure_locale_file")
32
load("//tools:defaults.bzl", "pkg_npm")
43
load("//tools:defaults2.bzl", "ts_project")
54

65
package(default_visibility = ["//visibility:public"])
76

87
# This generates the `closure-locale.ts` file through the `generate-locales` tool. Since
9-
# the `closure-locale.ts` file is checked-in for Google3, we add a `generated_file_test` to
10-
# ensure the checked-in file is up-to-date. To disambiguate from the test, we use a more
11-
# precise target name here.
8+
# the base locale file is checked-in for Google3, it is additionally stored in a golden location.
129
generate_closure_locale_file(
13-
name = "closure_locale_file_generated",
14-
output_file = "closure_locale_generated.ts",
15-
)
16-
17-
generated_file_test(
1810
name = "closure_locale_file",
1911
src = "closure-locale.ts",
20-
generated = ":closure_locale_file_generated",
2112
)
2213

2314
generate_all_locale_files(

packages/common/locales/generate-locales-tool/BUILD.bazel

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,11 @@ ts_config(
1414
ts_project(
1515
name = "generate-locales-tool",
1616
srcs = glob(["*.ts"]),
17+
# Disabled to remove doubling of runtime files as we are approaching the 70k limit when
18+
# CLDR files are also included in the binary action.
19+
enable_runtime_rnjs_interop = False,
1720
deps = [
1821
"//:node_modules/@types/cldrjs",
19-
"//:node_modules/@types/node",
2022
"//:node_modules/cldr",
2123
"//:node_modules/cldrjs",
2224
"//:node_modules/tinyglobby",

packages/common/locales/generate-locales-tool/bin/BUILD.bazel

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
load("//tools:defaults.bzl", "nodejs_binary")
2-
load("//tools:defaults2.bzl", "ts_project")
1+
load("//tools:defaults2.bzl", "js_binary", "ts_project")
32

43
package(default_visibility = ["//visibility:public"])
54

@@ -13,18 +12,24 @@ BIN_ENTRYPOINTS = [
1312
ts_project(
1413
name = "bin",
1514
srcs = glob(["*.ts"]),
15+
# Disabled to remove doubling of runtime files as we are approaching the 70k limit when
16+
# CLDR files are also included in the binary action.
17+
enable_runtime_rnjs_interop = False,
1618
deps = [
17-
"//:node_modules/@types/node",
1819
"//packages/common/locales/generate-locales-tool:generate-locales-tool_rjs",
1920
],
2021
)
2122

22-
[nodejs_binary(
23+
[js_binary(
2324
name = entrypoint,
2425
data = [
25-
":bin",
26+
":bin_rjs",
2627
"@cldr_json_data//:all_json",
2728
"@cldr_xml_data//:all_xml",
2829
],
2930
entry_point = ":%s.js" % entrypoint,
31+
no_copy_to_bin = [
32+
"@cldr_xml_data//:all_xml",
33+
"@cldr_json_data//:all_json",
34+
],
3035
) for entrypoint in BIN_ENTRYPOINTS]

0 commit comments

Comments
 (0)