Skip to content

Commit 90ec904

Browse files
devversionwagnermaciel
authored andcommitted
build: fix firebase deployment of dev-app (#22961)
The `@angular/localize` package does not contain any `.metadata.json` files, or an `ANGULAR_PACKAGE` marker file. This results in the NodeJS bazel rules not capturing the UMD files within the `NamedModule` provider. We fix this by using the standard module provider for extracting JS sources from TS targets and its transitive dependencies. This is more long-term proof as the hard-coded Angular package logic within Rules NodeJS is most likely not a long-term solution. see: https://github.com/bazelbuild/rules_nodejs/blob/stable/internal/npm_install/generate_build_file.ts#L1080-L1081 Fixes #22943. (cherry picked from commit 9428939)
1 parent 0012409 commit 90ec904

File tree

2 files changed

+12
-12
lines changed

2 files changed

+12
-12
lines changed

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")
22
load("//tools:create-system-config.bzl", "create_system_config")
33
load("//tools:defaults.bzl", "ng_module", "sass_binary")
4-
load("//tools:es5-named-output.bzl", "es5_named_output")
4+
load("//tools:es5-module-output.bzl", "es5_module_output")
55
load("//tools/dev-server:index.bzl", "dev_server")
66

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

200200
# Collects all ES5 JavaScript files which are required to serve the dev-app. By default,
201201
# ts_library and ng_module targets only expose the type definition files as outputs.
202-
es5_named_output(
202+
es5_module_output(
203203
name = "dev_app_js_sources",
204204
tags = ["manual"],
205205
deps = [":dev-app"],

tools/es5-named-output.bzl renamed to tools/es5-module-output.bzl

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,30 @@
1-
load("@build_bazel_rules_nodejs//:providers.bzl", "JSNamedModuleInfo")
1+
load("@build_bazel_rules_nodejs//:providers.bzl", "JSModuleInfo")
22

3-
"""Implementation of the es5_named_output rule.
3+
"""Implementation of the es5_module_output rule.
44
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
5+
JSModuleInfo provider.
6+
https://github.com/bazelbuild/rules_nodejs/blob/stable/packages/typescript/internal/build_defs.bzl#L334-L337
77
"""
88

9-
def _es5_named_output_impl(ctx):
9+
def _es5_module_output_impl(ctx):
1010
depsets = []
1111
for dep in ctx.attr.deps:
12-
if JSNamedModuleInfo in dep:
13-
depsets.append(dep[JSNamedModuleInfo].sources)
12+
if JSModuleInfo in dep:
13+
depsets.append(dep[JSModuleInfo].sources)
1414
if hasattr(dep, "files"):
1515
depsets.append(dep.files)
1616
sources = depset(transitive = depsets)
1717

1818
return [DefaultInfo(files = sources)]
1919

20-
"""Rule that collects all ES5 named outputs from a list of deps.
20+
"""Rule that collects all ES5 module outputs from a list of deps.
2121
It can be used as input for all those rules that require named JavaScript sources (such as
2222
pkg_web).
2323
We need this because ts_library and ng_module targets output only expose the type definition files
2424
as outputs.
2525
"""
26-
es5_named_output = rule(
27-
implementation = _es5_named_output_impl,
26+
es5_module_output = rule(
27+
implementation = _es5_module_output_impl,
2828
attrs = {
2929
"deps": attr.label_list(
3030
allow_files = True,

0 commit comments

Comments
 (0)