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 }}
This repository has been archived by the owner on Jun 28, 2024. It is now read-only.
I had some trouble using this library with preactjs/wmr, specifically when I tried to prerender the project.
At first, I didn't understand what went wrong as I had a check for typeof(document) in place before trying to do anything with the imported lifecycle library.
Then I had a look at the source code and realized page-lifecycle's export is a new Lifecycle() instance. In other words, just importing the library causes it execute code and hit a document.visibilityState statement, causing the error in environments that don't have a document object - like preactjs/wmr's prerender step.
Reproduce:
In a preactjs/wmr project, create a component and statically import the page-lifecycle library, then try to build with wmr --prerender
Description
I had some trouble using this library with preactjs/wmr, specifically when I tried to prerender the project.
At first, I didn't understand what went wrong as I had a check for
typeof(document)
in place before trying to do anything with the importedlifecycle
library.Then I had a look at the source code and realized page-lifecycle's export is a
new Lifecycle()
instance. In other words, just importing the library causes it execute code and hit adocument.visibilityState
statement, causing the error in environments that don't have adocument
object - like preactjs/wmr's prerender step.Reproduce:
In a preactjs/wmr project, create a component and statically import the page-lifecycle library, then try to build with
wmr --prerender
(Disclaimer: untested/pseudo code)
Throws an error (sorry for the minified code):
Workaround:
Import
src/Lifecycle.mjs
directly and instantiate the exported class manually:The text was updated successfully, but these errors were encountered: