Stencil: Prerender not finding window properties

Created on 23 Aug 2018  Â·  4Comments  Â·  Source: ionic-team/stencil

Stencil version:

@stencil/[email protected]

I'm submitting a:

[x ] bug report
[ ] feature request
[ ] support request => Please do not submit support requests here, use one of these channels: https://stencil-worldwide.herokuapp.com/ or https://forum.ionicframework.com/

Current behavior:

When running npm run build I get lots of error's saying window properties couldn't be found. This only happens in the prerender step.

Expected behavior:

Window properties should be found and no compile error should be thrown.

Steps to reproduce:

Use window properties somewhere the code and try to compile the app with prerender.

Related code:

componentWillLoad() {
    const userId = localStorage.getItem('userId');
}

// adding the window object removes the error.
componentWillLoad() {
    const userId = window.localStorage.getItem('userId');
}

Other information:

Runtime error detected during componentWillLoad(): soli-app
           localStorage is not defined ReferenceError: localStorage is not defined at e.componentWillLoad
           (evalmachine.<anonymous>:2:18409) at update
           (/Users/digo/code/src/gitlab.com/threeaccents/soli/webapp/node_modules/@stencil/core/dist/compiler/index.js:10519:48)
           at plt.queue.tick
           (/Users/digo/code/src/gitlab.com/threeaccents/soli/webapp/node_modules/@stencil/core/dist/compiler/index.js:10477:34)
           at flush
           (/Users/digo/code/src/gitlab.com/threeaccents/soli/webapp/node_modules/@stencil/core/dist/compiler/index.js:11946:33)
           at _combinedTickCallback (internal/process/next_tick.js:131:7) at process._tickCallback
           (internal/process/next_tick.js:180:9)
prerender

All 4 comments

Currently prerendering is getting refactored to use puppeteer, so this issue will be fixed in upcoming releases.

Cool I'm also getting some redux properties errors:

 Runtime error detected during componentWillLoad(): create-grow-view
           Cannot read property 'subscribe' of undefined TypeError: Cannot read property 'subscribe' of undefined at
           Object.mapStateToProps (evalmachine.<anonymous>:3:575) at t.initRedux (evalmachine.<anonymous>:2:17837) at
           t.componentWillLoad (evalmachine.<anonymous>:2:17688) at update
           (/Users/digo/code/src/gitlab.com/threeaccents/soli/webapp/node_modules/@stencil/core/dist/compiler/index.js:10519:48)
           at plt.queue.tick
           (/Users/digo/code/src/gitlab.com/threeaccents/soli/webapp/node_modules/@stencil/core/dist/compiler/index.js:10477:34)
           at flush
           (/Users/digo/code/src/gitlab.com/threeaccents/soli/webapp/node_modules/@stencil/core/dist/compiler/index.js:11946:33)
           at _combinedTickCallback (internal/process/next_tick.js:131:7) at process._tickCallback
           (internal/process/next_tick.js:180:9)

just ran into this with https://github.com/balupton/stencil-ssr-on-zeit-now


didn't puppeteer get canned?

https://github.com/ionic-team/stencil/issues/442


How extensive is the puppeteer plan?

Adopting puppeteer could eliminate serverless (e.g. ziet now, cloudflare works) rendering of stencil components/pages/apps — which will be a growing environment for SSR, due to its cost, scaling, and speed benefits.

Unfortunately for me, I can't adopt stencil until it supports serverless rendering.


Considering SSR is completely broken right now, it would be nice if it this was reflected here:

https://stenciljs.com/docs/prerendering

Stencil one will be able to support window/document usage thanks to V8's VM isolation! where we can execute your app under different context (globals).

Was this page helpful?
0 / 5 - 0 ratings

Related issues

mitchellsimoens picture mitchellsimoens  Â·  3Comments

MatanYadaev picture MatanYadaev  Â·  3Comments

anthonylebrun picture anthonylebrun  Â·  3Comments

ryanmunger picture ryanmunger  Â·  3Comments

bekliev picture bekliev  Â·  3Comments