Repository navigation
chore: Angular 20 upgrade - #20914
Conversation
- 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
…change npm install to npm ci for consistency
…rkflow to prevent spam" This reverts commit 70a994a.
Merge Checks Failed |
| "targets": { | ||
| "build": { | ||
| "executor": "./tools/build-lib:augmented-types", | ||
| "executor": "./tools/build-lib:declaration-merging", |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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') }} |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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 }}- |
There was a problem hiding this comment.
query: is the - sign at the end by purpose?
There was a problem hiding this comment.
Yes, it’s intentional. Restore keys use prefix-matching
Example from GH docs
restore-keys: |
npm-feature-${{ hashFiles('package-lock.json') }}
npm-feature-
npm-| const icons = fixture.debugElement.queryAll(By.css('cx-icon')); | ||
| const infoIcon = icons.find( | ||
| (icon) => icon.componentInstance.type === ICON_TYPE.INFO | ||
| ); | ||
| expect(infoIcon).toBeTruthy(); |
There was a problem hiding this comment.
query: out of curiosity, what was the reason that only this test case stopped working with CommonConfiguratorTestUtilsService ?
There was a problem hiding this comment.
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') |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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); |
There was a problem hiding this comment.
query: does the ng-reflect-router-link not exist anymore?
|
|
||
| it('should not add any custom attributes if none are provided', () => { | ||
| const expectedAttributes = { | ||
| 'ng-reflect-cx-attributes-name-prefix': attributeNamePrefix, |
There was a problem hiding this comment.
query: I see another change in tests related to ng-reflect attributes. Are they all due to the same reason?
| "prefer-const": "off", | ||
| "@angular-eslint/use-lifecycle-interface": "error", | ||
| "@angular-eslint/prefer-standalone": "off", | ||
| "@angular-eslint/prefer-inject": "off", |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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
| "accessibility": "explicit" | ||
| } | ||
| ], | ||
| "@typescript-eslint/no-deprecated": "warn", |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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.
pawelfras
left a comment
There was a problem hiding this comment.
LGTM 🔥
I also performed testing based on CXSPA-11434
Angular 20 Upgrade
Nx migration (all packages and their migrations) ran
npx nx migrate <package>@<version>andnpx 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.3angular-oauth2-oidc→^20.0.2ngx-infinite-scroll→^20.0.0@angular-builders/custom-esbuild→^20.0.0ng-packagr→^20.3.2jest-preset-angular→^15.0.3jest→^30.2.0jest-circus→^30.2.0jest-environment-jsdom→^30.2.0(new package)jest-environment-node→^30.2.0jest-util→^30.2.0ts-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.1nx→^22.1.1zone.js→^0.15.1typescript→^5.9.3express→^5.1.0eslint→^9.28.0@types/node→^22.19.1glob→^11.1.0eslint-plugin-deprecation(incompatible with ESLint 9)Unit tests:
ng-reflect-*attributes (removed in Angular 20 dev mode by default)jest-environment-jsdompackageBuild issues:
<ng-select>component to satisfy 'items' input (#20864)outputToObservableto align with signal outputs used in new ng-selectSchematics: