You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
ng build fails after injecting Keycloak, but ng serve works fine #59837
Which @angular/* package(s) are the source of the bug?
compiler, compiler-cli
Is this a regression?
Yes
Description
I have recently upgraded to Angular 19 and the corresponding keycloak-angular module. After replacing the legacy KeycloakService with Keycloak, ng serve works fine, but ng build failes with an error during AotCompilation: TypeError: Cannot read properties of undefined (reading 'Symbol(patchedReferencedAliases)')
Please find attached our project. I have taken our project and deleted most parts of it, but the bug is still reproducible. I have left some stuff that i could not easily delete. frontend.zip
npm install
npx ng serve # works
npx ng build # error
Please provide a link to a minimal reproduction of the bug
$ npx ng build
Application bundle generation failed. [1.933 seconds]
X [ERROR] Angular compilation emit failed. [plugin angular-compiler]
TypeError: Cannot read properties of undefined (reading 'Symbol(patchedReferencedAliases)')
at loadIsReferencedAliasDeclarationPatch (file:///C:/tmp/frontend/node_modules/@angular/compiler-cli/bundles/chunk-WKHF7UQD.js:1568:49)
at file:///C:/tmp/frontend/node_modules/@angular/compiler-cli/bundles/chunk-WKHF7UQD.js:1623:35
at transformation (C:\tmp\frontend\node_modules\typescript\lib\typescript.js:118855:14)
at transformNodes (C:\tmp\frontend\node_modules\typescript\lib\typescript.js:118863:70)
at Object.transform (C:\tmp\frontend\node_modules\typescript\lib\typescript.js:152762:18)
at AotCompilation.emitAffectedFiles (C:\tmp\frontend\node_modules\@angular\build\src\tools\angular\compilation\aot-compilation.js:272:58)
at emit (C:\tmp\frontend\node_modules\@angular\build\src\tools\angular\compilation\parallel-worker.js:95:37)
at C:\tmp\frontend\node_modules\piscina\dist\worker.js:144:32
Please provide the environment you discovered this bug in (run ng version)
I found a workaround to make the project build again: Replace the constructor-injection of keycloak: Keycloak with property-injection private keycloak: Keycloak = inject(Keycloak) outside of the constructor.
Replace (search for keycloak: Keycloak, 3 locations):
Since property-injection and constructor-injection should conceptionally be the same, I fear this bug might resurface and bite us later, therefore I am not satisfied with this workaround.
@ADegele Same here, I also encountered this problem and have been struggling with it for the last two days. I didn't suspect it was about Keycloak. Thanks for the workaround, you saved me another hours of debugging!
Activity
michalma commentedon Feb 3, 2025
@ADegele Same here, I also encountered this problem and have been struggling with it for the last two days. I didn't suspect it was about Keycloak. Thanks for the workaround, you saved me another hours of debugging!
yeahitsjan commentedon Feb 5, 2025
Same problem here. Sent here from my report in
angular-cli. SettingisolatedModules: falseinside thetsconfig.jsonalso works around the issue.fix(compiler-cli): avoid crash in isolated transform operations (#59869)
fix(compiler-cli): avoid crash in isolated transform operations (angu…
angular-automatic-lock-bot commentedon Mar 16, 2025
This issue has been automatically locked due to inactivity.
Please file a new issue if you are encountering a similar or related problem.
Read more about our automatic conversation locking policy.
This action has been performed automatically by a bot.