4594 Commits

Author SHA1 Message Date
Younes Jaaidi
ef7ea536fe feat(@angular-devkit/build-angular): add aot option to jest 2025-02-04 07:46:16 -08:00
Angular Robot
7a8ff1f099 build: update all non-major dependencies 2025-02-03 14:35:08 -08:00
Angular Robot
02d87bcf33 build: update all non-major dependencies 2025-01-31 08:28:30 +01:00
Paul Gschwendtner
3194f5675b build: remove leftover unused rules_nodejs npm dependency
This dependency does not provide any value for the `ts_project`
compilation, nor does it seem to be necessary; so we are cleaning up
this dependency.
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
Charles Lyding
319fbb6f06 refactor(@angular-devkit/core): add missing function return types
Adding explicit type information for function return types is needed
to allow the `@angular-devkit/core` package to eventually be built with
the `isolatedDeclarations` option.
2025-01-29 18:54:27 +01:00
Paul Gschwendtner
832bfffc43 build: migrate @angular-devkit/build-angular tests to rules_js
Migrates the `@angular-devkit/build-angular` tests to `rules_js`. This
was a rather larger undertaking as the tests were very reliant on e.g.
the directory structure or specific node module layout; so some changes
were needed.

- the Sass files include a much larger file header now. That is because
  the npm Sass files have much larger paths, given being inside a
  symlinked pnpm store directory. E.g.

  ```

/*!**********************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************!*\
  !*** css ../../../../../node_modules/.aspect_rules_js/css-loader@7.1.2_webpack_5.97.1/node_modules/css-loader/dist/cjs.js??ruleSet[1].rules[4].rules[0].oneOf[0].use[1]!../../../../../node_modules/.aspect_rules_js/postcss-loader@8.1.1_1462687623/node_modules/postcss-loader/dist/cjs.js??ruleSet[1].rules[4].rules[0].oneOf[0].use[2]!./src/test-style-a.css?ngGlobalStyle ***!
  \**********************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************/
.test-a {color: red}
  ```

- Similarly to above, hashed chunk files can change given different
  paths of e.g. Webpack, or external sources.

- Tests for verifying the lazy module chunks may enable
  `preserveSymlinks` just to make the chunk names shorter and easier to
  verify, avoiding truncatd super long paths to the e.g. pnpm stores
  again.

- the ngsw-worker.js file cannot be copied using `copyFile` as that
  results in permissions being copied as well. In Bazel, now that
  the npm files are properly captured, are readonly, so subsequent
  builds (e.g. the watch tests) will fail to copy/override the file
  again! Reading and writing the file consistently seems appropriate.

- Tests relying on puppeteer and webdriver-manager worked in the past,
  by accident, because postinstall scripts (from e.g. puppeteer) were
  able to modify content of other packages (e.g. the puppeteer-core
  cache of browsers then). This does not work with `rules_js` anymore,
  so we need to keep the cache local to the puppeteer postinstall
  script. This requires a little trickery right now to ensure resolution
  of the browsers at runtime works..

- server tests did miss the `node` types to be explicitly listed (as
  they would be in a fresh project), and this caused failures. Likely
  because we no longer patch resolution.

- avoid npm-module style imports from tests within the same package.
  This is not allowed with `rules_js` and also is inconsistent.
2025-01-29 09:02:41 +01:00
Angular Robot
0fe4a5493f build: update all non-major dependencies 2025-01-29 08:30:27 +01:00
Charles Lyding
694ef8e6e4 fix(@angular/build): allow tailwindcss 4.x as a peer dependency
To support usage of the newly released Tailwind CSS 4.0.0, the peer dependency
range has been update to include `^4.0.0`. This prevents potential installation
warnings/error when using various package managers.
Use of Tailwind CSS 4+ requires either the `application` (new project default) or
`browser-esbuild` builder. Both of which support custom postcss configuration
via a `.postcssrc.json` file.

For instructions on the setup of Tailwind CSS with Angular, please see the
Tailwind CSS documentation here: https://tailwindcss.com/docs/installation/framework-guides/angular
2025-01-27 12:30:33 -05:00
Angular Robot
d47971c9e4 build: update all non-major dependencies to v7.26.7 2025-01-27 14:16:22 +01:00
Angular Robot
e00ea8e1fb build: update all non-major dependencies 2025-01-24 07:23:41 -05:00
Alan Agius
1a3ef3b60b fix(@angular/build): disable TypeScript removeComments option
Disables TypeScript's `removeComments` option to ensure important annotations like `/* @__PURE__ */`
and `/* vite-ignore */` are preserved. TypeScript's comment removal can be too aggressive,
potentially stripping out critical information needed by bundlers for dead code elimination.
Non-essential comments will be handled by the bundler, so removing them in TypeScript isn't necessary
and could lead to an increase in the final bundle size.

Closes #29470
2025-01-24 13:20:56 +01:00
Charles Lyding
f836be9e67 fix(@angular/build): support Vite allowedHosts option for development server
Vite version 6.0.9+, which is now used by the Angular CLI, contains a potentially
breaking change for some development setups. Examples of such setups include those
that use reverse proxies or custom host names during development. The change within
a patch release was made by Vite to address a security vulnerability. For
projects that directly access the development server via `localhost`, no changes should
be needed. However, some development setups may now need to adjust the newly
introduced `allowedHosts` development server option. This option can include an array
of host names that are allowed to communicate with the development server. The option
sets the corresponding Vite option within the Angular CLI.
For more information on the option and its specific behavior, please see the Vite
documentation located here:
https://vite.dev/config/server-options.html#server-allowedhosts

The following is an example of the configuration option allowing `example.com`:
```
"serve": {
      "builder": "@angular/build:dev-server",
      "options": {
        "allowedHosts": ["example.com"]
      },
```

Additional details on the vulnerability can be found here:
https://github.com/vitejs/vite/security/advisories/GHSA-vg6x-rcgg-rjx6
2025-01-23 18:48:47 -05:00
Paul Gschwendtner
0c264261fe build: migrate modules/testing/builders to rules_js runtime
Fully migrates `modules/testing/builders` to `rules_js`, so that it can
resolve modules at runtime using RJS, or executes tests via RJS.
2025-01-23 15:27:55 +01:00
Paul Gschwendtner
ac055e1ff3 build: migrate @angular-devkit/schematics-cli tests to rules_js
Migrates the schematics-cli tests to `rules_js`.

Notably a little extra logic was needed here as the tests were relying
on the built npm package at runtime, resolvable via it's "package name".
To address this, we manually link the package for the test at runtime.

The spec file is moved into a separate folder for this reason, so that
we don't accidentally expose the schematics CLI package for unexpected
reasons.
2025-01-21 18:19:11 +01: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
e8a97aa465 build: migrate @angular-devkit/core/node tests to rules_js
Migrates the sub-entry point tests for core/node to `rules_js`.
2025-01-21 18:19:11 +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
14584f0bfd build: migrate @angular-devkit/build-webpack tests to rules_js
Migrates the `@angular-devkit/build-webpack` jasmine tests to
`rules_js`. This requires wiring up in the pnpm workspace.

Additionally `typescript` is added as it was missing as a "peer
dependency" at runtime for `@ngtools/webpack`. This is expected, and
we're already adding other peer deps before this change.
2025-01-21 09:25:54 +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
Angular Robot
0186e8061f build: update all non-major dependencies 2025-01-20 10:52:33 +01:00
Paul Gschwendtner
0f5106d970 test: improve stability of strategy tests
The strategy tests are extremely time-sensitive with regards to the RxJS
job logic executing, and the tests currently rely on `setImmediate` to
flush/trigger job execution. This seems to be rather unstable via Remote
execution, and sensitive to changes with the execution (e.g. injecting
source map support or not), so we are stabilizing the tests further by
having better time delays for job execution, and by using `setTimeout`
for flushing. This seems very sufficient.
2025-01-17 16:29:45 +01:00
Paul Gschwendtner
74162d54b2 build: migrate @angular-devkit/architect-cli tests to rules_js
Migrates `@angular-devkit/architect-cli` jasmine rules to the
native `rules_js` variant.
2025-01-17 16:29:45 +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
3cc84e4434 build: migrate @angular-devkit/core tests to rules_js
Migrates `@angular-devkit/core` jasmine rules to the native `rules_js`
variant.
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
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
Angular Robot
2046ce4717 build: update all non-major dependencies 2025-01-16 09:07:20 -08: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
96b6a16a65 refactor: add explicit types for createBuilder exports
This is necessary as with the new compilation, leveraging pnpm-linked
first party dependencies, there are cases **during migration** where
multiple locations of the same package exist. e.g.

- `@angular_devkit/architect/node_modules/@angular-devkit/core` (pnpm package output)
- `@angular_devkit/core` (plain js sources)

This is fine, and there is no risk of wrong types, and this should only
occur during migration anyway, but it causes a few type issues as
TypeScript is unable to emit proper types for inference. This is okay,
as we'd likely even want to make use of `isolatedDeclarations` at some
point, but we just add explicit types right now.

(also making `Builder` type more type safe, checking assignability
properly).
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
Joey Perrott
92c7674604 build: migrate @angular-devkit/schematics-cli to npm_package
This allows us to use the package in the RJS pnpm workspace.
2025-01-15 08:36:31 -08:00
Angular Robot
23ebfd9440 build: update all non-major dependencies 2025-01-15 10:56:18 +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
Paul Gschwendtner
0ae4e13c3d build: migrate @angular-devkit/build-angular 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
Paul Gschwendtner
edca9b2e04 build: migrate @angular-devkit/build-webpack 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
Paul Gschwendtner
1486c63f90 build: migrate @angular-devkit/core 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
Paul Gschwendtner
ea79fabc39 build: migrate @angular-devkit/architect-cli 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
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
Angular Robot
aaf114fa6e build: update dependency undici to v7.2.1 2025-01-10 08:44:09 +01:00
Alan Agius
adf9359ad1 fix(@angular-devkit/core): handle Windows drive letter case insensitivity in path functions
This update ensures that path-related functions in account for the case-insensitivity of drive letters on Windows systems. By addressing this inconsistency, the functionality becomes more robust and aligned with Windows filesystem behavior.

Closes #27029
2025-01-09 16:07:34 +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
Alan Agius
b78ccb073a test: remove browser builder AOT tests
These cases are covered in other spec files.
2025-01-07 13:52:07 +01:00
Alan Agius
4d88743b02 test: lower debounceTime in browser builder tests
The current `debounceTime` values are unnecessarily high, resulting in slow test execution. Reducing these times will improve efficiency.
2025-01-07 13:52:07 +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
Alan Agius
aa6bf07f35 fix(@angular-devkit/architect): provide better error when builder is not defined
When a builder is not defined a more actionable error message is now displayed.

Closes #29226
2025-01-06 15:19:00 +01:00
Angular Robot
9b57ff0552 build: update all non-major dependencies 2025-01-06 11:55:29 +01:00