Skip to content

ionic 4 server side rendering erro #3280

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
guzuomuse opened this issue Jun 3, 2018 · 2 comments
Closed

ionic 4 server side rendering erro #3280

guzuomuse opened this issue Jun 3, 2018 · 2 comments

Comments

@guzuomuse
Copy link

guzuomuse commented Jun 3, 2018

Bug Report

Ionic Info
Run ionic info from a terminal/cmd prompt and paste the output below.

 @ionic/cli-utils  : 2.0.0-rc.6
   ionic (Ionic CLI) : 4.0.0-rc.6

local packages:

   @angular-devkit/core       : 0.6.0
   @angular-devkit/schematics : 0.6.0
   @angular/cli               : 6.0.1
   @ionic/schematics-angular  : 1.0.0-rc.6
   Ionic Framework            : @ionic/angular 4.0.0-alpha.7
System:

   NodeJS : v8.9.4
   npm    : 5.6.0
   OS     : Windows 10

Describe the Bug
angular 6+ app using ionic. server side rendering error:

document.addEventListener('deviceready', function () {
    ^

ReferenceError: document is not defined
    at checkReady (D:\www\ionic\v4\test5\www\server.js:140566:5)
    at Object.<anonymous> (D:\www\ionic\v4\test5\www\server.js:140548:62)
    at __webpack_require__ (D:\www\ionic\v4\test5\www\server.js:29:30)
    at Object.<anonymous> (D:\www\ionic\v4\test5\www\server.js:140458:76)
    at __webpack_require__ (D:\www\ionic\v4\test5\www\server.js:29:30)
    at Object.@ionic-native/splash-screen/ngx (D:\www\ionic\v4\test5\www\server.js:128188:18)
    at __webpack_require__ (D:\www\ionic\v4\test5\www\server.js:127618:30)
    at Object../src/app/app.component.ts (D:\www\ionic\v4\test5\www\server.js:127749:13)
    at __webpack_require__ (D:\www\ionic\v4\test5\www\server.js:127618:30)
    at Object../src/app/app.server.module.ngfactory.js (D:\www\ionic\v4\test5\www\server.js:127809:10)

after some research, i found that the reason is that using ionic-native.
for example :
import { SplashScreen } from '@ionic-native/splash-screen/ngx'; import { StatusBar } from '@ionic-native/status-bar/ngx';
so maybe we must detect the isplatformbrowser("browser") and is platformserver('server') must be used in somewhere , how we do something like this?
thanks

@ionitron-bot ionitron-bot bot added the triage label Jun 3, 2018
@guzuomuse
Copy link
Author

guzuomuse commented Jun 3, 2018

i have remove some code from app.module.ts and then i can make node www/server run.
but still give some error:

ReferenceError: window is not defined

i know it's the same reason as

ReferenceError: document is not defined

cuase serve side not support window,document...etc.

@imhoffd
Copy link
Contributor

imhoffd commented Jun 4, 2018

@guzuomuse We don't fully support SSR yet

Let's track it here: ionic-team/ionic-framework#14574

@imhoffd imhoffd closed this as completed Jun 4, 2018
@imhoffd imhoffd removed the triage label Jun 4, 2018
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

No branches or pull requests

2 participants