build: migrate remaing esbuild and nodejs_binary usages to new toolchain (#62498)

Migrate the remaing usages of esbuild and nodejs_binary in adev to the new toolchain versions.

PR Close #62498
This commit is contained in:
Joey Perrott
2025-07-02 19:57:26 +00:00
committed by Jessica Janiuk
parent f8807a30be
commit ffce768115
23 changed files with 198 additions and 179 deletions
+3 -3
View File
@@ -53,12 +53,12 @@ ng_package(
"//adev/shared-docs/pipeline:_playground.bzl",
"//adev/shared-docs/pipeline:_stackblitz.bzl",
"//adev/shared-docs/pipeline:_tutorial.bzl",
"//adev/shared-docs/pipeline:playground.mjs",
"//adev/shared-docs/pipeline:stackblitz.mjs",
"//adev/shared-docs/pipeline:tutorial.mjs",
"//adev/shared-docs/pipeline/examples/stackblitz:stackblitz.mjs",
"//adev/shared-docs/pipeline/examples/template:files",
"//adev/shared-docs/pipeline/guides:guides.mjs",
"//adev/shared-docs/pipeline/guides:guides-no-mermaid.mjs",
"//adev/shared-docs/pipeline/tutorials:playground.mjs",
"//adev/shared-docs/pipeline/tutorials:tutorial.mjs",
"//adev/shared-docs/pipeline/tutorials/common:files",
"//adev/shared-docs/styles",
],
+21 -113
View File
@@ -1,10 +1,4 @@
load("@aspect_rules_js//js:defs.bzl", "js_library")
load("@build_bazel_rules_nodejs//:index.bzl", "nodejs_binary")
# BEGIN-DEV-ONLY
# This section is only used here in the dev-infra repo as the resulting bundle is published in
# the package.
load("//tools:defaults.bzl", "esbuild_esm_bundle")
load("@aspect_rules_js//js:defs.bzl", "js_binary", "js_library")
package(default_visibility = ["//adev/shared-docs/pipeline:__subpackages__"])
@@ -13,90 +7,6 @@ js_library(
srcs = ["esbuild.config.mjs"],
)
esbuild_esm_bundle(
name = "stackblitz-bundle",
entry_point = "//adev/shared-docs/pipeline/examples/stackblitz:index.mts",
# JSDOM should not be bundled because it has workers and dynamic imports.
external = ["jsdom"],
metafile = False,
output = "stackblitz.mjs",
platform = "node",
target = "es2022",
visibility = ["//visibility:public"],
deps = [
"//adev/shared-docs/pipeline/examples/stackblitz:index",
],
)
esbuild_esm_bundle(
name = "previews-bundle",
entry_point = "//adev/shared-docs/pipeline/examples/previews:index.mts",
external = [
"typescript",
],
metafile = False,
output = "previews.mjs",
platform = "node",
target = "es2022",
visibility = ["//visibility:public"],
deps = [
"//adev/shared-docs/pipeline/examples/previews:index",
"@npm//typescript",
],
)
esbuild_esm_bundle(
name = "zip-bundle",
entry_point = "//adev/shared-docs/pipeline/examples/zip:index.mts",
metafile = False,
output = "zip.mjs",
platform = "node",
target = "es2022",
visibility = ["//visibility:public"],
deps = [
"//adev/shared-docs/pipeline/examples/zip:index",
],
)
esbuild_esm_bundle(
name = "playground-bundle",
entry_point = "//adev/shared-docs/pipeline/tutorials:playground.mts",
metafile = False,
output = "playground.mjs",
platform = "node",
target = "es2022",
visibility = ["//visibility:public"],
deps = [
"//adev/shared-docs/pipeline/tutorials:playground",
],
)
esbuild_esm_bundle(
name = "tutorial-bundle",
entry_point = "//adev/shared-docs/pipeline/tutorials:tutorial.mts",
metafile = False,
output = "tutorial.mjs",
platform = "node",
target = "es2022",
visibility = ["//visibility:public"],
deps = [
"//adev/shared-docs/pipeline/tutorials",
],
)
esbuild_esm_bundle(
name = "navigation-bundle",
entry_point = "//adev/shared-docs/pipeline/navigation:index.mts",
metafile = False,
output = "navigation.mjs",
platform = "node",
target = "es2022",
visibility = ["//visibility:public"],
deps = [
"//adev/shared-docs/pipeline/navigation",
],
)
exports_files([
"_guides.bzl",
"_stackblitz.bzl",
@@ -107,38 +17,36 @@ exports_files([
"BUILD.bazel",
])
# END-DEV-ONLY
nodejs_binary(
js_binary(
name = "stackblitz",
data = [
"@npm//jsdom",
"//:node_modules/jsdom",
],
entry_point = "//adev/shared-docs/pipeline:stackblitz.mjs",
entry_point = "//adev/shared-docs/pipeline/examples/stackblitz:stackblitz.mjs",
visibility = ["//visibility:public"],
)
nodejs_binary(
js_binary(
name = "previews",
data = [
"@npm//typescript",
"//:node_modules/typescript",
],
entry_point = "//adev/shared-docs/pipeline:previews.mjs",
entry_point = "//adev/shared-docs/pipeline/examples/previews:previews.mjs",
visibility = ["//visibility:public"],
)
nodejs_binary(
js_binary(
name = "zip",
entry_point = "//adev/shared-docs/pipeline:zip.mjs",
entry_point = "//adev/shared-docs/pipeline/examples/zip:zip.mjs",
visibility = ["//visibility:public"],
)
nodejs_binary(
js_binary(
name = "markdown",
data = [
"@npm//jsdom",
"@npm//mermaid",
"@npm//playwright-core",
"//:node_modules/jsdom",
"//:node_modules/mermaid",
"//:node_modules/playwright-core",
"@rules_browsers//src/browsers/chromium",
],
entry_point = "//adev/shared-docs/pipeline/guides:guides.mjs",
@@ -149,29 +57,29 @@ nodejs_binary(
visibility = ["//visibility:public"],
)
nodejs_binary(
js_binary(
name = "markdown_no_mermaid",
data = [
"@npm//jsdom",
"//:node_modules/jsdom",
],
entry_point = "//adev/shared-docs/pipeline/guides:guides-no-mermaid.mjs",
visibility = ["//visibility:public"],
)
nodejs_binary(
js_binary(
name = "playground",
entry_point = "//adev/shared-docs/pipeline:playground.mjs",
entry_point = "//adev/shared-docs/pipeline/tutorials:playground.mjs",
visibility = ["//visibility:public"],
)
nodejs_binary(
js_binary(
name = "tutorial",
entry_point = "//adev/shared-docs/pipeline:tutorial.mjs",
entry_point = "//adev/shared-docs/pipeline/tutorials:tutorial.mjs",
visibility = ["//visibility:public"],
)
nodejs_binary(
js_binary(
name = "navigation",
entry_point = "//adev/shared-docs/pipeline:navigation.mjs",
entry_point = "//adev/shared-docs/pipeline/navigation:navigation.mjs",
visibility = ["//visibility:public"],
)
+10 -7
View File
@@ -1,4 +1,3 @@
load("@build_bazel_rules_nodejs//:providers.bzl", "run_node")
load("@devinfra//bazel/private:path_relative_to_label.bzl", "path_relative_to_label")
def _generate_guides(ctx):
@@ -33,20 +32,24 @@ def _generate_guides(ctx):
# Define an action that runs the nodejs_binary executable. This is the main thing that this
# rule does. If mermaid blocks are enabled then a different executable is used.
if (ctx.attr.mermaid_blocks):
run_node(
ctx = ctx,
ctx.actions.run(
inputs = depset(ctx.files.srcs + ctx.files.data),
executable = "_generate_guides",
executable = ctx.executable._generate_guides,
outputs = html_outputs,
arguments = [args],
env = {
"BAZEL_BINDIR": ".",
},
)
else:
run_node(
ctx = ctx,
ctx.actions.run(
inputs = depset(ctx.files.srcs + ctx.files.data),
executable = "_generate_guides_no_mermaid",
executable = ctx.executable._generate_guides_no_mermaid,
outputs = html_outputs,
arguments = [args],
env = {
"BAZEL_BINDIR": ".",
},
)
# The return value describes what the rule is producing. In this case we need to specify
+5 -5
View File
@@ -1,5 +1,3 @@
load("@build_bazel_rules_nodejs//:providers.bzl", "run_node")
def _generate_nav_items(ctx):
"""Implementation of the navigation items data generator rule"""
@@ -25,12 +23,14 @@ def _generate_nav_items(ctx):
# Add the path to the output file to the arguments.
args.add(json_output.path)
run_node(
ctx = ctx,
ctx.actions.run(
inputs = depset(ctx.files.srcs),
executable = "_generate_nav_items",
executable = ctx.executable._generate_nav_items,
outputs = [json_output],
arguments = [args],
env = {
"BAZEL_BINDIR": ".",
},
)
# The return value describes what the rule is producing. In this case we need to specify
+5 -5
View File
@@ -1,5 +1,3 @@
load("@build_bazel_rules_nodejs//:providers.bzl", "run_node")
def _generate_playground(ctx):
"""Implementation of the playground generator rule"""
@@ -29,12 +27,14 @@ def _generate_playground(ctx):
ctx.runfiles(files = ctx.files.common_srcs)
run_node(
ctx = ctx,
ctx.actions.run(
inputs = depset(ctx.files.playground_srcs + ctx.files.common_srcs),
executable = "_generate_playground",
executable = ctx.executable._generate_playground,
outputs = [playground_directory],
arguments = [args],
env = {
"BAZEL_BINDIR": ".",
},
)
# The return value describes what the rule is producing. In this case we need to specify
+5 -5
View File
@@ -1,5 +1,3 @@
load("@build_bazel_rules_nodejs//:providers.bzl", "run_node")
def _generate_previews_impl(ctx):
"""Implementation of the previews generator rule"""
@@ -20,12 +18,14 @@ def _generate_previews_impl(ctx):
ctx.runfiles(files = ctx.files._template_src)
run_node(
ctx = ctx,
ctx.actions.run(
inputs = depset(ctx.files.example_srcs + ctx.files._template_src),
executable = "_generate_previews",
executable = ctx.executable._generate_previews,
outputs = [ts_output],
arguments = [args],
env = {
"BAZEL_BINDIR": ".",
},
)
# The return value describes what the rule is producing. In this case we need to specify
+5 -4
View File
@@ -1,5 +1,3 @@
load("@build_bazel_rules_nodejs//:providers.bzl", "run_node")
def _generate_stackblitz(ctx):
"""Implementation of the stackblitz generator rule"""
@@ -35,12 +33,15 @@ def _generate_stackblitz(ctx):
ctx.runfiles(files = ctx.files.template_srcs)
run_node(
ctx.actions.run(
ctx = ctx,
inputs = depset(ctx.files.example_srcs + ctx.files.template_srcs),
executable = "_generate_stackblitz",
executable = ctx.executable._generate_stackblitz,
outputs = [html_output, tmp_directory],
arguments = [args],
env = {
"BAZEL_BINDIR": ".",
},
)
# The return value describes what the rule is producing. In this case we need to specify
+5 -5
View File
@@ -1,5 +1,3 @@
load("@build_bazel_rules_nodejs//:providers.bzl", "run_node")
def _generate_tutorial(ctx):
"""Implementation of the tutorial generator rule"""
@@ -29,12 +27,14 @@ def _generate_tutorial(ctx):
ctx.runfiles(files = ctx.files.common_srcs)
run_node(
ctx = ctx,
ctx.actions.run(
inputs = depset(ctx.files.tutorial_srcs + ctx.files.common_srcs),
executable = "_generate_tutorial",
executable = ctx.executable._generate_tutorial,
outputs = [tutorial_directory],
arguments = [args],
env = {
"BAZEL_BINDIR": ".",
},
)
# The return value describes what the rule is producing. In this case we need to specify
+5 -4
View File
@@ -1,5 +1,3 @@
load("@build_bazel_rules_nodejs//:providers.bzl", "run_node")
def _generate_zip(ctx):
"""Implementation of the zip generator rule"""
@@ -35,12 +33,15 @@ def _generate_zip(ctx):
ctx.runfiles(files = ctx.files.template_srcs)
run_node(
ctx.actions.run(
ctx = ctx,
inputs = depset(ctx.files.example_srcs + ctx.files.template_srcs),
executable = "_generate_zip",
executable = ctx.executable._generate_zip,
outputs = [zip_output, tmp_directory],
arguments = [args],
env = {
"BAZEL_BINDIR": ".",
},
)
# The return value describes what the rule is producing. In this case we need to specify
@@ -1,5 +1,3 @@
load("@build_bazel_rules_nodejs//:providers.bzl", "run_node")
def _generate_api_manifest(ctx):
"""Implementation of the generate_api_manifest rule"""
@@ -19,12 +17,14 @@ def _generate_api_manifest(ctx):
# Define an action that runs the nodejs_binary executable. This is
# the main thing that this rule does.
run_node(
ctx = ctx,
ctx.actions.run(
inputs = depset(ctx.files.srcs),
executable = "_generate_api_manifest",
executable = ctx.executable._generate_api_manifest,
outputs = [manifest],
arguments = [args],
env = {
"BAZEL_BINDIR": ".",
},
)
# The return value describes what the rule is producing. In this case we need to specify
@@ -1,4 +1,4 @@
load("@build_bazel_rules_nodejs//:index.bzl", "nodejs_binary")
load("@aspect_rules_js//js:defs.bzl", "js_binary")
load("@devinfra//bazel/esbuild:index.bzl", "esbuild_esm_bundle")
load("//adev/shared-docs:defaults.bzl", "ts_project")
@@ -54,7 +54,7 @@ ts_project(
)
# Action binary for the api_gen bazel rule.
nodejs_binary(
js_binary(
name = "render_api_to_html",
data = [
":render_api_to_html_lib",
@@ -63,8 +63,7 @@ nodejs_binary(
# Do not use the NodeJS linker because:
# - it's brittle and causes race conditions on Windows.
# - it requires additional work to setup the runtime linker.
templated_args = [
"--bazel_patch_module_resolver",
fixed_args = [
"--node_options=--preserve-symlinks-main",
],
visibility = ["//visibility:public"],
@@ -25,6 +25,9 @@ def _render_api_to_html(ctx):
executable = ctx.executable._render_api_to_html,
outputs = outputs,
arguments = [args],
env = {
"BAZEL_BINDIR": ".",
},
)
# The return value describes what the rule is producing. In this case we need to specify
@@ -1,7 +1,12 @@
load("@aspect_rules_esbuild//esbuild:defs.bzl", "esbuild")
load("//adev/shared-docs:defaults.bzl", "ts_project")
package(default_visibility = ["//visibility:public"])
exports_files([
"previews.template",
])
ts_project(
name = "index",
srcs = [
@@ -24,7 +29,23 @@ filegroup(
visibility = ["//visibility:public"],
)
exports_files([
"index.mts",
"previews.template",
])
esbuild(
name = "bundle",
srcs = [
"//adev/shared-docs:tsconfig_build",
],
config = "//adev/shared-docs/pipeline:esbuild-config",
entry_point = ":index.mts",
external = [
"typescript",
"path",
],
format = "esm",
output = "previews.mjs",
platform = "node",
target = "es2022",
visibility = ["//visibility:public"],
deps = [
"//adev/shared-docs/pipeline/examples/previews:index_rjs",
],
)
@@ -1,3 +1,4 @@
load("@aspect_rules_esbuild//esbuild:defs.bzl", "esbuild")
load("//adev/shared-docs:defaults.bzl", "ts_project")
package(default_visibility = ["//visibility:public"])
@@ -38,6 +39,21 @@ ts_project(
],
)
exports_files([
"index.mts",
])
esbuild(
name = "bundle",
srcs = [
"//adev/shared-docs:tsconfig_build",
],
config = "//adev/shared-docs/pipeline:esbuild-config",
entry_point = ":index.mts",
# JSDOM should not be bundled because it has workers and dynamic imports.
external = ["jsdom"],
format = "esm",
output = "stackblitz.mjs",
platform = "node",
target = "es2022",
visibility = ["//visibility:public"],
deps = [
":index_rjs",
],
)
@@ -1,3 +1,4 @@
load("@aspect_rules_esbuild//esbuild:defs.bzl", "esbuild")
load("//adev/shared-docs:defaults.bzl", "ts_project")
package(default_visibility = ["//visibility:public"])
@@ -38,6 +39,19 @@ ts_project(
],
)
exports_files([
"index.mts",
])
esbuild(
name = "bundle",
srcs = [
"//adev/shared-docs:tsconfig_build",
],
config = "//adev/shared-docs/pipeline:esbuild-config",
entry_point = ":index.mts",
format = "esm",
output = "zip.mjs",
platform = "node",
target = "es2022",
visibility = ["//visibility:public"],
deps = [
":index_rjs",
],
)
@@ -1,3 +1,4 @@
load("@aspect_rules_esbuild//esbuild:defs.bzl", "esbuild")
load("//adev/shared-docs:defaults.bzl", "ts_project")
package(default_visibility = ["//visibility:public"])
@@ -34,3 +35,20 @@ ts_project(
"//adev/shared-docs/interfaces",
],
)
esbuild(
name = "bundle",
srcs = [
"//adev/shared-docs:tsconfig_build",
],
config = "//adev/shared-docs/pipeline:esbuild-config",
entry_point = ":index.mts",
format = "esm",
output = "navigation.mjs",
platform = "node",
target = "es2022",
visibility = ["//visibility:public"],
deps = [
":navigation_rjs",
],
)
@@ -1,3 +1,4 @@
load("@aspect_rules_esbuild//esbuild:defs.bzl", "esbuild")
load("//adev/shared-docs:defaults.bzl", "ts_project")
package(default_visibility = ["//visibility:public"])
@@ -9,8 +10,8 @@ ts_project(
"*.mts",
],
exclude = [
"playground.mts",
"tutorial.mts",
"playground_index.mts",
"tutorial_index.mts",
],
),
enable_runtime_rnjs_interop = True,
@@ -25,7 +26,7 @@ ts_project(
ts_project(
name = "playground",
srcs = [
"playground.mts",
"playground_index.mts",
],
enable_runtime_rnjs_interop = True,
visibility = [
@@ -39,9 +40,9 @@ ts_project(
)
ts_project(
name = "tutorials",
name = "tutorial",
srcs = [
"tutorial.mts",
"tutorial_index.mts",
],
visibility = [
"//adev/shared-docs:__subpackages__",
@@ -52,3 +53,37 @@ ts_project(
"//adev/shared-docs/interfaces:interfaces_rjs",
],
)
esbuild(
name = "playground_bundle",
srcs = [
"//adev/shared-docs:tsconfig_build",
],
config = "//adev/shared-docs/pipeline:esbuild-config",
entry_point = ":playground_index.mts",
format = "esm",
output = "playground.mjs",
platform = "node",
target = "es2022",
visibility = ["//visibility:public"],
deps = [
":playground_rjs",
],
)
esbuild(
name = "tutorial_bundle",
srcs = [
"//adev/shared-docs:tsconfig_build",
],
config = "//adev/shared-docs/pipeline:esbuild-config",
entry_point = ":tutorial_index.mts",
format = "esm",
output = "tutorial.mjs",
platform = "node",
target = "es2022",
visibility = ["//visibility:public"],
deps = [
":tutorial_rjs",
],
)
+1 -1
View File
@@ -1,4 +1,4 @@
load("@build_bazel_rules_nodejs//:index.bzl", "copy_to_bin")
load("@aspect_bazel_lib//lib:copy_to_bin.bzl", "copy_to_bin")
exports_files(
glob(["*"]),
+1 -1
View File
@@ -1,4 +1,4 @@
load("@build_bazel_rules_nodejs//:index.bzl", "copy_to_bin")
load("@aspect_bazel_lib//lib:copy_to_bin.bzl", "copy_to_bin")
exports_files(
glob(["*"]),
+1 -1
View File
@@ -1,4 +1,4 @@
load("@build_bazel_rules_nodejs//:index.bzl", "copy_to_bin")
load("@aspect_bazel_lib//lib:copy_to_bin.bzl", "copy_to_bin")
exports_files(
glob(["*"]),
+1 -1
View File
@@ -1,4 +1,4 @@
load("@build_bazel_rules_nodejs//:index.bzl", "js_library")
load("@aspect_rules_js//js:defs.bzl", "js_library")
package(default_visibility = [
"//adev:__subpackages__",