Skip to content
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

Initial PR for migrating to rules_js #30629

Merged
merged 8 commits into from
Mar 18, 2025
Merged
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
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# @generated
# Input hashes for repository rule npm_translate_lock(name = "npm2", pnpm_lock = "@//:pnpm-lock.yaml").
# This file should be checked into version control along with the pnpm-lock.yaml file.
.npmrc=-2023857461
package.json=1204886269
pnpm-lock.yaml=1975546108
pnpm-workspace.yaml=1711114604
yarn.lock=824621907
12 changes: 7 additions & 5 deletions .bazelrc
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
# Required by `rules_ts`.
common --@aspect_rules_ts//ts:skipLibCheck=always
common --@aspect_rules_ts//ts:default_to_tsc_transpiler

###############################
# Filesystem interactions #
###############################
@@ -87,11 +91,9 @@ build:remote --google_default_credentials=true

# Setup the toolchain and platform for the remote build execution. The platform
# is provided by the shared dev-infra package and targets k8 remote containers.
build:remote --crosstool_top=@npm//@angular/build-tooling/bazel/remote-execution/cpp:cc_toolchain_suite
build:remote --extra_toolchains=@npm//@angular/build-tooling/bazel/remote-execution/cpp:cc_toolchain
build:remote --extra_execution_platforms=@npm//@angular/build-tooling/bazel/remote-execution:platform_with_network
build:remote --host_platform=@npm//@angular/build-tooling/bazel/remote-execution:platform_with_network
build:remote --platforms=@npm//@angular/build-tooling/bazel/remote-execution:platform_with_network
build:remote --extra_execution_platforms=@devinfra//bazel/remote-execution:platform_with_network
build:remote --host_platform=@devinfra//bazel/remote-execution:platform_with_network
build:remote --platforms=@devinfra//bazel/remote-execution:platform_with_network

################################
# Sandbox settings #
2 changes: 1 addition & 1 deletion .bazelversion
Original file line number Diff line number Diff line change
@@ -1 +1 @@
5.0.0
6.5.0
1 change: 0 additions & 1 deletion .github/CODEOWNERS
Original file line number Diff line number Diff line change
@@ -13,4 +13,3 @@
/.github/ISSUE_TEMPLATE/** @angular/components-googlers

/tools/ @angular/dev-infra-components
/tools/public_api_guard/**/*.md @angular/components-googlers
4 changes: 3 additions & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -64,7 +64,7 @@ jobs:
- name: Install node modules
run: yarn install --frozen-lockfile
- name: Check API Goldens
run: yarn bazel test tools/public_api_guard/...
run: yarn bazel test goldens/...
- uses: ./.github/actions/slack
if: failure()
with:
@@ -173,6 +173,8 @@ jobs:
run: yarn install --frozen-lockfile
- name: Run tests
run: bazel test --build_tag_filters=-e2e --test_tag_filters=-e2e --build_tests_only -- src/...
env:
ASPECT_RULES_JS_FROZEN_PNPM_LOCK: '1'
- uses: ./.github/actions/slack
if: failure()
with:
4 changes: 3 additions & 1 deletion .github/workflows/pr.yml
Original file line number Diff line number Diff line change
@@ -65,7 +65,7 @@ jobs:
- name: Install node modules
run: yarn install --frozen-lockfile
- name: Check API Goldens
run: yarn bazel test tools/public_api_guard/...
run: yarn bazel test goldens/...

e2e:
runs-on: ubuntu-latest
@@ -149,6 +149,8 @@ jobs:
run: yarn install --frozen-lockfile
- name: Run tests
run: bazel test --build_tag_filters=-e2e --test_tag_filters=-e2e --build_tests_only -- src/...
env:
ASPECT_RULES_JS_FROZEN_PNPM_LOCK: '1'

build:
runs-on: ubuntu-latest-16core
1 change: 1 addition & 0 deletions .ng-dev/release.mts
Original file line number Diff line number Diff line change
@@ -23,6 +23,7 @@ export const releasePackages = [

/** Configuration for the `ng-dev release` command. */
export const release: ReleaseConfig = {
rulesJsInteropMode: true,
releaseNotes: {
useReleaseTitle: true,
groupOrder: releasePackages,
8 changes: 7 additions & 1 deletion .npmrc
Original file line number Diff line number Diff line change
@@ -1 +1,7 @@
engine-strict = true
# Yarn Berry doesn't check engines at all, so pnpm shouldn't either.
engine-strict = false

# Disabling pnpm [hoisting](https://pnpm.io/npmrc#hoist) by setting `hoist=false` is recommended on
# projects using rules_js so that pnpm outside of Bazel lays out a node_modules tree similar to what
# rules_js lays out under Bazel (without a hidden node_modules/.pnpm/node_modules)
hoist=false
2 changes: 2 additions & 0 deletions .prettierignore
Original file line number Diff line number Diff line change
@@ -12,3 +12,5 @@ src/cdk/schematics/ng-update/test-cases/**/*_input.ts
src/cdk/schematics/ng-update/test-cases/**/*_expected_output.ts
src/material/schematics/ng-update/test-cases/**/*_input.ts
src/material/schematics/ng-update/test-cases/**/*_expected_output.ts

pnpm-lock.yaml
5 changes: 5 additions & 0 deletions BUILD.bazel
Original file line number Diff line number Diff line change
@@ -4,6 +4,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")

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

@@ -12,6 +13,10 @@ exports_files([
"package.json",
])

npm_link_all_packages(
name = "node_modules",
)

nodejs_binary(
name = "yarn_vendored",
data = [".yarn/releases/yarn-1.22.17.cjs"],
4 changes: 2 additions & 2 deletions DEV_ENVIRONMENT.md
Original file line number Diff line number Diff line change
@@ -66,7 +66,7 @@ packages locally and test them by either of the following ways:
### Approving public API changes
If you're making changes to a public API, they need to be propagated to our public API golden files.
To save the changes you can run `yarn approve-api <target>` and to review the changes, you can look
at the file under `tools/public_api_guard/<target>.d.ts`.
at the file under `goldens/<package>/<entry-point>.api.md`.


### Disabling Git hooks
@@ -86,7 +86,7 @@ export HUSKY=0

A set of environment variables is made available within the dev-app. Such variables
will be injected into the dev-app, so that e.g. API keys can be used for development
without requiring secrets to be committed.
without requiring secrets to be committed.

The following variables are currently used in the dev-app:

117 changes: 103 additions & 14 deletions WORKSPACE
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
#Workspace for angular material
workspace(
name = "angular_material",
managed_directories = {"@npm": ["node_modules"]},
)

# Point to the nested WORKSPACE we merged from github.com/angular/material.angular.io
@@ -64,20 +63,42 @@ load("@build_bazel_rules_nodejs//:repositories.bzl", "build_bazel_rules_nodejs_d

build_bazel_rules_nodejs_dependencies()

http_archive(
name = "aspect_rules_js",
sha256 = "75c25a0f15a9e4592bbda45b57aa089e4bf17f9176fd735351e8c6444df87b52",
strip_prefix = "rules_js-2.1.0",
url = "https://github.com/aspect-build/rules_js/releases/download/v2.1.0/rules_js-v2.1.0.tar.gz",
)

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.0.0"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn't we be on 20.11.1?

Typically we have our version of node within our repository as the earliest maintenance version (and moving to 20 now instead of waiting til mid april makes sense to me) instead of the current version.

I know that it was already at 22.0.0 when you moved this part over, but I wanted to check in on this now.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think for the Bazel invocation it doesn't necessarily matter as everyone gets the same. What do you think would be the value for staying at the earliest maintenance version?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since we still support the lower versions, the value is mostly in making sure we don't incidentally rely on something unsupported in the lower versions. It likely doesn't really make a difference, but just wanted to flag it

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, I think for CLI this matters, but here the risk is very low yeah.

Good idea to follow-up on this though. I can see this being a potential issue for the shipped schematics code.


NODE_REPOSITORIES = {
"22.0.0-darwin_arm64": ("node-v22.0.0-darwin-arm64.tar.gz", "node-v22.0.0-darwin-arm64", "ea96d349cfaa67aa87ceeaa3e5b52c9167f7ac302fd8d1ff162d0785e9dc0785"),
"22.0.0-darwin_amd64": ("node-v22.0.0-darwin-x64.tar.gz", "node-v22.0.0-darwin-x64", "422a3887ff5418f0a4552d89cf99346ab8ab51bb5d384660baa88b8444d2c111"),
"22.0.0-linux_arm64": ("node-v22.0.0-linux-arm64.tar.xz", "node-v22.0.0-linux-arm64", "83711d29cbe46375bdffab5419f3d831892e24294169272f6c39edc364556241"),
"22.0.0-linux_ppc64le": ("node-v22.0.0-linux-ppc64le.tar.xz", "node-v22.0.0-linux-ppc64le", "2b3fb8707a79243bfb3131312b86716ddc3855bce21bb168095b6b916798e5e9"),
"22.0.0-linux_s390x": ("node-v22.0.0-linux-s390x.tar.xz", "node-v22.0.0-linux-s390x", "89a8efeeb9f94ce9ea251b8109e079c14919f4c0dc2cbc9f545ec47ef0886737"),
"22.0.0-linux_amd64": ("node-v22.0.0-linux-x64.tar.xz", "node-v22.0.0-linux-x64", "9122e50f2642afd5f6078cafd1f52ede60fc464284384f05c18a04d13d07ae5a"),
"22.0.0-windows_amd64": ("node-v22.0.0-win-x64.zip", "node-v22.0.0-win-x64", "32d639b47d4c0a651ff8f8d7d41a454168a3d4045be37985f9a810cf8cef6174"),
}

nodejs_register_toolchains(
name = "nodejs",
node_repositories = {
"22.0.0-darwin_arm64": ("node-v22.0.0-darwin-arm64.tar.gz", "node-v22.0.0-darwin-arm64", "ea96d349cfaa67aa87ceeaa3e5b52c9167f7ac302fd8d1ff162d0785e9dc0785"),
"22.0.0-darwin_amd64": ("node-v22.0.0-darwin-x64.tar.gz", "node-v22.0.0-darwin-x64", "422a3887ff5418f0a4552d89cf99346ab8ab51bb5d384660baa88b8444d2c111"),
"22.0.0-linux_arm64": ("node-v22.0.0-linux-arm64.tar.xz", "node-v22.0.0-linux-arm64", "83711d29cbe46375bdffab5419f3d831892e24294169272f6c39edc364556241"),
"22.0.0-linux_ppc64le": ("node-v22.0.0-linux-ppc64le.tar.xz", "node-v22.0.0-linux-ppc64le", "2b3fb8707a79243bfb3131312b86716ddc3855bce21bb168095b6b916798e5e9"),
"22.0.0-linux_s390x": ("node-v22.0.0-linux-s390x.tar.xz", "node-v22.0.0-linux-s390x", "89a8efeeb9f94ce9ea251b8109e079c14919f4c0dc2cbc9f545ec47ef0886737"),
"22.0.0-linux_amd64": ("node-v22.0.0-linux-x64.tar.xz", "node-v22.0.0-linux-x64", "9122e50f2642afd5f6078cafd1f52ede60fc464284384f05c18a04d13d07ae5a"),
"22.0.0-windows_amd64": ("node-v22.0.0-win-x64.zip", "node-v22.0.0-win-x64", "32d639b47d4c0a651ff8f8d7d41a454168a3d4045be37985f9a810cf8cef6174"),
},
node_version = "22.0.0",
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")
@@ -103,9 +124,6 @@ yarn_install(
manual_build_file_contents = create_npm_package_archive_build_file(),
package_json = "//:package.json",
quiet = False,
# We prefer to symlink the `node_modules` to only maintain a single install.
# See https://github.com/angular/dev-infra/pull/446#issuecomment-1059820287 for details.
symlink_node_modules = True,
yarn = "//:.yarn/releases/yarn-1.22.17.cjs",
yarn_lock = "//:yarn.lock",
)
@@ -140,3 +158,74 @@ load("@build_bazel_rules_nodejs//toolchains/esbuild:esbuild_repositories.bzl", "
esbuild_repositories(
npm_repository = "npm",
)

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

npm_translate_lock(
name = "npm2",
data = [
"//:package.json",
"//:pnpm-workspace.yaml",
],
npmrc = "//:.npmrc",
pnpm_lock = "//:pnpm-lock.yaml",
update_pnpm_lock = True,
verify_node_modules_ignored = "//:.bazelignore",
yarn_lock = "//:yarn.lock",
)

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

npm_repositories()

http_archive(
name = "aspect_rules_ts",
sha256 = "9acd128abe77397505148eaa6895faed57839560dbf2177dd6285e51235e2724",
strip_prefix = "rules_ts-3.3.1",
url = "https://github.com/aspect-build/rules_ts/releases/download/v3.3.1/rules_ts-v3.3.1.tar.gz",
)

load("@aspect_rules_ts//ts:repositories.bzl", "rules_ts_dependencies")

rules_ts_dependencies(
# Obtained by: curl --silent https://registry.npmjs.org/typescript/5.8.2 | jq -r '.dist.integrity'
ts_integrity = "sha512-aJn6wq13/afZp/jT9QZmwEjDqqvSGp1VT5GVg+f/t6/oVyrgXM6BY1h9BRh/O5p3PlUPAe+WuiEZOmb/49RqoQ==",
ts_version_from = "//:package.json",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note that I don't know if we want to align on, for angular-cli we define the ts_version here instead of getting it from package.json. I don't have a really strong feeling on either way, but since we have to obtain the integrity sha anyway, maybe it makes sense to have the version directly defined here as well.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, in CLI I have a clean-up PR (blocked currently) that also leverages the version from the package.json

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see your point. Not feeling strongly, but ideally, long-term rules_js would automatically have the right integrity available. That's what I'm hoping for.

)

http_archive(
name = "aspect_rules_rollup",
sha256 = "c4062681968f5dcd3ce01e09e4ba73670c064744a7046211763e17c98ab8396e",
strip_prefix = "rules_rollup-2.0.0",
url = "https://github.com/aspect-build/rules_rollup/releases/download/v2.0.0/rules_rollup-v2.0.0.tar.gz",
)

load("@bazel_tools//tools/build_defs/repo:git.bzl", "git_repository")

git_repository(
name = "devinfra",
commit = "cc73dde52b557f831cc3b6e48daf8c3b542a33df",
remote = "https://github.com/angular/dev-infra.git",
)

load("@devinfra//bazel:setup_dependencies_1.bzl", "setup_dependencies_1")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Noting this while I am looking at it now. We should name these setup functions to include the repo they are setting up so that we don't have name collisions in the functions we bring in as well.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agreed. Let's follow-up on this and also align rules_angular


setup_dependencies_1()

load("@devinfra//bazel:setup_dependencies_2.bzl", "setup_dependencies_2")

setup_dependencies_2()

git_repository(
name = "rules_angular",
commit = "e10bf488aca18c159399f4c1163324a40f45a5dc",
remote = "https://github.com/devversion/rules_angular.git",
)

load("@rules_angular//setup:step_1.bzl", "step_1")

step_1()

load("@rules_angular//setup:step_2.bzl", "step_2")

step_2()
34 changes: 34 additions & 0 deletions goldens/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -1,4 +1,38 @@
load("@devinfra//bazel/api-golden:index.bzl", "api_golden_test_npm_package")

exports_files([
"size-test.yaml",
"tsec-exemption.json",
])

api_golden_test_npm_package(
name = "cdk_api",
data = glob(["cdk/**"]) + [
"//src/cdk:npm_package",
],
golden_dir = "angular_material/goldens/cdk",
npm_package = "angular_material/src/cdk/npm_package",
)

api_golden_test_npm_package(
name = "material_api",
data = glob(["material/**"]) + ["//src/material:npm_package"],
golden_dir = "angular_material/goldens/material",
npm_package = "angular_material/src/material/npm_package",
)

api_golden_test_npm_package(
name = "google_maps_api",
data = glob(["google-maps/**"]) + ["//src/google-maps:npm_package"],
golden_dir = "angular_material/goldens/google-maps",
npm_package = "angular_material/src/google-maps/npm_package",
types = ["@npm//@types/google.maps"],
)

api_golden_test_npm_package(
name = "youtube_player_api",
data = glob(["youtube-player/**"]) + ["//src/youtube-player:npm_package"],
golden_dir = "angular_material/goldens/youtube-player",
npm_package = "angular_material/src/youtube-player/npm_package",
types = ["@npm//@types/youtube"],
)
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
## API Report File for "components-srcs"
## API Report File for "@angular/cdk_a11y"

> Do not edit this file. It is a report generated by [API Extractor](https://api-extractor.com/).

@@ -30,7 +30,7 @@ export class A11yModule {
// (undocumented)
static ɵinj: i0.ɵɵInjectorDeclaration<A11yModule>;
// (undocumented)
static ɵmod: i0.ɵɵNgModuleDeclaration<A11yModule, never, [typeof i1.ObserversModule, typeof i2.CdkAriaLive, typeof i3.CdkTrapFocus, typeof i4.CdkMonitorFocus], [typeof i2.CdkAriaLive, typeof i3.CdkTrapFocus, typeof i4.CdkMonitorFocus]>;
static ɵmod: i0.ɵɵNgModuleDeclaration<A11yModule, never, [typeof ObserversModule, typeof CdkAriaLive, typeof CdkTrapFocus, typeof CdkMonitorFocus], [typeof CdkAriaLive, typeof CdkTrapFocus, typeof CdkMonitorFocus]>;
}

// @public (undocumented)
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
## API Report File for "components-srcs"
## API Report File for "@angular/cdk_accordion"

> Do not edit this file. It is a report generated by [API Extractor](https://api-extractor.com/).

@@ -74,7 +74,7 @@ export class CdkAccordionModule {
// (undocumented)
static ɵinj: i0.ɵɵInjectorDeclaration<CdkAccordionModule>;
// (undocumented)
static ɵmod: i0.ɵɵNgModuleDeclaration<CdkAccordionModule, never, [typeof i1.CdkAccordion, typeof i2.CdkAccordionItem], [typeof i1.CdkAccordion, typeof i2.CdkAccordionItem]>;
static ɵmod: i0.ɵɵNgModuleDeclaration<CdkAccordionModule, never, [typeof CdkAccordion, typeof CdkAccordionItem], [typeof CdkAccordion, typeof CdkAccordionItem]>;
}

// (No @packageDocumentation comment for this package)
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
## API Report File for "components-srcs"
## API Report File for "@angular/cdk_bidi"

> Do not edit this file. It is a report generated by [API Extractor](https://api-extractor.com/).

@@ -17,7 +17,7 @@ export class BidiModule {
// (undocumented)
static ɵinj: i0.ɵɵInjectorDeclaration<BidiModule>;
// (undocumented)
static ɵmod: i0.ɵɵNgModuleDeclaration<BidiModule, never, [typeof i1.Dir], [typeof i1.Dir]>;
static ɵmod: i0.ɵɵNgModuleDeclaration<BidiModule, never, [typeof Dir], [typeof Dir]>;
}

// @public
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
## API Report File for "components-srcs"
## API Report File for "@angular/cdk_clipboard"

> Do not edit this file. It is a report generated by [API Extractor](https://api-extractor.com/).

@@ -51,7 +51,7 @@ export class ClipboardModule {
// (undocumented)
static ɵinj: i0.ɵɵInjectorDeclaration<ClipboardModule>;
// (undocumented)
static ɵmod: i0.ɵɵNgModuleDeclaration<ClipboardModule, never, [typeof i1.CdkCopyToClipboard], [typeof i1.CdkCopyToClipboard]>;
static ɵmod: i0.ɵɵNgModuleDeclaration<ClipboardModule, never, [typeof CdkCopyToClipboard], [typeof CdkCopyToClipboard]>;
}

// @public
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
## API Report File for "components-srcs"
## API Report File for "@angular/cdk_coercion"

> Do not edit this file. It is a report generated by [API Extractor](https://api-extractor.com/).
Loading
Loading