bug: Ionic / Angular Universal Prerender bugs on slides
See original GitHub issueBug Report
Ionic version:
[x] 5.x
Current behavior:
The SSR prerender does not render properly. There is a problem when importing slider.js
. It seems that the screen object is not defined.
Expected behavior:
It should allow to prerender the html files for the templates that contain ion-select
to be prerendered.
Steps to reproduce:
It happens when running npm run prerender
directly from the @nguniversal/express-engine
schematics and the template has an ion-slides
.
Related code:
A sample application via GitHub https://github.com/rgolea/ionic-ssr-errors
Other information:
This is a continuation of the #21063 since the original issue was fixed.
Ionic info:
Ionic:
Ionic CLI : 6.6.0
Utility:
cordova-res : not installed
native-run (update available: 1.0.0) : 0.3.0
System:
NodeJS : v13.12.0
npm : 6.14.4
OS : macOS Catalina
Errors:
Prerendering 1 route(s) to <path-to-project>/dist/ionic-ssr-errors/browser
TypeError: Cannot read property 'width' of undefined
at Device (<path-to-project>/dist/ionic-ssr-errors/server/main.js:1:3026748)
at hydrateAppClosure (<path-to-project>/dist/ionic-ssr-errors/server/main.js:1:3028625)
at hydrateFactory (<path-to-project>/dist/ionic-ssr-errors/server/main.js:1:3107878)
at render (<path-to-project>/dist/ionic-ssr-errors/server/main.js:1:3128770)
at <path-to-project>/dist/ionic-ssr-errors/server/main.js:1:3133854
at new ZoneAwarePromise (<path-to-project>/dist/ionic-ssr-errors/server/main.js:1:3206236)
at hydrateDocument (<path-to-project>/dist/ionic-ssr-errors/server/main.js:1:3133500)
at <path-to-project>/dist/ionic-ssr-errors/server/main.js:1:1287139
at <path-to-project>/dist/ionic-ssr-errors/server/main.js:1:1212014
at ZoneDelegate.invoke (<path-to-project>/dist/ionic-ssr-errors/server/main.js:1:3194265)
CREATE <path-to-project>/dist/ionic-ssr-errors/browser/index.html (3471 bytes)
The error seems to come from here: https://github.com/ionic-team/ionic/blob/6a167172ffa4802ff68b5ca0690586438f5ed744/core/src/components/slides/swiper/swiper.bundle.js#L2586 The thing is that it seems to be defined:
Issue Analytics
- State:
- Created 3 years ago
- Reactions:1
- Comments:27 (6 by maintainers)
Top GitHub Comments
@liamdebeasi swiper has updated to the latest version. I will test tomorrow and confirm it works.
Yeah, I think you are correct – ssr-window is a dependency of swiper: https://github.com/nolimits4web/swiper/blob/master/package.json#L77. Not sure what the dev’s release process is, but we’ll get the fix into Ionic one way or another.