Open SebastianKohler opened 3 months ago
This is affecting us as well - SSR cannot render the site.
Same problem
Same problem here.
In addition, building my app catches the error also at compile time:
> ng build my-app --watch
TypeError: o.attachShadow is not a function
at Mu (file:///[redacted]/.angular/prerender-root/d62c222d-bf22-49a2-84e2-4076e9839a1f/chunk-RESHKSIQ.mjs:2:26911)
[...]
EDIT: if helpful, here my stack-trace:
TypeError: elm.attachShadow is not a function
at proxyHostElement ([redacted]\.angular\cache\18.2.9\[redacted]\vite\deps_ssr\@ionic_angular-server.js:1993:15)
at patchElement2 ([redacted]\.angular\cache\18.2.9\[redacted]\vite\deps_ssr\@ionic_angular-server.js:2104:17)
at patchChild2 ([redacted]\.angular\cache\18.2.9\[redacted]\vite\deps_ssr\@ionic_angular-server.js:2110:13)
at patchChild2 ([redacted]\.angular\cache\18.2.9\[redacted]\vite\deps_ssr\@ionic_angular-server.js:2113:15)
at patchChild2 ([redacted]\.angular\cache\18.2.9\[redacted]\vite\deps_ssr\@ionic_angular-server.js:2113:15)
at patchChild2 ([redacted]\.angular\cache\18.2.9\[redacted]\vite\deps_ssr\@ionic_angular-server.js:2113:15)
at patchChild2 ([redacted]\.angular\cache\18.2.9\[redacted]\vite\deps_ssr\@ionic_angular-server.js:2113:15)
at patchChild2 ([redacted]\.angular\cache\18.2.9\[redacted]\vite\deps_ssr\@ionic_angular-server.js:2113:15)
at hydrateApp ([redacted]\.angular\cache\18.2.9\[redacted]\vite\deps_ssr\@ionic_angular-server.js:2144:9)
at hydrateAppClosure ([redacted]\.angular\cache\18.2.9\[redacted]\vite\deps_ssr\@ionic_angular-server.js:30085:5)
Not sure if helpful seems it looks more like a compilation error, but since this happens inside some hydration functions, note that my root app component has host: { ngSkipHydration: 'true' }
.
Same problem for me with the latest ionic version.
Prerequisites
Ionic Framework Version
v8.x
Current Behavior
Since v8.2.4 Ionic components like
ion-button
andion-chip
produce anelm.attachShadow is not a function
TypeError in Angular apps with server side rendering (SSR) enabled.The TypeError did not occur in version 8.2.2 and prior, but in every version since 8.2.4.
Expected Behavior
No TypeError like in v8.2.2 and prior.
Steps to Reproduce
See the code reproduction URL for a minimal app on GitHub showcasing the error (steps to run the app in the README).
The modules-based Angular app was generated with Angular CLI version 18.1.3 with the command:
I then added
@ionic/angular
and@ionic/angular-server
, configured Ionic and switched to Angular’s olderbrowser
builder which I’m using in my actual project (and as far as I know Ionic doesn’t work in Angular standalone SSR apps using the new Vite-basedapplication
builder). See the commit history in the code reproduction repository for a detailed account of the code changes.Once you have the code reproduction app running you will get the TypeError in the terminal.
Code Reproduction URL
https://github.com/SebastianKohler/ionic-angular-ssr-attachShadow-typeError
Ionic Info
I don’t use the Ionic CLI. Here is the info from the Angular CLI:
Additional Information
No response