Skip to content
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

Prerendering with lazy and suspense(Template execution failed: [object Promise]) #1359

Open
RomanistHere opened this issue Aug 1, 2020 · 3 comments
Milestone

Comments

@RomanistHere
Copy link

RomanistHere commented Aug 1, 2020

Hey guys, I want to have structure like this:

App.js:

import { Suspense, lazy } from 'preact/compat'

import Preloader from "../components/Preloader/Preloader"

const Comp1= lazy(() => import('../routes/Comp1/Comp1'))
const Comp2= lazy(() => import('../routes/Comp2/Comp2'))
...

export default () => {
  return (
    <Suspense fallback={<Preloader />}>
      <Router>
        <Route path="/" component={Comp1} />
        <Route path="/comp2" component={Comp2} />

It's simple routing with preloader till any new page load.
dev server and build without prerendering working, but I want to have structure like this prerendered.
If we try to build structure above there is "Template execution failed: [object Promise]" error.

I've tried:
-preact-async-route and AsyncRoute component. Current version asks to use lazy/suspense. With AsyncRoute I was getting errors too.
-"async!" flag in imports - It didn't help much either - there are were errors as well.
-moving pages to "routes" folder doesn't help to split at all - I've got the same size of chunks.

I parsed all documentation I found and still have no clue what would be the "right" way to implement it.

@prateekbh prateekbh added this to the 3.1 milestone Aug 2, 2020
@JoviDeCroock
Copy link
Member

We'll need to include something like preact-ssr-prepass for this to work, this can resolve these promises and load the UI.

@RomanistHere
Copy link
Author

We'll need to include something like preact-ssr-prepass for this to work, this can resolve these promises and load the UI.

Any way I can make it work now?

@liflovs
Copy link

liflovs commented Aug 24, 2021

would be interested in this as well

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

4 participants