preact-cli icon indicating copy to clipboard operation
preact-cli copied to clipboard

Build fails due to "document" reference in component when preloading

Open DaGhostman opened this issue 5 years ago • 1 comments

Do you want to request a feature or report a bug? Bug Report

What is the current behaviour? Not possible to do a successful preact build when using preact-async-route for code splitting due to:

× ERROR ReferenceError: document is not defined

Gist with full log

If the current behaviour is a bug, please provide the steps to reproduce.

TL;DR sample repo

  1. Create a new application through CLI
  2. Pick typescript (I am not 100% sure this is relevant in some way?)
  3. Install preact-async-route
  4. Update at least 1 route to use Route from async-route package and use the getComponent prop
  5. Run preact build

What is the expected behaviour? The build to complete successfully and produce all of the expected files

Please mention other relevant information.

Please paste the results of preact info here.

Environment Info:
  System:
    OS: Windows 10 10.0.19041
    CPU: (8) x64 Intel(R) Core(TM) i7-7700HQ CPU @ 2.80GHz
  Binaries:
    Node: 10.14.1 - E:\nodejs\node.EXE
    Yarn: 1.17.3 - ~\AppData\Roaming\npm\yarn.CMD
    npm: 6.11.3 - E:\nodejs\npm.CMD
  Browsers:
    Edge: 44.19041.1.0
  npmPackages:
    preact: ^10.3.1 => 10.3.4 
    preact-cli: ^3.0.0-next.19 => 3.0.0-rc.10 
    preact-render-to-string: ^5.1.4 => 5.1.4 
    preact-router: ^3.2.1 => 3.2.1

DaGhostman avatar Mar 25 '20 20:03 DaGhostman

https://github.com/prateekbh/preact-async-route#deprecation-notice

preact-async-route is not supported for preact X. Use Suspense/Lazy instead

prateekbh avatar Mar 25 '20 20:03 prateekbh