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.
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
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
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.
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
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
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.
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.
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
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
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`.
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
```
Updated the `Http2ServerResponse` interface to eliminate dependency on generics, ensuring compatibility across multiple versions of `@types/node`.
Closes#28965
This commit ensures proper handling of nested redirects that are implicitly structured but not explicitly defined in the router configuration.
Closes#28903
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.
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.