angular / angular-cli

CLI tool for Angular
https://cli.angular.io
MIT License
26.76k stars 11.98k forks source link

SSR Schematics uses by default API being in developer preview state #28662

Open pawelfras opened 2 days ago

pawelfras commented 2 days ago

Command

new

Is this a regression?

The previous version in which this bug was not present was

19.0.0-next.9

Description

Schematics for SSR generates new application with the following API that is in dev preview:

Compared to previous functionalities introduced as dev preview, e.g. provideClientHydration, the API mentioned above is not optional but used by default.

Minimal Reproduction

Exception or Error

No response

Your Environment

Angular CLI: 19.0.0-next.11 Node: 22.8.0 Package Manager: yarn 1.22.22 OS: darwin arm64

Angular: ...

Package Version

@angular-devkit/architect 0.1900.0-next.11 (cli-only) @angular-devkit/core 19.0.0-next.11 (cli-only) @angular-devkit/schematics 19.0.0-next.11 (cli-only) @schematics/angular 19.0.0-next.11 (cli-only)

Anything else relevant?

No response

alan-agius4 commented 2 days ago

Thanks for bringing this up—we definitely understand your point. That said, there are clear advantages to using the new API over the old one.

For context, in the past, schematics were used to scaffold development preview code for features like Fetch HttpClient (withFetch), Hydration (provideClientHydration), and Event Reply (withEventReply). To opt out of these, manual code changes were required.

We'll continue to discuss this internally.

Platonn commented 2 days ago

Hi @alan-agius4 . Thanks for taking this issue under discussion in the Angular Team. Let me share our usecase, to help provide more context for an informed debate:

Our Angular library We're maintaining an Angular library for creating ecommerce sites (SAP Spartacus), where we depend on SSR APIs a lot. And as an enterprise product, we care adapt new APIs of Angular only when they are declared Stable API. Otherwise we would risk too many/frequent breaking changes for our users, which we want to avoid for our users.

Our library is installed via schematics Our storefront app is scaffolded in 2 steps:

  1. ng new ... (create new angular app)
  2. ng add @spartacus/schematics ... (install our library and scaffold a storefront app).

Why ng new using Developer Preview APIs is cumbersome for us And if the app created in the step 1 uses Angular APIs being in Developer Preview, then we have to write our own funky schematics steps that revert usage of Developer Preview APIs, and replace with the Stable APIs - which is cumbersome.

So ideally, I'd love if ng new could by default create apps using only stable APIs, but Developer Preview APIs would be used only when an optional CLI arg is provided to ng new.

Many thanks for your effort. Respect to your choices All that said, I want to thank you for all your hard work on improving Angular SSR Developer Experience. And I respect your software design choices, acknowledging they are often very hard to make.