298 Commits

Author SHA1 Message Date
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
Alan Agius
e6be37601d refactor(@angular-devkit/schematics): remove deprecated NodePackageLinkTask
BREAKING CHANGE: The `NodePackageLinkTask` has been removed without a replacement. Create a custom task if needed.

Note: This does not affect application developers.
2025-03-03 15:59:49 +01:00
Angular Robot
4b4b25bdfc build: update dependency rxjs to v7.8.2 2025-02-23 09:40:53 -05:00
Joey Perrott
5358aa4b04 refactor(@angular-devkit/schematics): fix dependencies and import paths for strict deps requirements 2025-02-20 14:18:10 -05:00
Joey Perrott
6890422769 refactor(@angular-devkit/schematics): fix dependencies and import paths for strict deps requirements 2025-02-20 14:18:10 -05:00
Joey Perrott
ca1e86b684 build: disable failing strict_deps targets
Disable all failing strict_deps targets with TODOs to fix them moving forward.
2025-02-19 15:22:58 -05:00
Joey Perrott
c9273f8b85 build: add @types/node to assorted locations where node types are being relied on and currently obtained transitively. 2025-02-19 12:53:55 -05:00
Joey Perrott
33ed6e875e refactor: move builtin module imports to use node: prefix imports 2025-02-14 11:09:23 -08:00
Paul Gschwendtner
612c17823a build: migrate @angular-devkit/schematics/tools tests to rules_js
Migrates the sub-entry point tests for schematics/tools to `rules_js`.
2025-01-21 18:19:11 +01:00
Paul Gschwendtner
2982c01655 fix(@angular-devkit/schematics): ensure collections can be resolved via test runner in pnpm workspaces
Currently when operating within a pnpm workspace and leveraging the
schematic test runner, there are situations where e.g.
`@schematics/angular` cannot be resolved. Consider this pnpm node
modules structure:

```
packages/
  pwa/
    node_modules/@schematics/angular --> .pnpm-store/@schematics/angular/...
    node_modules/@angular-devkit/schematics --> .pnpm-store/@angular-devkit/schematics/...
    index_spec.js // trying to call external schematic `@schematics/angular`
```

This above setup will fail because `@schematics/angular` is attempted to
be resolved from within the devkit schematics code, which doesn't have
access, or a dependency on `@schematics/angular`. We can use the
specified collection of the test runner to determine a good "resolution
lookup site", similiar to how it happens with the real `ng update`
command.
2025-01-21 09:25:54 +01:00
Paul Gschwendtner
05cc4bbeb8 build: migrate @angular-devkit/schematics tests to rules_js
Migrates `@angular-devkit/schematics` jasmine rules to the
native `rules_js` variant.

As part of this commit, we are performing a few adjustments that we've
discussed as preparation for this migration:

- cross package imports are always using the module name
- inside package imports are always using relative imports, matching
  existing tests, fixing a few outliers.
2025-01-17 16:29:45 +01:00
Paul Gschwendtner
1a4157d88c build: migrate @angular/cli tests to use rules_js
Integrates `@angular/cli` into the pnpm workspace and wires up the
native `rules_js` rules.

One nice benefits that highlight here:

- `resolve` runtime dependency is only installed in the CLI folder, and
  we can pull it from there. --> Locally managed deps! :yay:
2025-01-17 16:29:45 +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
2a8a1dd301 build: migrate @angular-devkit/schematics to npm_package
Updates to the `rules_js` npm archive rule, as part of the overall
migration effort.
2025-01-14 16:06:07 +01:00
Alan Agius
4f803083fc fix(@angular-devkit/schematics): update Rule type to support returning a Promise of Tree
The `Rule` type has been updated to align with its intended functionality, allowing it to return a `Promise<Tree>`. Previously, this behavior was supported but not properly typed.

Closes #22783
2025-01-14 09:44:32 +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
Charles Lyding
8b68d9fe7c build: migrate @angular-devkit/schematics to ts_project
The `@angular-devkit/schematics` package has been migrated to the `rules_js` ts_project rule.
The tsconfig path mappings for the `@angular-devkit` scope have also been cleaned up now that
all the packages within this scope have been migrated.
2025-01-06 12:19:23 -05:00
Angular Robot
947948434f build: update all non-major dependencies 2024-12-19 10:30:49 -05:00
Angular Robot
12f2026581 build: update all non-major dependencies 2024-12-11 07:56:48 -08:00
Angular Robot
3a22d4435b build: update all non-major dependencies 2024-11-27 08:39:52 -05:00
Angular Robot
fe1af9fc97 build: update all non-major dependencies 2024-11-21 11:39:43 -08:00
Angular Robot
fba1978af2 build: update dependency magic-string to v0.30.12 2024-10-11 08:45:51 -07:00
Charles Lyding
62a99b70b8 refactor(@angular-devkit/schematics): avoid for await...of with promise arrays
The upcoming version of typescript Eslint rules will fail the `await-thenable`
rule for cases of for await...of that use promise arrays. This change
removes the usage to avoid lint failures during the version update.
Ref: https://typescript-eslint.io/rules/await-thenable/#async-iteration-for-awaitof-loops
2024-10-02 16:06:35 -04:00
Kristiyan Kostadinov
7f570c5685 build: update to TypeScript 5.6 RC
Updates the repo to the TypeScript 5.6 RC and narrows down the version to drop support for 5.4, in line with the compiler.
2024-08-29 10:40:28 +02:00
Angular Robot
2bf8e7f296 build: update all non-major dependencies 2024-07-30 12:40:39 +02:00
Charles Lyding
5895e9fb01 test: enable no-case-declarations lint rule
The `no-case-declarations` rule is now enabled and all failures
in have been addressed within the published code. Unit tests
have been excluded.
2024-07-11 08:19:56 +02:00
Doug Parker
79821006b8 refactor: fix pipe type
An explicit cast was removed in fa9bce0e9a (diff-29e41c6172a2d68db9886be9e933ed2b477732095313e104c52a725f887276cf) which relies on [control flow narrowing](https://devblogs.microsoft.com/typescript/announcing-typescript-5-5/#control-flow-narrowing-for-constant-indexed-accesses) in TS 5.5. However, google3 is still on TS 5.4, so we can't fully depend on that feature. Using an intermediate variable makes the type narrowing work correctly even in TS 5.4.
2024-06-27 11:21:30 -07:00
Charles Lyding
7fa5c3ea9f refactor(@angular-devkit/schematics): use modern language features in test engine host
The `NodeModulesTestEngineHost` class has been adjusted to use modern JavaScript
language features such as private fields and nullish coalescing.
2024-06-26 08:31:30 -07:00
Charles Lyding
b60b7dacfa refactor(@angular-devkit/schematics): avoid double file access reading JSON files
The file system engine hosts for schematics were using a helper method to
read JSON files that was performing both an exist and read call. Besides
causing two file system calls, this also has a potential race condition
where the file may not exist by the time the read call is made. To avoid
this, a try/catch is used with the read call to handle the not existing
case.
2024-06-26 08:31:10 -07:00
Charles Lyding
d56c8de284 refactor: minor code cleanup to improve code health
Several smaller code changes to improve type information and remove now
unneeded code structures based on improvements to both Node.js, TypeScript,
and underlying dependencies.
2024-06-25 16:57:16 -04:00
Charles Lyding
fa9bce0e9a test: enable @typescript-eslint/no-unnecessary-type-assertion lint rule
The `@typescript-eslint/no-unnecessary-type-assertion` rule is now enabled and all failures
have been addressed within the code.
2024-06-25 16:57:03 -04:00
Alan Agius
aebfde28c7 build: update all non-major dependencies
Closes #27881
2024-06-25 20:53:49 +02:00
Charles Lyding
39f946a848 build: enabled isolated modules TypeScript option
The TypeScript `isolatedModules` option is now enabled for all TypeScript
code within the repository. As a result, all packages will now be built
with the option enabled. This does not affect projects created with the CLI
and is only related to the building of the actual Angular CLI code.
The `isolatedModules` option ensures that code can be emitted without the
TypeScript typechecker and allows tools other than TypeScript to potentially
be used. Code was updated to correct all errors after the option was enabled.
Additionally, some early code fixes were done to add function and accessor
return types to prepare for future `isolatedDeclarations` usage. More changes
would be needed to consider turning on `isolatedDeclarations`, however.
2024-06-23 15:34:49 +02: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
Charles Lyding
d087b5f9f2 refactor(@angular-devkit/schematics): reduce direct rxjs usage in filter host tree
All direct usage of rxjs has been removed from the FilterHostTree implementation.
This removes the need to import rxjs within the containing file. The recursive
logic has also been replaced with an iterative approach.
2024-05-15 13:42:20 -04:00
Alan Agius
7b52b98bfd fix(@angular-devkit/schematics): SchematicTestRunner.runExternalSchematic fails with "The encoded data was not valid for encoding utf-8"
When using Jest instanceof does not work correctly. See: https://github.com/jestjs/jest/issues/2549

Closes: #27643
2024-05-15 17:17:50 +02:00
Divy Srivastava
41ee8eac19 fix(@angular-devkit/schematics): use web standard error check for Deno support 2024-05-02 09:59:48 -04:00
Angular Robot
8843188080 build: update all non-major dependencies 2024-04-17 20:01:54 +02:00
Alan Agius
203c0eeb35 build: update all non-major dependencies 2024-04-08 10:10:09 -04:00
Alan Agius
7975845831 refactor(@angular-devkit/schematics): deprecate NodePackageLinkTask
DEPRECATED: `NodePackageLinkTask` in `@angular-devkit/schematics`. A custom task should be created instead.
2024-03-14 16:04:20 +01:00
Angular Robot
ab4f98596c build: update all non-major dependencies 2024-03-06 11:37:15 +01:00
Charles Lyding
860b93a25b refactor(@angular-devkit/schematics): remove now unused internal UpdateBuffer class
The internal `UpdateBuffer` class is no longer used within the schematics package
and can be removed.
2024-02-12 13:28:07 +01:00
Charles Lyding
77f6a41a83 refactor(@angular-devkit/schematics): directly use magic-string in update recorder
The schematics `UpdateRecorder` now uses the `magic-string` library directly instead
of delegating to another class (`UpdateBuffer`) which now effectively only wraps the
`magic-string`. This also allows for improved BOM handling and repeat conversion
of strings to and from `Buffer` instances.
2024-02-12 13:28:07 +01:00
Alan Agius
cc916c1997 fix(@angular-devkit/schematics): add bun to known package managers
Fixes an issue that causes `Unknown package manager "bun".` is thrown when running `NodePackageTask` executor
2024-02-09 14:07:38 +01:00
Angular Robot
ccdaed4e49 build: update all non-major dependencies 2024-02-06 08:42:54 -05:00
Angular Robot
5f916e7810 build: update all non-major dependencies 2024-02-01 08:31:07 -08:00
Charles Lyding
910531a3c8 refactor: remove outdated namespace syntax usage
The `namespace` TypeScript usage within the CLI has been removed. This
syntax is not recommended outside of type definition files.
2024-01-26 08:55:53 +01:00
Angular Robot
248b4c9a75 build: update all non-major dependencies 2024-01-23 10:52:36 +01:00
Alan Agius
7e9bbe442d fix(@angular-devkit/schematics): replace template line endings with platform specific
Currently, when using `ng new` on Windows, users will get a number of `LF will be replaced by CRLF the next time Git touches it` warnings.

This commit, replaces the line endings in templates to be platform specific.

Closes #26764
2024-01-03 11:44:51 +01:00