168 Commits

Author SHA1 Message Date
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
Angular Robot
8d35b9bd38 build: update angular 2024-12-13 11:30:46 -08:00
Alan Agius
10a5b8b6b8 fix(@angular/ssr): disable component bootstrapping during route extraction
This commit disables component bootstrapping during route extraction to prevent invoking the AppComponent and its lifecycle hooks.

Closes #29085
2024-12-11 18:16:46 +01:00
Alan Agius
6eed4609f4 refactor(@angular/ssr): move ignored messages as a global
Refactored the ignored log messages into a global constant.
2024-12-11 14:52:26 +01:00
Alan Agius
41ece633b3 feat(@angular/ssr): redirect to preferred locale when accessing root route without a specified locale
When users access the root route `/` without providing a locale, the application now redirects them to their preferred locale based on the `Accept-Language` header.

This enhancement leverages the user's browser preferences to determine the most appropriate locale, providing a seamless and personalized experience without requiring manual locale selection.
2024-12-10 13:11:06 +01:00
Alan Agius
8d7a51dfc9 feat(@angular/ssr): add modulepreload for lazy-loaded routes
Enhance performance when using SSR by adding `modulepreload` links to lazy-loaded routes. This ensures that the required modules are preloaded in the background, improving the user experience and reducing the time to interactive.

Closes #26484
2024-12-10 12:39:47 +01:00
Alan Agius
0a570c0c2e feat(@angular/build): add support for customizing URL segments with i18n
Previously, the `baseHref` option under each locale allowed for generating a unique base href for specific locales. However, users were still required to handle file organization manually, and `baseHref` appeared to be primarily designed for this purpose.

This commit introduces a new `subPath` option, which simplifies the i18n process, particularly in static site generation (SSG) and server-side rendering (SSR). When the `subPath` option is used, the `baseHref` is ignored. Instead, the `subPath` serves as both the base href and the name of the directory containing the localized version of the app.

Below is an example configuration showcasing the use of `subPath`:

```json
"i18n": {
  "sourceLocale": {
    "code": "en-US",
    "subPath": ""
  },
  "locales": {
    "fr-BE": {
      "subPath": "fr",
      "translation": "src/i18n/messages.fr-BE.xlf"
    },
    "de-BE": {
      "subPath": "de",
      "translation": "src/i18n/messages.de-BE.xlf"
    }
  }
}
```

The following tree structure demonstrates how the `subPath` organizes localized build output:
```
dist/
├── app/
│   └── browser/  # Default locale, accessible at `/`
│       ├── fr/  # Locale for `fr-BE`, accessible at `/fr`
│       └── de/  # Locale for `de-BE`, accessible at `/de`
```

DEPRECATED: The `baseHref` option under `i18n.locales` and `i18n.sourceLocale` in `angular.json` is deprecated in favor of `subPath`.

The `subPath` defines the URL segment for the locale, serving as both the HTML base HREF and the directory name for output. By default, if not specified, `subPath` will use the locale code.

Closes #16997 and closes #28967
2024-12-07 19:00:32 +01:00
Alan Agius
d7214e9610 fix(@angular/ssr): include Content-Language header when locale is set
The server now includes the `Content-Language` HTTP header in responses whenever a locale is explicitly set.
2024-12-07 18:46:14 +01:00
Alan Agius
6647247ec0 test(@angular/ssr): refine spec setup to resolve component ID collision warnings
This update addresses excessive log noise caused by the following warning:
`NG0912: Component ID generation collision detected. Components 'AppComponent' and 'AppComponent' with selector 'app-root' generated the same component ID. To fix this, you can change the selector of one of those components or add an extra host attribute to force a different ID. Find more at https://angular.dev/errors/NG0912`.
2024-12-06 08:24:11 +01:00
Angular Robot
f717a54066 build: update angular 2024-12-05 16:52:35 +01:00
Alan Agius
1ca260e807 docs(@angular/ssr): remove duplicate @return comment
Remove duplicate `@return` tsdoc comment.
2024-12-05 16:21:37 +01:00
Alan Agius
f897b7a7f1 fix(@angular/ssr): apply HTML transformation to CSR responses
Before this commit, HTML transformations were not applied to CSR responses, leading to the omission of the Vite client code.

Closes #29033
2024-12-04 15:37:32 +01:00
Alan Agius
4db4dd4315 refactor(@angular/ssr): replace Map with Record in SSR manifest
Replaced `Map` with `Record` in SSR manifest to simplify structure and improve testing/setup.
2024-12-04 10:13:39 +01:00
Alan Agius
e4448bb3d4 fix(@angular/ssr): correctly handle serving of prerendered i18n pages
Ensures proper handling of internationalized (i18n) pages during the  serving of prerendered content.
2024-12-02 15:39:56 +01:00
Alan Agius
4e5585a27f build: update Angular packages to version 19.1.x 2024-12-02 13:12:00 +01:00
Alan Agius
42e16ddce0 refactor(@angular/ssr): mark @angular/platform-server as optional
Whlist, this package is not really optional, NPM will install the wrong verson of peer dependencies when the Angular CLI is in prerelease mode.

```ts
STDERR:
npm error code ERESOLVE
npm error ERESOLVE unable to resolve dependency tree
npm error
npm error While resolving: test-project@0.0.0
npm error Found: @angular/animations@19.1.0-next.0
npm error node_modules/@angular/animations
npm error   @angular/animations@"^19.1.0-next.0" from the root project
npm error
npm error Could not resolve dependency:
npm error peer @angular/animations@"19.0.1" from @angular/platform-server@19.0.1
npm error node_modules/@angular/platform-server
npm error   peer @angular/platform-server@"^19.1.0-next.0 || ^19.0.0" from @angular/ssr@19.1.0-next.0
npm error   node_modules/@angular/ssr
npm error     @angular/ssr@"19.1.0-next.0" from the root project
npm error
npm error Fix the upstream dependency conflict, or retry
npm error this command with --force or --legacy-peer-deps
```
2024-12-02 13:12:00 +01:00
Alan Agius
aed726fca3 fix(@angular/build): add timeout to route extraction
This commit introduces a 30-second timeout for route extraction.
2024-11-27 16:48:33 -05:00
Angular Robot
7554cc1ec2 build: update angular 2024-11-26 21:38:28 -05:00
Alan Agius
3dd3b2218b fix(@angular/ssr): ensure compatibility for Http2ServerResponse type
Updated the `Http2ServerResponse` interface to eliminate dependency on generics, ensuring compatibility across multiple versions of `@types/node`.

Closes #28965
2024-11-26 17:46:34 +01:00
Sheik Althaf
7ff933423c refactor(@angular/ssr): use appRef.whenStable instead of util function from angular core
using application whenStable function instead of custom util function from angular core.
2024-11-25 10:44:13 -05:00
Alan Agius
20411f696e refactor(@angular/ssr): replace :params with *
The SSR router relies on wildcard matching rather than params. This commit refactors the stored routes by removing the `:params`.
2024-11-22 10:40:11 -08:00
Alan Agius
34574b2906 fix(@angular/ssr): handle nested redirects not explicitly defined in router config
This commit ensures proper handling of nested redirects that are implicitly structured but not explicitly defined in the router configuration.

Closes #28903
2024-11-22 11:10:34 +01:00
Alan Agius
8c534da649 fix(@angular/ssr): handle baseHref that start with ./
Updated function to support handling `baseHref` starting with './' path correctly.
2024-11-21 08:20:58 +01:00
Charles Lyding
23dac18def build: update Angular packages to v19 stable 2024-11-19 10:01:19 -05:00
Doug Parker
d3dd8f00d3 fix(@angular/ssr): use wildcard server route configuration on the '/' route when the app router is empty 2024-11-18 10:38:17 -08:00
Doug Parker
160dee33d7 fix(@schematics/angular): don't show server routing prompt when using browser builder
The new routing APIs don't support `browser` builder, but calling `ng add @angular/ssr` with a `browser` builder would still prompt the user to add them. If the user said "Yes", it would actually ignore that answer and not enable the new APIs.

With this change, `ng add @angular/ssr` when using `browser` builder does not show the prompt and assumes the answer is "No". It also throws an error if the user runs `ng add @angular/ssr --server-routing`.

I'm not aware of a built-in prompting mechanism in schematics beyond `x-prompt`, which can't be used here, so instead I just called Inquirer directly. Unfortunately testing the prompt is a little awkward, as Inquirier does not provide useful APIs in this space. I evaluated `@inquirer/testing`, but ultimately decided that was more intended for testing custom Inquirer prompts, not mocking usage of standard prompts. Schematics APIs do not provide a useful way to inject additional data like a mock, so instead I had to do this through a `setPrompterForTestOnly` function. I'm not a huge fan of it, but I don't see a more straightforward way of solving the problem.
2024-11-18 10:37:31 -08:00
Doug Parker
114673ff8d refactor: removes @angular/ssr/tokens and imports the symbols from @angular/core
Since the symbols are exposed from `@angular/core`, there is no need for a separate export in `@angular/ssr/tokens` anymore.
2024-11-15 10:54:37 -08:00
Angular Robot
4fcce7dc0f build: update angular 2024-11-15 10:23:54 -08:00
cexbrayat
d77527db6d fix(@angular/ssr): export PrerenderFallback
Importing `PrerenderFallback` in a project throws at build time in 19.0.0-rc.2 with:

```ts
✘ [ERROR] No matching export in "node_modules/@angular/ssr/fesm2022/ssr.mjs" for import "PrerenderFallback"

    src/app/app.routes.server.ts:1:9:
      1 │ import { PrerenderFallback, RenderMode, ServerRoute } from '@angula...
```

This exports `PrerenderFallback` the same way `RenderMode` is exported to fix the issue.
2024-11-15 09:49:10 -08:00
Alan Agius
073e81ecfb refactor(@angular/ssr): remove redundant new URL
Re-use existing const
2024-11-08 22:33:09 +01:00