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

Conversation

devversion
Copy link
Member

See individual commits

@angular-robot angular-robot bot added the area: build & ci Related the build and CI infrastructure of the project label Mar 14, 2025
@devversion devversion force-pushed the initial-rjs branch 5 times, most recently from f452498 to f3b322b Compare March 17, 2025 16:15
@devversion devversion requested a review from crisbeto March 17, 2025 16:23
@devversion devversion added target: patch This PR is targeted for the next patch release action: review The PR is still awaiting reviews from at least one requested reviewer labels Mar 17, 2025
@devversion devversion marked this pull request as ready for review March 17, 2025 16:23
@devversion devversion requested review from a team, andrewseguin and jelbourn as code owners March 17, 2025 16:23
Copy link
Member

@crisbeto crisbeto left a comment

Choose a reason for hiding this comment

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

Do we also plan to update the various utility scripts (e.g. yarn test) and the docs?

Copy link
Member

@josephperrott josephperrott left a comment

Choose a reason for hiding this comment

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

LGTM

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.

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.

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

@@ -1,4 +1,4 @@
## API Report File for "components-srcs"
## API Report File for "@angular/cdk_collections"
Copy link
Member

Choose a reason for hiding this comment

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

Nit: In an ideal world we would have the package string listing here correctly end up with the deeper entry point @angular/cdk/collections

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, that's a fix we'd need to make in api_golden

Copy link
Member

@josephperrott josephperrott left a comment

Choose a reason for hiding this comment

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

LGTM

Can we also include the necessary updates to renovate.json for the pnpm-lockfile changes?

@devversion
Copy link
Member Author

Do we also plan to update the various utility scripts (e.g. yarn test) and the docs?

@crisbeto for sure! Can you help quickly in how you think yarn test is affected? I thought it should be unaffected by this PR at least for now

@crisbeto
Copy link
Member

yarn test should work if the test targets follow the same pattern as before. That being said, we have a bunch of docs that are referring to Yarn instead of pnpm.

@devversion
Copy link
Member Author

devversion commented Mar 17, 2025

yeah, they follow the same convention, so should work.

Also this is just the initial PR and we are doing an incremental migration. You will still use yarn but occasionally need to run bazel run @npm2//:sync to update the lock file, when updating dependencies.

Will make this more clear in the team's Slack chat.

This is necessary for an incremental migration to `rules_js` which
requires Bazel v6. Bazel v6 removed the managed directories feature,
which means we no longer can rely on symlinked node modules as the Bazel
repository; but rather need to duplicate dependencies. This is
okay/acceptable to enable the incremental migration.
Sets up `rules_js` and links dependencies into the bazel-bin.
This commit sets up `rules_ts`, providing the `ts_library` equivalent
for the `rules_js` migration.
The `ts_project` interop rule that we've built was also used in the
Angular CLI migration, and it allows us to mix `ts_project` and
`ts_library` targets; enabling an incremental migration.
This is an initial commit to migrate some `testing/` targets to
`ts_project`, leveraging the interop rule we've built.

Notably we also turn of strict deps checking temporarily as the deps
checking is only applicable when there are no interop deps anymore!
* Moves the public API goldens to `goldens/`
* Switches us to the `npm_package` variant of the golden testing rule.
  This variant is more future proof and will work well with the
  `rules_js` migration (as it takes arbitrary Bazel tree artifacts)
This will automatically result in Renovate updating the Aspect lock
files.
This will result in the release tool automatically updating the Aspect
lock files when necessary.
@devversion devversion removed the request for review from jelbourn March 18, 2025 13:00
@devversion devversion removed the request for review from andrewseguin March 18, 2025 13:00
@devversion devversion added merge: preserve commits When the PR is merged, a rebase and merge should be performed action: merge The PR is ready for merge by the caretaker target: minor This PR is targeted for the next minor release and removed action: review The PR is still awaiting reviews from at least one requested reviewer target: patch This PR is targeted for the next patch release labels Mar 18, 2025
@devversion devversion merged commit 23269f3 into angular:main Mar 18, 2025
23 of 26 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
action: merge The PR is ready for merge by the caretaker area: build & ci Related the build and CI infrastructure of the project merge: preserve commits When the PR is merged, a rebase and merge should be performed target: minor This PR is targeted for the next minor release
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants