14 Commits

Author SHA1 Message Date
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
Alan Agius
43cd4584f5 fix(@schematics/angular): enable opt-in for new @angular/ssr feature
This commit updates several schematics to make the new `@angular/ssr` feature opt-in. Users can opt in by using the `--server-routing` option or by responding with `yes` to the prompt.
2024-10-25 19:51:12 +02:00
Alan Agius
292a4b7c2f feat(@schematics/angular): update app-shell and ssr schematics to adopt new Server Rendering API
This commit revises the app-shell and ssr schematics to incorporate the new Server Rendering API, along with the integration of server-side routes.

BREAKING CHANGE: The app-shell schematic is no longer compatible with Webpack-based builders.
2024-10-09 18:07:33 +02:00
Alan Agius
d8b8364d35 refactor(@schematics/angular): move @angular/ssr dependency to server schematic
This change is necessary as the `@angular/ssr` package is now required for all types of server-side rendering, including SSG and app-shell.
2024-08-27 09:34:04 -07: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
3107ad7b83 fix(@schematics/angular): check both application builder packages in SSR schematic
The SSR schematic was previously only checking for the application build found
within the `@angular-devkit/build-angular` package which is only an alias to the
actual builder found in the `@angular/build` package. Both aliased and direct
usages are now checked when executing the schematic.
2024-05-27 08:03:28 +02:00
Alan Agius
4469e481fc fix(@schematics/angular): do not trigger NPM install when using ---skip-install and --ssr
The `skipInstall` option was never passed to the ssr schematic, which caused NPM install to also be invoked when running `ng new --ssr`.
2023-12-26 18:28:45 +01:00
Alan Agius
a708dccff3 feat(@schematics/angular): update SSR and application builder migration schematics to work with new outputPath
In #26675 we introduced a long-form variant of `outputPath`, this commit updates the application builder migration and ssr schematics to handle this change.
2023-12-19 07:20:25 +01:00
Alan Agius
364a16b7a6 feat(@angular-devkit/build-angular): move browser-sync as optional dependency
`browser-sync` is now an optional dependency of `@angular-devkit/build-angular`. This package is only needed when using the legacy `@angular-devkit/build-angular:ssr-dev-server` builder.

Closes #26349
2023-12-06 11:47:28 -05:00
Alan Agius
b513d89b77 feat(@schematics/angular): add optional migration to use application builder
This commits adds an optional migration to migration existing projects to use the vite and esbuild based application builder.

The migration can be opted-in when running `ng update @angular/cli --name=use-application-builder`
2023-12-01 13:38:06 +01:00
Alan Agius
80b024bc0d fix(@schematics/angular): add helper script to spawn SSR server from dist
This commit adds a helper script in the `package.json` when running `ng add @angular/ssr` or `ng new --ssr` that can be used to spawn the SSR server.

Example of script:
```json
{
    "scripts": {
       "serve:ssr:my-app": "node dist/my-app/server/server.mjs"
    }
}
```

Closes #26315
2023-11-13 08:27:13 +01:00
Alan Agius
17fd0ade13 fix(@angular-devkit/build-angular): update ssr option definition
This commits updates the `ssr` application builder option definition. The main change is that now the option does not accept the entry-point as a value. Instead it should be passed in the `entry` suboption.

Example
```json
"ssr": {
    "entry": "server.ts"
}
```

This change in this option is important to allow us in the future to add additional sub options. Like potentially a `platform` or `target`.
2023-10-19 13:15:31 +02:00
Alan Agius
62aa7393c8 test: ensure to use the correct version for @angular/ssr packages
This commit fixes an issue that causes update tests to fail when we are in feature freeze
2023-10-12 15:54:24 +02:00
Alan Agius
6a85b13b1f refactor(@angular/ssr): move ng-add schematic to @schematics/angular
This move is in preparation to enable `ng new --ssr`.
2023-09-25 20:17:01 +02:00