Skip to content

chore: Angular 20 upgrade - #20914

Merged
sdrozdsap merged 58 commits into
develop-next-majorfrom
epic/angular-20-upgrade
Dec 5, 2025
Merged

sdrozdsap merged 58 commits into
develop-next-majorfrom
epic/angular-20-upgrade

Conversation

@sdrozdsap

@sdrozdsap sdrozdsap commented Nov 27, 2025 •

Copy link
Copy Markdown
Contributor

Angular 20 Upgrade

Nx migration (all packages and their migrations) ran npx nx migrate <package>@<version> and npx nx migrate --run-migrations (run packages' migrations, all except optional ones like control-flow-migration).

Bumped packages:

  • @angular/core → ^20.3.9
  • @angular/animations → ^20.3.9
  • @angular/common → ^20.3.9
  • @angular/compiler → ^20.3.9
  • @angular/forms → ^20.3.9
  • @angular/platform-browser → ^20.3.9
  • @angular/platform-browser-dynamic → ^20.3.9
  • @angular/platform-server → ^20.3.9
  • @angular/router → ^20.3.9
  • @angular/service-worker → ^20.3.9
  • @angular/cli → ^20.3.9
  • @angular/compiler-cli → ^20.3.9
  • @angular/language-service → ^20.3.9
  • @angular/ssr → ^20.3.9
  • @angular/pwa → ^20.3.9
  • @angular/build → ^20.3.9 (new package)
  • @angular-devkit/build-angular → ^20.3.9
  • @angular-devkit/core → ^20.3.9
  • @angular-devkit/schematics → ^20.3.9
  • @schematics/angular → ^20.3.9
  • @ngrx/effects → ^20.1.0
  • @ngrx/operators → ^20.1.0
  • @ngrx/router-store → ^20.1.0
  • @ngrx/store → ^20.1.0
  • @ngrx/store-devtools → ^20.1.0
  • @angular-eslint/builder → ^20.7.0
  • @angular-eslint/eslint-plugin → ^20.7.0
  • @angular-eslint/eslint-plugin-template → ^20.7.0
  • @angular-eslint/schematics → ^20.7.0
  • @angular-eslint/template-parser → ^20.7.0
  • @angular-eslint/test-utils → ^20.7.0
  • @angular-eslint/utils → ^20.7.0
  • @ng-select/ng-select → ^20.4.3
  • angular-oauth2-oidc → ^20.0.2
  • ngx-infinite-scroll → ^20.0.0
  • @angular-builders/custom-esbuild → ^20.0.0
  • ng-packagr → ^20.3.2
  • jest-preset-angular → ^15.0.3
  • jest → ^30.2.0
  • jest-circus → ^30.2.0
  • jest-environment-jsdom → ^30.2.0 (new package)
  • jest-environment-node → ^30.2.0
  • jest-util → ^30.2.0
  • ts-jest → ^29.4.5
  • @nx/angular → ^22.1.1
  • @nx/devkit → ^22.1.1
  • @nx/eslint-plugin → ^22.1.1
  • @nx/jest → ^22.1.1
  • @nx/workspace → ^22.1.1
  • nx → ^22.1.1
  • zone.js → ^0.15.1
  • typescript → ^5.9.3
  • express → ^5.1.0
  • eslint → ^9.28.0
  • @types/node → ^22.19.1
  • glob → ^11.1.0
  • Removed eslint-plugin-deprecation (incompatible with ESLint 9)

Unit tests:

  • Refactored tests to avoid relying on ng-reflect-* attributes (removed in Angular 20 dev mode by default)
  • Updated snapshots containing Angular version references
  • Upgraded Jest and related packages to v30
  • Added jest-environment-jsdom package
  • Applied changes due to Jest API changes
  • Fixed tests across multiple libraries (organization, quote, product, cds, pickup-in-store, product-configurator, storefrontlib, storefinder)

Build issues:

Schematics:

sdrozdsap and others added 30 commits November 25, 2025 14:23
- in ng-select@20 ariaLabelDropdown has been changed to input signal
- used SIGNAL symbol to get access to change value of the input signal
- known problem: Support for setting Input Signals programmatically given a directive instance angular/angular#54782
@sdrozdsap
sdrozdsap marked this pull request as ready for review November 27, 2025 15:32
@github-actions

Copy link
Copy Markdown
Contributor

Merge Checks Failed

Please push a commit to re-trigger the build.
To push an empty commit you can use `git commit --allow-empty -m "Trigger Build"`

@SAP SAP deleted a comment from github-actions Bot Nov 28, 2025
@github-actions
github-actions Bot marked this pull request as draft November 28, 2025 07:11
@sdrozdsap
sdrozdsap marked this pull request as ready for review November 28, 2025 07:11
"targets": {
"build": {
"executor": "./tools/build-lib:augmented-types",
"executor": "./tools/build-lib:declaration-merging",

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

nitpick: Recently was released the new version of rollup-plugin-dts and it contains a fox for the bug because ow which we introduced new custom builder. The 6.3.0 version is in range of versions supported by the ng-packagr.
Let's update version of this peer dependency and verify if we can use ng-packagr builder directly.
Let's do it in a separate PR - leaving comment just for reference.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I've created this Jira ticket for tracking any post-merge tasks and included this comment in the description

~/.cache/Cypress
key: nodemodules-${{ inputs.cache-key }}
restore-keys: nodemodules-${{ inputs.cache-key }}
key: nodemodules-${{ inputs.cache-key }}-${{ hashFiles('**/package-lock.json') }}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

query: Could you help me understand what was the exact reason of changing that? I'm wondering how was it working before vs now and why it was not needed in previous version.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Previously the cache key didn’t include the package-lock.json hash, so for a given cache-key (in our case PR base SHA) we always restored the same node_modules even when dependencies changed. That caused stale installs and skipped npm install, whenever we would adjust packages in the scope of same PR. I found out about it because I had an issue in the build job, that TS couldn't find DOCUMENT exported from @angular/core, because it started exporting it in v20, however old version of angular was being used

By adding hashFiles('**/package-lock.json'), the cache now invalidates correctly whenever dependencies change. And with this my issue got resolved

Example from GH docs

restore-keys: |
  npm-feature-${{ hashFiles('package-lock.json') }}
  npm-feature-
  npm-```

key: nodemodules-${{ inputs.cache-key }}
restore-keys: nodemodules-${{ inputs.cache-key }}
key: nodemodules-${{ inputs.cache-key }}-${{ hashFiles('**/package-lock.json') }}
restore-keys: nodemodules-${{ inputs.cache-key }}-

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

query: is the - sign at the end by purpose?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Yes, it’s intentional. Restore keys use prefix-matching

Example from GH docs

restore-keys: |
  npm-feature-${{ hashFiles('package-lock.json') }}
  npm-feature-
  npm-

Comment on lines +195 to +199
const icons = fixture.debugElement.queryAll(By.css('cx-icon'));
const infoIcon = icons.find(
(icon) => icon.componentInstance.type === ICON_TYPE.INFO
);
expect(infoIcon).toBeTruthy();

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

query: out of curiosity, what was the reason that only this test case stopped working with CommonConfiguratorTestUtilsService ?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

The problem actually is not with CommonConfiguratorTestUtilsService, rather with the same ng-reflect-* issue(see #20914 (comment)). Since we no longer can use it, I had to find elements with icon type INFO by using separate query

const infoButton = fixture.debugElement.query(
By.css('button[ng-reflect-cx-popover]')
).nativeElement;
By.css('.title h3 button cx-icon')

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

query: could you help me understand why the change was required?

I noticed there are more similar changes in files with unit tests and I assume the reason was the same for all of them.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

According to Angular upgrade to 20 guide

Refactor application and test code to avoid relying on ng-reflect-* attributes. If needed temporarily for migration, use provideNgReflectAttributes() from @angular/core in bootstrap providers to re-enable them in dev mode only.

Since we no longer have ng-reflect-* attributes I had to refactor several test cases to not rely on it

.find((el) => el.nativeElement.innerText === displayName).nativeElement;
.find((el) => el.nativeElement.innerText === displayName)?.nativeElement;
expect(link.getAttribute('href')).toEqual(`/${encodedName}`);
expect(link.getAttribute('ng-reflect-router-link')).toEqual(name);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

query: does the ng-reflect-router-link not exist anymore?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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


it('should not add any custom attributes if none are provided', () => {
const expectedAttributes = {
'ng-reflect-cx-attributes-name-prefix': attributeNamePrefix,

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

query: I see another change in tests related to ng-reflect attributes. Are they all due to the same reason?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Comment thread .eslintrc.json
"prefer-const": "off",
"@angular-eslint/use-lifecycle-interface": "error",
"@angular-eslint/prefer-standalone": "off",
"@angular-eslint/prefer-inject": "off",

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

query: Is this rule now enabled by default?
In general, we'd like to use inject() in a new code, but I'm aware it might be difficult/impossible to keep both - "error" for new code and "off" for the existing one.
Leaving this comment just for a reference, no action required.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Is this rule now enabled by default?

Yes it is. I can set it to any value we want, but considering that we already are in progress of migrating to inject as part of one of the spikes scope, I think we should be okay with not having this lint rule enabled

Comment thread .eslintrc.json
"accessibility": "explicit"
}
],
"@typescript-eslint/no-deprecated": "warn",

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

query: If I'm not mistaken, you mentioned that in a sense, this rule is more strict. Were any other code changes required as a result of this change?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Good question! There are indeed much more lint warnings due to this change, however I didn't address them, as they are just warnings(especially considering that we didn't have them before). Some of them might be easy to fix, but for some cases more advanced refactor might be needed. And this felt like out of the upgrade scope. Please let me know if you think any further actions should be taken in this direction

Comment thread migrations.json Outdated

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

minor: W could remove this file because it is no longer needed. If any migrations pops up during Angular 21 upgrade, new file will be generated.

@github-actions
github-actions Bot marked this pull request as draft December 2, 2025 14:31
@SAP SAP deleted a comment from github-actions Bot Dec 3, 2025
@SAP SAP deleted a comment from github-actions Bot Dec 3, 2025
@SAP SAP deleted a comment from github-actions Bot Dec 3, 2025
@sdrozdsap
sdrozdsap marked this pull request as ready for review December 3, 2025 12:38
@sdrozdsap
sdrozdsap requested a review from pawelfras December 3, 2025 12:38

@pawelfras pawelfras left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

LGTM 🔥
I also performed testing based on CXSPA-11434

@sdrozdsap
sdrozdsap merged commit 2f63235 into develop-next-major Dec 5, 2025
@sdrozdsap
sdrozdsap deleted the epic/angular-20-upgrade branch December 5, 2025 14:02

This branch was previously deployed

1 inactive deployment
dev — f5c00ba5 Deployed Dec 3, 2025 by sdrozdsap
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants