197 Commits

Author SHA1 Message Date
Alan Agius
18e13e2cee feat(@schematics/angular): remove --server-routing option
Server-side rendering (SSR) will always enable server routing when using the application builder.

BREAKING CHANGE: `--server-routing` option has been removed from several schematics. Server routing will be used when using the application builder.
2025-03-13 17:40:26 +01:00
Alan Agius
cdfc50c29a feat(@angular/ssr): stabilize AngularNodeAppEngine, AngularAppEngine, and provideServerRouting APIs
This commit promotes the `AngularNodeAppEngine`, `AngularAppEngine`, and `provideServerRouting` APIs from dev preview to stable. These APIs enhance server-side rendering (SSR) capabilities in Angular applications, improving routing and server integration for better performance and reliability.
2025-03-13 17:40:26 +01:00
Paul Gschwendtner
32470e6a32 build: update angular 2025-03-13 09:29:35 +01:00
Alan Agius
ee8466de52 fix(@angular/ssr): prevent stream draining if write does not return a boolean
Implements a workaround for https://github.com/CodeGenieApp/serverless-express/issues/683

Closes #29801
2025-03-11 15:24:54 +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
Alan Agius
280693231e perf(@angular/ssr): optimize response times by introducing header flushing
Improves SSR performance by streaming the response before inlining critical CSS. This allows for earlier header flushing, reducing time to first byte (TTFB) and improving perceived load times.
2025-03-04 16:15:35 +01:00
Alan Agius
349dcd1b30 build: update Angular dev deps to version 20 2025-03-04 12:34:23 +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
d63e31c326 refactor(@angular/ssr): remove deprecated provideServerRoutesConfig dev-preview API
`provideServerRouting` should be used instead.
2025-03-03 15:59:52 +01:00
Angular Robot
44b06f4486 build: update angular 2025-02-27 08:58:21 -08: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
Angular Robot
8f73dad78d build: update angular 2025-02-19 16:28:28 -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
Alan Agius
833dc986db fix(@angular/ssr): properly handle baseHref with protocol
Enhances handling of `baseHref` when it includes a full URL with a protocol.

Closes #29590
2025-02-10 15:33:31 -08:00
Angular Robot
021985fcb1 build: update angular 2025-02-07 11:04:05 -08:00
Alan Agius
25dbe7cfc1 refactor(@angular/ssr): simplify preload append logic in metadata
Replace `filter` and `map` with a `for...of` loop to improve readability in the preload append logic within metadata.
2025-02-03 15:20:18 -08:00
Alan Agius
6448f80bfb fix(@angular/ssr): prioritize the first matching route over subsequent ones
Ensures that the SSR router gives precedence to the first matching route, addressing the issue where later conflicting routes.

This change prevents the incorrect prioritization of routes and ensures the intended route is matched first, aligning routing behavior.

Closes: #29539
2025-02-03 12:23:19 -08:00
Alan Agius
9726cd084b feat(@angular/ssr): Add support for route matchers with fine-grained render mode control
This commit adds support for custom route matchers in Angular SSR, allowing fine-grained control over the `renderMode` (Server, Client) for individual routes, including those defined with matchers.

Routes with custom matchers are **not** supported during prerendering and must explicitly define a `renderMode` of either server or client.

The following configuration demonstrates how to use glob patterns (including recursive `**`) to define server-side rendering (SSR) or client-side rendering (CSR) for specific parts of the 'product' route and its child routes.

```typescript
// app.routes.ts
import { Routes } from '@angular/router';

export const routes: Routes = [
  {
    path: '',
    component: DummyComponent,
  },
  {
    path: 'product',
    component: DummyComponent,
    children: [
      {
        path: '',
        component: DummyComponent,
      },
      {
        path: 'list',
        component: DummyComponent,
      },
      {
        matcher: () => null, // Example custom matcher (always returns null)
        component: DummyComponent,
      },
    ],
  },
];
```

```typescript
// app.routes.server.ts
import { RenderMode, ServerRoute } from '@angular/ssr';

export const serverRoutes: ServerRoute[] = [
  { path: '**', renderMode: RenderMode.Client },
  { path: 'product', renderMode: RenderMode.Prerender },
  { path: 'product/list', renderMode: RenderMode.Prerender },
  { path: 'product/**/overview/details', renderMode: RenderMode.Server },
];
```

Closes #29284
2025-01-31 13:09:34 +01:00
Paul Gschwendtner
c0d20e05c3 build: switch beasties bundling to rules_js
Switches the beasties bundling to `rules_js`, using rollup directly from
the node modules installation.

Notably we are facing a small issue that doesn't cause any issues right
now, because rollup tries to dereference symlinks by default given
a bug: https://github.com/aspect-build/rules_js/issues/1827.

This means we can't rely on the jailed resolution, but in practice it
shouldn't cause an issue at this point.
2025-01-30 11:16:46 +01: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
83b9d33946 build: migrate remaining usage of pkg_npm to rules_js
This is necessary so that we can delete the `pkg_npm` macro and fully
leverage the `rules_js` variant.
2025-01-30 11:16:46 +01:00
Angular Robot
448e920e34 build: update angular 2025-01-30 08:00:17 +01:00
Alan Agius
46581db16b fix(@angular/ssr): redirect to locale pathname instead of full URL
When redirecting to the preferred locale, the previous implementation used the full URL for the 302 redirect to i18n subpaths based on the user's preferred locale. This update ensures that the redirect now uses the locale-specific pathname instead of the full URL.

Closes #29514
2025-01-29 16:18:16 +01:00
Paul Gschwendtner
539336e01a build: migrate remaining @angular/ssr tests to rules_js
Migrates the remaining `@angular/ssr` tests to `rules_js`.
2025-01-29 10:16:32 +01:00
Alan Agius
ec05c814ee fix(@angular/ssr): rename provideServerRoutesConfig to provideServerRouting
This commit renames `provideServerRoutesConfig` to `provideServerRouting` and updates the second parameter to use the `ServerRoutes` features.

This change improves alignment with the framework's API conventions and the way features are integrated.

### Example Usage:
Before:
```typescript
provideServerRoutesConfig(serverRoutes, { appShellRoute: 'shell' })
```

After:
```typescript
provideServerRouting(serverRoutes, withAppShell(AppShellComponent))
```
2025-01-28 09:25:42 +01:00
alexfriesen
57ae111e28 refactor(@angular/ssr): drain node stream 2025-01-28 09:07:25 +01:00
Alan Agius
4df97d1923 fix(@angular/ssr): enhance dynamic route matching for better performance and accuracy
Updated route matching logic to prioritize closest matches, improving the accuracy of dynamic route resolution. Also we optimized performance by eliminating unnecessary recursive checks, reducing overhead during route matching.

Closes #29452
2025-01-24 11:44:16 +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
Alan Agius
b9151e25ff refactor(@angular/ssr): remove unused segment property from metadata
The `segment` property within the route-tree metadata is redundant and serves no functional purpose. Therefore, it has been removed.
2025-01-22 16:57:47 -05:00
Charles Lyding
5ee647049a build: update Angular versions for 19.2 prereleases 2025-01-22 16:55:46 -05:00
Alan Agius
b0c2d1900f refactor(@angular/ssr): update getPathSegments to use stripTrailingSlash instead of filter(Boolean)
This change modifies the `getPathSegments` function to use `stripTrailingSlash`, providing a more consistent and reliable way to handle trailing slashes in paths. This update also resolves issues causing CI failures.
2025-01-22 10:54:13 +01:00
Alan Agius
3546c6d12d fix(@angular/ssr): properly manage catch-all routes with base href
This fix ensures that catch-all routes (e.g., wildcard routes like `**`) are handled correctly when a base href is configured in an Angular SSR application.

Closes #29397
2025-01-22 09:06:29 +01:00
Alan Agius
4a1833d842 fix(@angular/ssr): unblock route extraction with withEnabledBlockingInitialNavigation
This fix ensures that route extraction is not blocked when `withEnabledBlockingInitialNavigation` is used.

Closes #29400
2025-01-20 18:51:23 +01:00
Angular Robot
a0efac87ce build: update angular 2025-01-20 12:35:40 -05:00
Alan Agius
f3a923301e fix(@angular/ssr): prevent route matcher error when SSR routing is not used
Although route matchers are not supported with the SSR Routing API, they still function with the legacy `CommonEngine`. Therefore, no error should be issued in this case.

Closes #29420
2025-01-20 16:17:29 +01:00
Angular Robot
d048368cfd build: update angular 2025-01-17 11:03:53 -08: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
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
Alan Agius
8ba6b28b43 docs: enhance descriptions for schematics options
Refined and clarified the descriptions for various schematics options to improve their readability and accuracy. These changes aim to make the documentation more user-friendly and accessible for developers.

Closes #25571
2025-01-15 17:31:06 +01:00
Angular Robot
ecadcae831 build: update bazel 2025-01-10 17:34:01 +01:00
Angular Robot
6fc31fd348 build: update angular 2025-01-08 11:34:47 -08: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
Alan Agius
6edb908837 fix(@angular/ssr): throw error when using route matchers
Route matchers are not currently supported in Angular SSR. This commit ensures an error is issued when a route matcher is detected.
2025-01-08 15:53:35 +01:00
Matthieu Riegler
ccf3650665 refactor(@angular/ssr): clean up comment.
The double JSDoc start sequence was visible in the docs (https://angular.dev/api/ssr/provideServerRoutesConfig). This commit fixes it.
2025-01-06 11:54:19 +01:00
Alan Agius
3feecddbba fix(@angular/ssr): disable component boostrapping when running route extraction
This commit fixes an issue where the components where still being
boostrapped when using `provideAppInitializer`

Closes #29131
2024-12-19 17:39:23 +01:00
Angular Robot
07a8bce68f build: update angular 2024-12-19 07:38:40 +01:00
Alan Agius
ad1d7d76fc fix(@angular/ssr): ensure correct Location header for redirects behind a proxy
Previously, when the application was served behind a proxy, server-side redirects generated an incorrect Location header, causing navigation issues. This fix updates `createRequestUrl` to use the port from the Host header, ensuring accurate in proxy environments. Additionally, the Location header now only contains the pathname, improving compliance with redirect handling in such setups.

Closes #29151
2024-12-17 12:33:49 -08:00
Alan Agius
f7c0a83c5d refactor(@angular/ssr): mark LINK_LOAD_SCRIPT_CONTENT as @PURE
This const is pure.
2024-12-17 11:27:54 -08:00
Alan Agius
78c41f67ec refactor(@angular/ssr): add timeout to prevent 'adev' hanging during route extraction
A timeout was added during route extraction to resolve an issue where 'adev' would hang in production builds.
The root cause is currently unclear, but this change ensures the build completes successfully.
2024-12-16 14:58:48 +01:00