256 Commits

Author SHA1 Message Date
Alan Agius
5ff4c28e7b build: ensure that tools/legacy-rnjs/node_modules is ignored 2025-03-11 14:17:40 +01:00
Paul Gschwendtner
9dd3f0344f
Further clean-up rules_nodejs npm workspace and remove yarn.lock (#29779)
* build: disconnect `@npm` workspace from main project

This will speed up significantly as we don't need to fetch all
dependencies again just for the `@npm` repository that is at this point
only leveraged by the `ng_package` rule for some of its dependencies.

This commit allows us to drop the `yarn.lock` and Aspect lock files, and
allows us to independently migrate `ng_package` to `rules_js`.

It also allows us to drop the `_rjs` TS interop layer in follow-up commits.

* build: drop `_rjs` suffix from `ts_project` targets

We don't need the `ts_project` interop in principle
at this point. We only have one remaining instance left for the SSR
`ng_package` integration. This commit cleans up all usages.

* build: remove yarn

* build: avoid duplicated dependencies at top-level

`rules_js` seems to be sensitive if there are similar versions of the same
package installed, but with differently matched peer dependencies. This
is fine because we can (and should long-term) move those dependencies to
their package-local `package.json` files. This commit unblocks the
migration and highlights how we can move deps to the individual packages
in the future.

* build: update checkout github action

This will allow us to use pnpm.

* build: update node to avoid strict-engines error caused by `npm`

Avoids:

```
Lockfile is up to date, resolution step is skipped
 ERR_PNPM_UNSUPPORTED_ENGINE  Unsupported environment (bad pnpm and/or Node.js version)

Your Node version is incompatible with "npm@11.2.0".

Expected version: ^20.17.0 || >=22.9.0
Got: v20.11.1
```

Note that we won't update the WORKSPACE test version as that would mean
we need to update the Node engines for shipped packages; and we can't do
this right now without introducing a breaking change.

* build: fix missing dependency for spec bundling

The beasties JS sources weren't available for bundling in the
`bazel-bin`, and this surfaced in RBE. This commit fixes this.
2025-03-11 10:05:52 +01:00
Paul Gschwendtner
5fd1cb56ab build: update dev-infra and rework windows native testing
As part of go/ng:windows-dev-future, we are changing how our
infrastructure supports Windows build & testing. Clearly:

- we will still support contributors on Windows, and we believe we will
  be improving and streamlining the experience here
- we will continue testing the Angular CLI for our Windows users. We are
  aware of the many Windows users using the `ng` CLI.

What is changing? We are no longer actively working towards a Bazel infrastructure
that supports native Windows building and testing. There are currently
two ways to contribute to Angular on Windows. That is via WSL, or via
e.g. native Windows cmd.exe, with Git Bash on top. We acknowledge that
the latter worked sometimes, but we also realize it very often breaks as
nobody on our team uses, verifies it, and it introduces extra complexity
because Bazel on Windows is quite disconnected from Linux/Mac (e.g. no
sandboxing). Going forward, to improve our team's effectiveness, and
improve our stability guarantees for Windows (and Windows contributors),
we are actively discouraging the use of Git Bash for contributing to
Angular; but instead ask for WSL to be used. I can speak as one of the
few long-term team members that have worked on Windows (without WSL) most
of my time, that WSL is great and the contributing experience is much
smoother and also easier to "guide". It's a positive change because we
won't be suggesting "two ways to contribute on Windows", where in
reality one is very brittle and can break at any time!

---

For testing of the Angular CLI: We will continue to maintain the
capability to cross-compile via Bazel with Windows as the target
platform. This allows us to build the e2e tests for Windows, and run
them natively outside WSL to ensure native Windows `ng` CLI testing!
This is what this change mostly does.

Notably, two things are missing here and will be followed up:

- caching of the e2e tests on Windows is not properly functioning yet.
- caching of the WSL node modules + nvm is not working properly yet.

Other than that, we are seeing very similar timing and results of the
Windows tests, so this change unblocks our `rules_js` migration.
2025-03-03 21:44:50 +01:00
Charles Lyding
5e90c1b4ec fix(@angular/cli): remove Node.js v18 support
Node.js v18 will reach its End-of-Life on 2025-04-30 and as a result will
not be supported with the upcoming Angular v20.
Node.js Release Schedule: https://github.com/nodejs/release#release-schedule

BREAKING CHANGE: Node.js v18 is no longer supported with Angular.

Before updating a project to Angular v20, the Node.js version must be
at least 20.11.1. For the full list of supported Node.js versions,
see https://angular.dev/reference/versions.
2025-02-20 13:37:53 -05:00
Joey Perrott
68ef24d3d7 build: add strict_deps requirement for ts_project
Setup requirement for strict_deps throughout repository to ensure that the only dependencies which are imported
are directly provided as dependencies within bazel.
2025-02-19 15:22:58 -05:00
Paul Gschwendtner
2236bc185a build: remove legacy defaults.bzl macro file
This file is currently no longer necessary after migrating all consumers
to their `rules_js` variants, so we can delete the file.

In follow-ups we will consider renaming `defaults2.bzl` back to this
file, or have a better name altogether.
2025-01-30 11:16:46 +01:00
Paul Gschwendtner
01ea33e372 build: migrate CLI schema generation to rules_js
Migrates the CLI schema generation to `rules_js`, also significantly
simplifying the rule boilerplate.
2025-01-30 11:16:46 +01:00
Paul Gschwendtner
b40fa4073d build: migrate ts_json_schema rule to rules_js
Migrates to `rules_js` and simplifies! the `ts_json_schema` rule
2025-01-30 11:16:46 +01:00
Paul Gschwendtner
ef70b77049 build: remove usages of rules_nodejs copy_to_bin
Replaces usages of `rules_nodejs` `copy_to_bin` with the
`rules_js`/Aspect bazel lib equivalent.
2025-01-30 11:16:46 +01:00
Paul Gschwendtner
6a6ecee7e8 build: do not print tar command on windows for every dependency
Currently the Windows job prints the `tar` command when extracting a
dependency, for every individual package.
2025-01-29 10:16:32 +01:00
Paul Gschwendtner
af25379a3b build: migrate @angular/ssr tests to rules_js
Migrates the SSR tesst to run natively via `rules_js`. Notably, we still
need the bundling in between as the tests and SSR plain code is not
valid ESM technically; due to lack of extensions.

We'll need to revisit this in the future, or at the very least come up
with a `rules_js`-variant of the `spec_bundle`; but for this is
sufficient and unblocks other packages.
2025-01-23 15:27:55 +01:00
Paul Gschwendtner
397ea00552 build: migrate @angular-devkit/architect/node tests to rules_js
Migrates the sub-entry point tests for architect/node to `rules_js`.
2025-01-21 18:19:11 +01:00
Alan Agius
e7413d3ae1 refactor: reduce dependencies on @angular-devkit/core
By converting schemas from TypeScript `interfaces` to `types`, we can minimize the reliance on `json.JsonObject`. This approach avoids the error "Type 'Schema' does not satisfy the constraint 'JsonObject'" caused by the missing index signature for type 'string' in 'Schema'.
2025-01-21 16:36:23 +01:00
Paul Gschwendtner
e519bef788 build: migrate @angular/pwa tests to rules_js
This commit changes the execution of `@angular/pwa` tests to `rules_js`
native `jasmine_test`.

This requires setting it up in the pnpm workspace for first-party linked
dependencies. Notably it turns out the peer dependency placeholder was
incorrect, so we are fixing it here and nicely avoid a problem where
pnpm would otherwise not find a local, or external suitable version.

As we originally tried to work without the fix for the peer dependency
range, there was supported added for extra substitutions. We are keeping
that logic as it will likely be useful in the future.
2025-01-21 09:25:54 +01:00
Paul Gschwendtner
037bbe5ca5 build: ensure source maps are used for jasmine stack traces
`rules_js` doesn't integrate source maps by default, so we are enabling it by default via `defaults2.bzl`.
2025-01-17 16:29:45 +01:00
Paul Gschwendtner
485f0679e6 build: ensure package substitutions work with pnpm workspace:* links
We'll be using `workspace:*` protocol links to link first-party packages
together in the pnpm workspace. For this reason, we need to make sure
they are properly replaced in `package.json` files, before packaging.
2025-01-17 16:29:45 +01:00
Alan Agius
31cbf5f9ad build: replace hardcoded Angular and ng-packagr peer dependencies with Bazel stamping
Refactor the build configuration to use Bazel stamping for Angular and ng-packagr dependencies, eliminating the need for hardcoded peer dependencies.
2025-01-16 19:06:30 +01:00
Alan Agius
c37b59ee2c build: exclude pnpm and dependenciesMeta fields from published NPM packages
Currently, the `pnpm` and `dependenciesMeta` fields from the root `package.json` are inadvertently copied to the `package.json` of published packages.

For example, see: dc4d5e0d52/package.json (L42-L52)
2025-01-16 17:44:34 +01:00
Paul Gschwendtner
ac37218e41 build: migrate @angular-devkit/architect jasmine test to native rules_js
Instead of using `rules_nodejs` interop and the linker at runtime, the
test target is migrated to the new `jasmine_test` rule, leveraging the
pnpm workspace for first-party dependencies.

Note that in the future we may be able to rename the local node modules
to something more clear. e.g. `:local_modules/@angular-devkit/core`, but
for now this is not possible :(

This commit shows how similar packages can be migrated in the future.
2025-01-15 19:20:40 +01:00
Paul Gschwendtner
4fee94a96c build: rename //:root_modules to //:node_modules.
This is necessary as `rules_js` requires this "common name" when dealing
with Yarn workspaces, linking first party dependencies automatically.

In the future, we may be able to send a PR to `rules_js` to support a
custom name somehow.
2025-01-15 19:20:40 +01:00
Paul Gschwendtner
e31be733b6 build: support substituting/stamping files other than package.json
Similart to `pkg_npm` from `rules_nodejs`, we should have a way to make
use of the stamp constants/placeholders throughout individual package
files. This is not possible at all with `rules_js`'s `npm_package` rule,
nor does it support stamp substitutions out of the box at all.

We have our own `expand_template` machinery to substitute `package.json`
files of npm archives, but we need to expand this to support arbitrary
files inside a package. This will be opt-in for explicitly listed files;
which is a good compromise for simplicity of supporting this.

This commit adds the necessary functionality and demonstrates the
feature by fixing `@angular/build`.
2025-01-13 19:19:06 +01:00
Paul Gschwendtner
b55bd318f1 fixup! build: migrate @angular-devkit/architect to npm_package
Include JSON files
2025-01-10 13:15:00 +01:00
Paul Gschwendtner
2218b0d0df build: migrate @angular-devkit/architect to npm_package
Migrates the `@angular-devkit/architect` package to the `rules_js` npm
package rule, consuming the direct `rules_ts` output JS files.

Notably, substitution is FAR different than what it used to be with
`rules_nodejs`, so we needed some extra work to leverage `make_template`
for substitutions in `package.json` files. **Keep in mind** that for
now, this does not apply to any other files; so we only substitute in
the `package.json`, but not in e.g. `.js` files as before. We will
follow-up on this.

The other jq merging/filtering for snapshot or tar references in
`package.json` files is kept as is, and is temporarily duplicated. This
is acceptable as the migration should be pretty smooth and quick.
2025-01-10 13:15:00 +01:00
Paul Gschwendtner
a8335cf950 build: never use interop targets for ts compilations
* Removes `interop_deps` from the `ts_project` interop macro.
* Keeps `_rjs` suffix for now as we still need the interop targets for
  e.g. `jasmine_node_test` and the `rules_nodejs` linker.

In follow-ups we can remove the suffix, and interop layer.
2025-01-09 09:42:06 +01:00
Paul Gschwendtner
8c94d22469 build: migrate @angular/ssr to ts_project
Migrates `@angular/ssr` to `ts_project`. Possible after
various upstream fixes for `ng_package` and interop changes.
2025-01-08 07:42:19 -08:00
Paul Gschwendtner
04b818436e build: do not include tsconfig files in npm archives
`rules_js` includes `tsconfig.json` files in the `DeclarationInfo`
provider. This ends up causing these files to be part of the npm
archives.
2025-01-08 14:12:01 +01:00
Paul Gschwendtner
cdf5d86688 build: improve ts_project hybrid interop with node modules
Currently the interop resulting target of a `ts_project` ends up not
necessarily working at runtime. This may be the case because a consuming
Node program may end up with mixes of `node_modules` dependencies from
`rules_nodejs` (old) and `rules_js` (new). This sounds fine at first
glance, but in practice can break very subtly because:

* Rules NodeJS leverages the linker, creating `node_module` directories
  outside of Bazel, at runtime. These don't depend on symlink resolving.
* Rules JS puts real node module folders via Bazel actions. These rely
  on `pnpm` non-hoisting layout, and symlink resolving.

As we can see there is a hard conflict with symlinks. They need to be
enabled with the new toolchain, but the other one doesn't enable symlink
resolution, and enabling is not possible as we'd otherwise risk escaping
the sandbox and cause even more subtle errors.

A good compromise solution is to automatically drop the `rules_js` node
module files/folder in the interop-`rules_nodejs` target and instead
brining in the equivalent `@npm//` dependencies from `rules_nodejs`.
This kind of keeps the logic similar to when not using `rules_js` or the
interop, and enables the simplest & safest mental model; and it works
compared to other solutions I tried with symlinking. Notably, we can't
keep both node module variants as the linker doesn't override existing
node module files from e.g. rules_js then (and would break then).
2024-12-19 12:21:37 -05:00
Paul Gschwendtner
c701acb25d build: use worker for ts_project to enable fast DX and avoid no-sandbox issues
For the `rules_js` migration we are introducing a new ruleset for
Angular rules. These rules are not used here by the CLI as we don't use
`ng_module`, but we are building the rules in a way where we expose a
worker binary that can also work with vanilla TS.

The worker significantly speeds up compilations, bringing them to
equivalent speeds of `ts_library`, and **importantly** fixes/avoids
issues when actions are executing outside sandbox. E.g. on Windows where
the tsc compilation currently can see many other files that aren't
action inputs; and accidentally picks them up.
2024-12-16 12:17:17 -05:00
Paul Gschwendtner
6006f591e8 build: workaround aspect bazel lib tar.gz windows issue
Workaround until `rules_js` imports the latest version of
`aspect_bazel_lib`: https://github.com/bazel-contrib/bazel-lib/issues/968
2024-12-16 12:17:17 -05:00
Paul Gschwendtner
620671dc18 build: update to more improved copy_to_bin rule.
This is necessary as the current rule is not clever enough to detect
when a given file is already "generated" and inside `bin`.

This is important because `package.json` files are always copied to bin
for `npm_package`, but the `package.json` may already be copied from
e.g. `ts_project#data`. This shouldn't cause a Bazel action conflict.
2024-12-16 12:17:17 -05:00
Paul Gschwendtner
369a5fa57a build: create ts_project interop allowing for incremental migration
This commit introduces a new interop Starlark macro/rule for using
`ts_project` throughout the repository without having to migrate
any dependant or dependencies; allowing for incremental migration
to `ts_project`.
2024-12-16 12:17:17 -05:00
Paul Gschwendtner
afc75ce5a4 build: setup rules_ts for compiling TypeScript sources
This commit sets up `rules_ts`, providing the `ts_library` equivalent
for the `rules_js` migration.
2024-12-16 12:17:17 -05:00
Alan Agius
15677d0cb7 refactor: replace critters with beasties
The Critters project has been transferred to the Nuxt team, who will now manage its development and has been renamed to Beasties.

See: https://github.com/danielroe/beasties
2024-10-28 18:57:05 +01:00
Alan Agius
41934e7aa1 build: update the @angular/bazel packager and set up the license attribute 2024-10-02 13:09:16 +02:00
Alan Agius
607a97cdeb refactor(@angular/ssr): bundle Critters
This commit bundles the Critters library to ensure compatibility with Nodeless environments. Additionally, all licenses for bundled libraries, including Critters, are now included in the package. This helps maintain compliance with open-source license requirements.
2024-08-24 07:37:36 +02:00
Charles Lyding
83b7343ec2 Revert "build: change to local repo's build system(path to npm_package_archive.tgz files)"
This reverts commit eedeee2f4fc4f0cd3124611aa733d320847f5bd3.

Causes snapshot publishing failures: https://github.com/angular/angular-cli/actions/runs/10471282117/job/29006137399
2024-08-20 16:52:21 +02:00
JAPNITSINGH
eedeee2f4f build: change to local repo's build system(path to npm_package_archive.tgz files) 2024-08-20 14:10:51 +02:00
Alan Agius
465d462031 build: remove unused bazel rules
This commit remove unused bazel rules.
2024-07-08 15:49:28 +02:00
Charles Lyding
cec97fe3a5 build: use yarn patching instead of third-party package 2024-06-10 18:17:03 -04:00
Ash Ramirez
434a3740f0 refactor(@angular/cli): update aio links -> adev links
Updates for all angular.io links to the new angular.dev domain. Additionally, adjustment to new resources where the equivalent does not exist on the new site (e.g. Tour of Heroes tutorial)
2024-06-06 11:12:06 +02:00
Alan Agius
4087728c3e feat(@angular/cli): support for Node.js v22
Add support for Node.js v22
2024-04-25 14:04:43 +02:00
Charles Lyding
e588e84160 test: remove node-fetch package usage
Native fetch support is now available in Node.js and the `node-fetch` package can now be removed.
2023-10-31 08:57:42 +01:00
Alan Agius
6b2b5191ca ci: add node.js 20 setup
Run tests on Node.js 20
2023-10-30 12:28:00 +01:00
Charles Lyding
f7130ef639 build: disable inline sourcemap generation
The built packages that will be published on npm previously contained inlined
sourcemaps for every JavaScript file. This caused a significant increase in the
overall package size of over two times larger. This has a negative effect on
developer experience especially the new project experience due to the increase
time to download and setup a new project. The sourcemaps are also rarely used
as debugging the CLI code itself is typically done with development builds.
The generated code is also very close to the original source due to it being
emitted as ES2022 code and with the eventual switch to ESM output this will
become even closer.
As an example of the size difference, the `@angular/cli` compressed package size
was reduced from ~352Kb to ~115Kb with this change.
2023-10-25 12:52:14 +02:00
Charles Lyding
0811f641b3 build: update package output to use ES2022
The JavaScript generated for the published packages is now using ES2022.
This removes additional downleveling of code that was previously necessary
to use newer features.
The minimum Node.js version of 18.13 provides support for the needed features.
While this change does require a patch to `@bazel/concatjs` to allow the target
to be set to `ES2022`, this patch is now already required by the migration of
the universal repository into the CLI repository.
2023-09-08 10:19:37 -07:00
Angular Robot
e8240d7197 build: update dependency jasmine to v5 2023-08-30 17:02:00 +02:00
Charles Lyding
a00b21afdf build: use bazel ts_library rule to build @angular/ssr
The `@angular/ssr` package does not require the Angular compiler and can instead use the
`ts_library` to compile the TypeScript code.  The `@angular/bazel` package has also been
update and a more limited patch is now used due to only needing the `ng_package` rule.
The continued use of the `ng_package` rule maintains the existing output structure for the
`@angular/ssr` package.
2023-08-30 09:08:18 +02:00
Alan Agius
3fe432c71b refactor: update code to integrate universal repo
This commit updates the moved universal code into the cli pipeline
2023-08-22 20:44:53 +00:00
Alan Agius
8fe8cdf05a refactor: move universal code into CLI repo
Merge remote-tracking branch 'universal/move-to-cli' into universal-merge
2023-08-16 11:34:47 +00:00
Alan Agius
e6ce7f8414 refactor: prepare code for CLI move 2023-08-16 09:55:58 +00:00