Skip to content

Commit ff44405

Browse files
committed
refactor: migrate to use new rules_js based ng_package
1 parent 75bc1fd commit ff44405

File tree

12 files changed

+22
-31
lines changed

12 files changed

+22
-31
lines changed

packages.bzl

+2-2
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,9 @@ PKG_GROUP_REPLACEMENTS = {
2020
# the peer dependencies and versions, primarily in `package.json`s.
2121
NPM_PACKAGE_SUBSTITUTIONS = dict(PKG_GROUP_REPLACEMENTS, **{
2222
# Peer dependency version on the Angular framework.
23-
"0.0.0-NG": "{STABLE_FRAMEWORK_PEER_DEP_RANGE}",
23+
"0.0.0-NG": "{{STABLE_FRAMEWORK_PEER_DEP_RANGE}}",
2424
# Version of the local package being built, generated via the `--workspace_status_command` flag.
25-
"0.0.0-PLACEHOLDER": "{STABLE_PROJECT_VERSION}",
25+
"0.0.0-PLACEHOLDER": "{{STABLE_PROJECT_VERSION}}",
2626
})
2727

2828
NO_STAMP_NPM_PACKAGE_SUBSTITUTIONS = dict(NPM_PACKAGE_SUBSTITUTIONS, **{

src/cdk-experimental/BUILD.bazel

+1-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
load("//src/cdk-experimental:config.bzl", "CDK_EXPERIMENTAL_TARGETS")
22
load("//tools:defaults.bzl", "ng_package")
33
load("//tools:defaults2.bzl", "ts_project")
4-
load("//tools/bazel:legacy_target.bzl", "get_legacy_label")
54
load("@npm2//:defs.bzl", "npm_link_all_packages")
65

76
package(default_visibility = ["//visibility:public"])
@@ -29,5 +28,5 @@ ng_package(
2928
"//integration:__subpackages__",
3029
"//src/material-experimental:__subpackages__",
3130
],
32-
deps = [get_legacy_label(t) for t in CDK_EXPERIMENTAL_TARGETS],
31+
deps = CDK_EXPERIMENTAL_TARGETS,
3332
)

src/cdk/BUILD.bazel

+1-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
load("//src/cdk:config.bzl", "CDK_ENTRYPOINTS", "CDK_ENTRYPOINTS_WITH_STYLES", "CDK_SCSS_LIBS", "CDK_TARGETS")
22
load("//tools:defaults.bzl", "ng_package", "sass_library")
33
load("//tools:defaults2.bzl", "ts_project")
4-
load("//tools/bazel:legacy_target.bzl", "get_legacy_label")
54
load("@npm2//:defs.bzl", "npm_link_all_packages")
65

76
package(default_visibility = ["//visibility:public"])
@@ -68,7 +67,7 @@ ng_package(
6867
"//goldens:__pkg__",
6968
"//integration:__subpackages__",
7069
],
71-
deps = [get_legacy_label(t) for t in CDK_TARGETS],
70+
deps = CDK_TARGETS,
7271
)
7372

7473
filegroup(

src/components-examples/BUILD.bazel

+1-2
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ load("//tools/highlight-files:index.bzl", "highlight_files")
33
load("//tools/package-docs-content:index.bzl", "package_docs_content")
44
load(":config.bzl", "ALL_EXAMPLES")
55
load("//tools:defaults2.bzl", "ng_project")
6-
load("//tools/bazel:legacy_target.bzl", "get_legacy_label")
76
load("@npm2//:defs.bzl", "npm_link_all_packages")
87

98
package(default_visibility = ["//visibility:public"])
@@ -73,7 +72,7 @@ ng_package(
7372
],
7473
tags = ["docs-package"],
7574
visibility = ["//:__pkg__"],
76-
deps = [":components-examples_legacy"] + [get_legacy_label(t) for t in ALL_EXAMPLES],
75+
deps = [":components-examples"] + ALL_EXAMPLES,
7776
)
7877

7978
genrule(

src/google-maps/BUILD.bazel

+1-1
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ ng_package(
4444
"//goldens:__pkg__",
4545
"//integration:__subpackages__",
4646
],
47-
deps = [":google-maps_legacy"],
47+
deps = [":google-maps"],
4848
)
4949

5050
filegroup(

src/material-date-fns-adapter/BUILD.bazel

+1-1
Original file line numberDiff line numberDiff line change
@@ -50,5 +50,5 @@ ng_package(
5050
"//goldens:__pkg__",
5151
"//integration:__subpackages__",
5252
],
53-
deps = [":material-date-fns-adapter_legacy"],
53+
deps = [":material-date-fns-adapter"],
5454
)

src/material-experimental/BUILD.bazel

+1-2
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ load(
66
)
77
load("//tools:defaults.bzl", "ng_package", "sass_library")
88
load("//tools:defaults2.bzl", "ts_project")
9-
load("//tools/bazel:legacy_target.bzl", "get_legacy_label")
109
load("@npm2//:defs.bzl", "npm_link_all_packages")
1110

1211
package(default_visibility = ["//visibility:public"])
@@ -53,5 +52,5 @@ ng_package(
5352
"//goldens:__pkg__",
5453
"//integration:__subpackages__",
5554
],
56-
deps = [get_legacy_label(t) for t in MATERIAL_EXPERIMENTAL_TARGETS + MATERIAL_EXPERIMENTAL_TESTING_TARGETS],
55+
deps = MATERIAL_EXPERIMENTAL_TARGETS + MATERIAL_EXPERIMENTAL_TESTING_TARGETS,
5756
)

src/material-luxon-adapter/BUILD.bazel

+1-1
Original file line numberDiff line numberDiff line change
@@ -52,5 +52,5 @@ ng_package(
5252
"//goldens:__pkg__",
5353
"//integration:__subpackages__",
5454
],
55-
deps = [":material-luxon-adapter_legacy"],
55+
deps = [":material-luxon-adapter"],
5656
)

src/material-moment-adapter/BUILD.bazel

+1-1
Original file line numberDiff line numberDiff line change
@@ -57,5 +57,5 @@ ng_package(
5757
"//goldens:__pkg__",
5858
"//integration:__subpackages__",
5959
],
60-
deps = [":material-moment-adapter_legacy"],
60+
deps = [":material-moment-adapter"],
6161
)

src/material/BUILD.bazel

+1-2
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ load(
77
)
88
load("//tools:defaults.bzl", "ng_package", "sass_library")
99
load("//tools:defaults2.bzl", "ts_project")
10-
load("//tools/bazel:legacy_target.bzl", "get_legacy_label")
1110

1211
package(default_visibility = ["//visibility:public"])
1312

@@ -193,5 +192,5 @@ ng_package(
193192
"//goldens:__pkg__",
194193
"//integration:__subpackages__",
195194
],
196-
deps = [get_legacy_label(t) for t in MATERIAL_TARGETS + MATERIAL_TESTING_TARGETS],
195+
deps = MATERIAL_TARGETS + MATERIAL_TESTING_TARGETS,
197196
)

src/youtube-player/BUILD.bazel

+1-1
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ ng_package(
6464
"//goldens:__pkg__",
6565
"//integration:__subpackages__",
6666
],
67-
deps = [":youtube-player_legacy"],
67+
deps = [":youtube-player"],
6868
)
6969

7070
ts_project(

tools/defaults.bzl

+10-14
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
load("@rules_pkg//:pkg.bzl", "pkg_tar")
44
load("@rules_sass//src:index.bzl", _sass_binary = "sass_binary", _sass_library = "sass_library")
5-
load("@npm//@angular/bazel:index.bzl", _ng_package = "ng_package")
5+
load("@rules_angular//src/ng_package:index.bzl", _ng_package = "ng_package")
66
load("//:packages.bzl", "NO_STAMP_NPM_PACKAGE_SUBSTITUTIONS", "NPM_PACKAGE_SUBSTITUTIONS")
77
load("//:pkg-externals.bzl", "PKG_EXTERNALS")
88
load("//tools/markdown-to-html:index.bzl", _markdown_to_html = "markdown_to_html")
@@ -64,21 +64,17 @@ def ng_package(
6464
externals = externals,
6565
srcs = srcs + [":license_copied"],
6666
deps = deps,
67-
# We never set a `package_name` for NPM packages, neither do we enable validation.
68-
# This is necessary because the source targets of the NPM packages all have
69-
# package names set and setting a similar `package_name` on the NPM package would
70-
# result in duplicate linker mappings that will conflict. e.g. consider the following
71-
# scenario: We have a `ts_library` for `@angular/cdk`. We will configure a package
72-
# name for the target so that it can be resolved in NodeJS executions from `node_modules`.
73-
# If we'd also set a `package_name` for the associated `pkg_npm` target, there would be
74-
# two mappings for `@angular/cdk` and the linker will complain. For a better development
75-
# experience, we want the mapping to resolve to the direct outputs of the `ts_library`
76-
# instead of requiring tests and other targets to assemble the NPM package first.
77-
package_name = None,
78-
validate = False,
67+
package = package_name,
7968
readme_md = readme_md,
8069
substitutions = npmPackageSubstitutions,
8170
visibility = visibility,
71+
rollup_runtime_deps = [
72+
"//:node_modules/@rollup/plugin-commonjs",
73+
"//:node_modules/@rollup/plugin-node-resolve",
74+
"//:node_modules/magic-string",
75+
"//:node_modules/rollup-plugin-dts",
76+
"//:node_modules/rollup-plugin-sourcemaps2",
77+
],
8278
**kwargs
8379
)
8480

@@ -97,6 +93,6 @@ def ng_package(
9793
name = "pkg",
9894
src = ":%s" % name,
9995
visibility = visibility,
100-
interop_deps = [d.replace("_legacy", "") for d in deps] + package_deps,
96+
interop_deps = deps + package_deps,
10197
package_name = package_name,
10298
)

0 commit comments

Comments
 (0)