Skip to content

feat: support angular@20 #292

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 25 commits into
base: main
Choose a base branch
from
Open

feat: support angular@20 #292

wants to merge 25 commits into from

Conversation

pieh
Copy link
Contributor

@pieh pieh commented Apr 11, 2025

Adjustments for Angular@20:

  • newly scaffolded Angular@20 project don't explicitly define outputPath which we rely on, so this adds default fallback for this case (dist/<project-name>) to make it as easy as possible to use Angular@20 on Netlify
  • Adding test fixtures and upgrading demo to use 20 (note that Angular@20 requires node@>=20.11 so I'm skipping tests and test setups below that version - we do have node 20 in test matrix version so we run tests against them. Additionally I do add node@22 to matrix to be have tests on current default)
  • don't suggest Common Engine with Angular@20 (it still works, but App Engine is much better overall, supporting way more features and integrates with dev server and it's no longer Developer Preview/experimental)

@github-actions github-actions bot added the type: chore work needed to keep the product and development running smoothly label Apr 11, 2025
Copy link

netlify bot commented Apr 11, 2025

Deploy Preview for plugin-angular-universal-demo ready!

Name Link
🔨 Latest commit f650742
🔍 Latest deploy log https://app.netlify.com/projects/plugin-angular-universal-demo/deploys/68307de6c990940008a125df
😎 Deploy Preview https://deploy-preview-292--plugin-angular-universal-demo.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

import { appConfig } from './app.config'
import { serverRoutes } from './app.routes.server'

const serverConfig: ApplicationConfig = {
providers: [provideServerRendering(), provideServerRoutesConfig(serverRoutes)],
providers: [provideServerRendering(withRoutes(serverRoutes))],
Copy link
Contributor Author

@pieh pieh Apr 11, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This had to be migrated manually (checked how newly scaffolded project with npx @angular/cli@next new sets things up) as ng update @angular/cli @angular/core --next didn't cover it (initially it resulted in trying to import no longer existing provideServerRoutesConfig function)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should this be called out somewhere that shows up in release notes? This might be relevant to folks upgrading, is that right?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We can also ask the Angular team if this is expected to not be handled

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll check if migration handles that now (this comment was done very early on before there was any rc yet, so maybe something changed) but if it didn't change I'll check with Angular team

Copy link
Contributor Author

@pieh pieh May 21, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So this still happens (diff is what automatic migration with npx @angular/cli@next update @angular/cli @angular/core --next does):
image
And I also don't see a mention of it yet on https://next.angular.dev/update-guide?v=19.0-20.0&l=3 so I'll ask about this

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

update:
Angular 19.1 "renamed" provideServerRoutesConfig to provideServerRouting (keeping previous one for backward compat) so it was somewhat quirk of us scaffolding / migrating really early on

There is currently migration for renamed one, but not for "original" one and angular/angular-cli#30359 is looking to address this

So this will be handled automatically soon

@pieh
Copy link
Contributor Author

pieh commented Apr 11, 2025

Note - test on Node 18 fail because it's unsupported with Angular 20:

$ npm run build

> demo@0.0.0 build
> ng build --verbose

Node.js version v18.19.0 detected.
The Angular CLI requires a minimum Node.js version of v20.11.

Please update your Node.js version or visit https://nodejs.org/ for additional instructions.

Test setup would need adjustment to skip tests using Angular 20 when on not supported Node version to continue testing previous Angular major versions (or maybe drop testing this node version as it's no longer maintained anyway)

node-version: [18.19.0, 20.13.1]
node-version: [18.19.1, 20.13.1]
Copy link
Contributor Author

@pieh pieh May 20, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

see https://github.com/netlify/angular-runtime/actions/runs/15134325612/job/42542439173#step:6:1422 - this is just to get rid of that warning for pre-angular-20 fixtures (it requires adjustment to required checks)

@pieh pieh changed the title test: try 20-next feat: support angular@20 May 20, 2025
@pieh pieh marked this pull request as ready for review May 20, 2025 10:21
@pieh pieh requested a review from a team as a code owner May 20, 2025 10:21
@github-actions github-actions bot added the type: feature code contributing to the implementation of a feature and/or user facing functionality label May 20, 2025
serhalp
serhalp previously approved these changes May 20, 2025
Copy link
Member

@serhalp serhalp left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

demo/.nvmrc Outdated
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: could this use the more standard .node-version?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think I'll remove it altogether and just bump node version in our demo site. This file is somewhat artifact of early (pre-rc) attempts where I didn't want to mess with existing site, but given we are close to merging 🤞 making adjustments on demo site seems fine now

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

removed completely in 9463872 after bumping node version in the project settings

import { appConfig } from './app.config'
import { serverRoutes } from './app.routes.server'

const serverConfig: ApplicationConfig = {
providers: [provideServerRendering(), provideServerRoutesConfig(serverRoutes)],
providers: [provideServerRendering(withRoutes(serverRoutes))],
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should this be called out somewhere that shows up in release notes? This might be relevant to folks upgrading, is that right?

import { appConfig } from './app.config'
import { serverRoutes } from './app.routes.server'

const serverConfig: ApplicationConfig = {
providers: [provideServerRendering(), provideServerRoutesConfig(serverRoutes)],
providers: [provideServerRendering(withRoutes(serverRoutes))],
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We can also ask the Angular team if this is expected to not be handled

Comment on lines +66 to +77
let { outputPath } = workspaceType === 'nx' ? project.targets.build.options : project.architect.build.options

if (!outputPath && workspaceType === 'default') {
// outputPath might not be explicitly defined in angular.json
// so we will try default which is dist/<project-name>
outputPath = join('dist', projectName)
}

const isApplicationBuilder =
workspaceType === 'nx'
? project.targets.build.executor.endsWith(':application')
: project.architect.build.builder.endsWith(':application')
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: do project.targets.build and project.architect.build have the exact same shape? if so, we could do the nx check only one and hold the build object in a variable

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

They don't: build.executor vs build.builder in here.

This code was overall already there before this PR when it was introduced in https://github.com/netlify/angular-runtime/pull/263/files#diff-76ddf06bdc3bb03e611fc684812e5455f0c7bc846aae658cc44f8785a747f6ecL12-R24 - I just moved it because extracting projectName needed for fallback case was messy otherwise

Comment on lines 200 to 203
// Angular 20+ made App Engine stable, so we should not recommend Common Engine anymore
failBuild(
`server.ts doesn't seem to be Netlify compatible and is not known default. Please replace it with Netlify compatible server.ts:\n\n\`\`\`\n${NetlifyServerTsAppEngine}\`\`\``,
)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wonder if this could link to something with more information? maybe just this repo's readme?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added link to this and few other similar messages in dea254f

@pieh
Copy link
Contributor Author

pieh commented May 21, 2025

angular/angular-cli@d06ff3f there will be bump of min node from 20.11 to 20.19 released soon so adjusting checks / node version for test runner in 9463872

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: chore work needed to keep the product and development running smoothly type: feature code contributing to the implementation of a feature and/or user facing functionality
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants