Skip to content

Migrate to use rules_js based ng_package #30915

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 8 commits into from
Apr 21, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 0 additions & 2 deletions .bazelignore
Original file line number Diff line number Diff line change
Expand Up @@ -31,5 +31,3 @@ src/material-moment-adapter/node_modules
src/material/node_modules
src/universal-app/node_modules
src/youtube-player/node_modules

tools/bazel/legacy-rnjs/node_modules
2 changes: 1 addition & 1 deletion BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ load("//src/cdk:config.bzl", "CDK_ENTRYPOINTS")
load("//src/cdk-experimental:config.bzl", "CDK_EXPERIMENTAL_ENTRYPOINTS")
load("//src/material:config.bzl", "MATERIAL_ENTRYPOINTS", "MATERIAL_TESTING_ENTRYPOINTS")
load("//src/material-experimental:config.bzl", "MATERIAL_EXPERIMENTAL_ENTRYPOINTS", "MATERIAL_EXPERIMENTAL_TESTING_ENTRYPOINTS")
load("@npm2//:defs.bzl", "npm_link_all_packages")
load("@npm//:defs.bzl", "npm_link_all_packages")

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

Expand Down
34 changes: 4 additions & 30 deletions WORKSPACE
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,7 @@ http_archive(
urls = ["https://github.com/bazelbuild/rules_nodejs/releases/download/5.8.4/rules_nodejs-5.8.4.tar.gz"],
)

# Add skylib which contains common Bazel utilities. Note that `rules_nodejs` would also
# bring in the skylib repository but with an older version that does not support shorthands
# for declaring Bazel build setting flags.
# Add skylib which contains common Bazel utilities.
http_archive(
name = "bazel_skylib",
sha256 = "a9c5d3a22461ed7063aa7b088f9c96fa0aaaa8b6984b601f84d705adc47d8a58",
Expand Down Expand Up @@ -56,8 +54,6 @@ load("@aspect_rules_js//js:repositories.bzl", "rules_js_dependencies")

rules_js_dependencies()

load("@rules_nodejs//nodejs:repositories.bzl", "nodejs_register_toolchains")

NODE_VERSION = "22.11.0"

NODE_REPOSITORIES = {
Expand All @@ -70,39 +66,17 @@ NODE_REPOSITORIES = {
"22.11.0-windows_amd64": ("node-v22.11.0-win-x64.zip", "node-v22.11.0-win-x64", "905373a059aecaf7f48c1ce10ffbd5334457ca00f678747f19db5ea7d256c236"),
}

nodejs_register_toolchains(
name = "nodejs",
node_repositories = NODE_REPOSITORIES,
node_version = NODE_VERSION,
)

load("@aspect_rules_js//js:toolchains.bzl", "rules_js_register_toolchains")

rules_js_register_toolchains(
node_repositories = NODE_REPOSITORIES,
node_version = NODE_VERSION,
)

load("@build_bazel_rules_nodejs//:index.bzl", "yarn_install")

# TODO(devversion): Remove this once `ng_package` is ported over to `rules_js`.
yarn_install(
name = "npm",
data = [
"//tools/bazel/legacy-rnjs:.yarn/patches/@angular-bazel-https-c46f484fb8.patch",
"//tools/bazel/legacy-rnjs:.yarn/releases/yarn-4.5.0.cjs",
"//tools/bazel/legacy-rnjs:.yarnrc.yml",
],
exports_directories_only = False,
package_json = "//tools/bazel/legacy-rnjs:package.json",
yarn = "//tools/bazel/legacy-rnjs:.yarn/releases/yarn-4.5.0.cjs",
yarn_lock = "//tools/bazel/legacy-rnjs:yarn.lock",
)

load("@aspect_rules_js//npm:repositories.bzl", "npm_translate_lock")

npm_translate_lock(
name = "npm2",
name = "npm",
custom_postinstalls = {
"@angular/animations": "node ../../@nginfra/angular-linking/index.mjs",
"@angular/common": "node ../../@nginfra/angular-linking/index.mjs",
Expand Down Expand Up @@ -175,7 +149,7 @@ npm_translate_lock(
verify_node_modules_ignored = "//:.bazelignore",
)

load("@npm2//:repositories.bzl", "npm_repositories")
load("@npm//:repositories.bzl", "npm_repositories")

npm_repositories()

Expand Down Expand Up @@ -230,7 +204,7 @@ setup_dependencies_2()

git_repository(
name = "rules_angular",
commit = "514eda9ec00a6745dc11b2a62d7be2634199171e",
commit = "005c80615934c891d729d5efc1ae661f9e3210c4",
remote = "https://github.com/devversion/rules_angular.git",
)

Expand Down
2 changes: 1 addition & 1 deletion docs/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
load("@aspect_bazel_lib//lib:copy_to_bin.bzl", "copy_to_bin")
load("@aspect_rules_js//js:defs.bzl", "js_binary", "js_library", "js_test")
load("@npm2//:defs.bzl", "npm_link_all_packages")
load("@npm//:defs.bzl", "npm_link_all_packages")
load("//docs:defs.bzl", "ng_app")

package(default_visibility = ["//visibility:public"])
Expand Down
2 changes: 1 addition & 1 deletion docs/defs.bzl
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
load("@npm2//:@angular-devkit/architect-cli/package_json.bzl", architect_cli = "bin")
load("@npm//:@angular-devkit/architect-cli/package_json.bzl", architect_cli = "bin")
load("@aspect_bazel_lib//lib:copy_to_bin.bzl", "copy_to_bin")

# NOTE:
Expand Down
2 changes: 1 addition & 1 deletion integration/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
load("@npm2//:defs.bzl", "npm_link_all_packages")
load("@npm//:defs.bzl", "npm_link_all_packages")

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

Expand Down
3 changes: 3 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,7 @@
"karma-jasmine": "^4.0.1",
"karma-parallel": "^0.3.1",
"karma-sourcemap-loader": "^0.3.8",
"magic-string": "0.30.17",
"marked": "^2.0.0",
"minimatch": "^3.0.4",
"node-fetch": "^2.6.0",
Expand All @@ -135,6 +136,8 @@
"reflect-metadata": "^0.1.13",
"requirejs": "^2.3.6",
"rollup": "^2.66.1",
"rollup-plugin-dts": "6.2.1",
"rollup-plugin-sourcemaps2": "0.5.0",
"sass": "^1.80.6",
"selenium-webdriver": "^3.6.0",
"semver": "^7.3.5",
Expand Down
4 changes: 2 additions & 2 deletions packages.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,9 @@ PKG_GROUP_REPLACEMENTS = {
# the peer dependencies and versions, primarily in `package.json`s.
NPM_PACKAGE_SUBSTITUTIONS = dict(PKG_GROUP_REPLACEMENTS, **{
# Peer dependency version on the Angular framework.
"0.0.0-NG": "{STABLE_FRAMEWORK_PEER_DEP_RANGE}",
"0.0.0-NG": "{{STABLE_FRAMEWORK_PEER_DEP_RANGE}}",
# Version of the local package being built, generated via the `--workspace_status_command` flag.
"0.0.0-PLACEHOLDER": "{STABLE_PROJECT_VERSION}",
"0.0.0-PLACEHOLDER": "{{STABLE_PROJECT_VERSION}}",
})

NO_STAMP_NPM_PACKAGE_SUBSTITUTIONS = dict(NPM_PACKAGE_SUBSTITUTIONS, **{
Expand Down
58 changes: 58 additions & 0 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 2 additions & 3 deletions src/cdk-experimental/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
load("//src/cdk-experimental:config.bzl", "CDK_EXPERIMENTAL_TARGETS")
load("//tools:defaults.bzl", "ng_package")
load("//tools:defaults2.bzl", "ts_project")
load("//tools/bazel:legacy_target.bzl", "get_legacy_label")
load("@npm2//:defs.bzl", "npm_link_all_packages")
load("@npm//:defs.bzl", "npm_link_all_packages")

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

Expand All @@ -29,5 +28,5 @@ ng_package(
"//integration:__subpackages__",
"//src/material-experimental:__subpackages__",
],
deps = [get_legacy_label(t) for t in CDK_EXPERIMENTAL_TARGETS],
deps = CDK_EXPERIMENTAL_TARGETS,
)
2 changes: 1 addition & 1 deletion src/cdk-experimental/scrolling/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,6 @@ ts_project(
e2e_test_suite(
name = "e2e_tests",
deps = [
":e2e_test_sources_legacy",
":e2e_test_sources",
],
)
5 changes: 2 additions & 3 deletions src/cdk/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
load("//src/cdk:config.bzl", "CDK_ENTRYPOINTS", "CDK_ENTRYPOINTS_WITH_STYLES", "CDK_SCSS_LIBS", "CDK_TARGETS")
load("//tools:defaults.bzl", "ng_package", "sass_library")
load("//tools:defaults2.bzl", "ts_project")
load("//tools/bazel:legacy_target.bzl", "get_legacy_label")
load("@npm2//:defs.bzl", "npm_link_all_packages")
load("@npm//:defs.bzl", "npm_link_all_packages")

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

Expand Down Expand Up @@ -68,7 +67,7 @@ ng_package(
"//goldens:__pkg__",
"//integration:__subpackages__",
],
deps = [get_legacy_label(t) for t in CDK_TARGETS],
deps = CDK_TARGETS,
)

filegroup(
Expand Down
2 changes: 1 addition & 1 deletion src/cdk/overlay/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ ts_project(
e2e_test_suite(
name = "e2e_tests",
deps = [
":e2e_test_sources_legacy",
":e2e_test_sources",
],
)

Expand Down
2 changes: 1 addition & 1 deletion src/cdk/schematics/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -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")
load("//tools:defaults2.bzl", "jasmine_test", "npm_package", "ts_project")
load("@aspect_rules_ts//ts:defs.bzl", rules_js_tsconfig = "ts_config")

Expand Down
2 changes: 1 addition & 1 deletion src/cdk/testing/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ ng_web_test_suite(
e2e_test_suite(
name = "protractor_e2e_tests",
deps = [
"//src/cdk/testing/tests:e2e_test_sources_legacy",
"//src/cdk/testing/tests:e2e_test_sources",
],
)

Expand Down
5 changes: 2 additions & 3 deletions src/components-examples/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,7 @@ load("//tools/highlight-files:index.bzl", "highlight_files")
load("//tools/package-docs-content:index.bzl", "package_docs_content")
load(":config.bzl", "ALL_EXAMPLES")
load("//tools:defaults2.bzl", "ng_project")
load("//tools/bazel:legacy_target.bzl", "get_legacy_label")
load("@npm2//:defs.bzl", "npm_link_all_packages")
load("@npm//:defs.bzl", "npm_link_all_packages")

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

Expand Down Expand Up @@ -73,7 +72,7 @@ ng_package(
],
tags = ["docs-package"],
visibility = ["//:__pkg__"],
deps = [":components-examples_legacy"] + [get_legacy_label(t) for t in ALL_EXAMPLES],
deps = [":components-examples"] + ALL_EXAMPLES,
)

genrule(
Expand Down
2 changes: 1 addition & 1 deletion src/dev-app/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
load("//tools:defaults.bzl", "sass_binary")
load("//tools:defaults2.bzl", "http_server", "ng_project")
load("@npm2//:defs.bzl", "npm_link_all_packages")
load("@npm//:defs.bzl", "npm_link_all_packages")
load("@aspect_rules_esbuild//esbuild:defs.bzl", "esbuild")
load("@aspect_rules_js//npm:defs.bzl", "npm_package")
load("//src/components-examples:config.bzl", "ALL_EXAMPLES")
Expand Down
2 changes: 1 addition & 1 deletion src/e2e-app/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
load("@aspect_rules_esbuild//esbuild:defs.bzl", "esbuild")
load("@npm2//:defs.bzl", "npm_link_all_packages")
load("@npm//:defs.bzl", "npm_link_all_packages")
load("//tools:defaults.bzl", "sass_binary")
load("//tools:defaults2.bzl", "http_server", "ng_project")

Expand Down
2 changes: 1 addition & 1 deletion src/google-maps/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ ng_package(
"//goldens:__pkg__",
"//integration:__subpackages__",
],
deps = [":google-maps_legacy"],
deps = [":google-maps"],
)

filegroup(
Expand Down
2 changes: 1 addition & 1 deletion src/google-maps/schematics/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -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")
load("//tools:defaults2.bzl", "npm_package", "ts_project")
load("@aspect_rules_ts//ts:defs.bzl", rules_js_tsconfig = "ts_config")

Expand Down
2 changes: 1 addition & 1 deletion src/material-date-fns-adapter/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -50,5 +50,5 @@ ng_package(
"//goldens:__pkg__",
"//integration:__subpackages__",
],
deps = [":material-date-fns-adapter_legacy"],
deps = [":material-date-fns-adapter"],
)
2 changes: 1 addition & 1 deletion src/material-date-fns-adapter/schematics/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -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")
load("//tools:defaults2.bzl", "npm_package", "ts_project")

package(default_visibility = ["//visibility:public"])
Expand Down
5 changes: 2 additions & 3 deletions src/material-experimental/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,7 @@ load(
)
load("//tools:defaults.bzl", "ng_package", "sass_library")
load("//tools:defaults2.bzl", "ts_project")
load("//tools/bazel:legacy_target.bzl", "get_legacy_label")
load("@npm2//:defs.bzl", "npm_link_all_packages")
load("@npm//:defs.bzl", "npm_link_all_packages")

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

Expand Down Expand Up @@ -53,5 +52,5 @@ ng_package(
"//goldens:__pkg__",
"//integration:__subpackages__",
],
deps = [get_legacy_label(t) for t in MATERIAL_EXPERIMENTAL_TARGETS + MATERIAL_EXPERIMENTAL_TESTING_TARGETS],
deps = MATERIAL_EXPERIMENTAL_TARGETS + MATERIAL_EXPERIMENTAL_TESTING_TARGETS,
)
2 changes: 1 addition & 1 deletion src/material-luxon-adapter/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -52,5 +52,5 @@ ng_package(
"//goldens:__pkg__",
"//integration:__subpackages__",
],
deps = [":material-luxon-adapter_legacy"],
deps = [":material-luxon-adapter"],
)
Loading
Loading