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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error: "regeneratorRuntime is not defined" with Import Wrappers #21

Closed
Al-Rozhkov opened this issue May 15, 2019 · 11 comments
Closed

Error: "regeneratorRuntime is not defined" with Import Wrappers #21

Al-Rozhkov opened this issue May 15, 2019 · 11 comments
Assignees

Comments

@Al-Rozhkov
Copy link

First of all thank you for this project! Feels like must have for every vue based SSG. 馃憤

I tried vue-lazy-hydration with Gridsome. There is pretty large block of "static" markup without reactive data. Looks like perfect case for ssr-only property. It works perfectly with <LazyHydrate ssr-only> component, but when I tried Import Wrappers I got an error:

ReferenceError: regeneratorRuntime is not defined
    at resolvableComponentFactory (LazyHydrate.esm.js?8416:109)
    at hydrateSsrOnly

Chrome and Firefox, Vue 2.6.10

Here is my code:

<template>
  <Layout>
    <main class="block">
      <front-hero />
      <front-news />
      <catalog-block />
      <front-advantages />
    </main>

    <section class="services-wrapper">
      <div class="block">
        <front-services />
      </div>
    </section>
  </Layout>
</template>

<script>
import { hydrateSsrOnly } from 'vue-lazy-hydration'

export default {
  components: {
    FrontHero: hydrateSsrOnly(
      () => import('~/components/blocks/FrontHero.vue')
    ),
    FrontAdvantages: hydrateSsrOnly(
      () => import('~/components/blocks/FrontAdvantages.vue')
    ),
    FrontServices: hydrateSsrOnly(
      () => import('~/components/blocks/FrontServices.vue')
    ),
    FrontNews: hydrateSsrOnly(
      () => import('~/components/blocks/FrontNews.vue')
    ),
    CatalogBlock: hydrateSsrOnly(
      () => import('~/components/blocks/CatalogBlock.vue')
    )
  }
}
</script>
@maoberlehner
Copy link
Owner

maoberlehner commented May 15, 2019

Can you try to use relative imports instead of ~? Eg. import('../components/blocks/FrontHero.vue')

If this still doesn't work a reproduction CodeSandbox would be great! Thx!

@Al-Rozhkov
Copy link
Author

Nope, still no luck with relative imports.

I need more time to strip out unrelated stuff and provide CodeSandbox.

@maoberlehner
Copy link
Owner

Maybe you can try to do a regular dynamic import FrontHero: () => import('~/components/blocks/FrontHero.vue') if that doesn't work either, the Babel config in use is nut suited for handling dynamic imports.

@Al-Rozhkov
Copy link
Author

Here is CodeSandbox: https://codesandbox.io/s/gridsomelazyhydration-3deeh

I'm really bad at Babel and Webpack yet. Any clue would be much appreciated.

@maoberlehner
Copy link
Owner

Thanks for the CodeSandbox link. Unfortunately it does not work for me.
Have you already tried using a dynamic import without this package: FrontHero: () => import('~/components/blocks/FrontHero.vue') Does this work?

@Al-Rozhkov
Copy link
Author

Yes, regular async component injection works:

components: {
    AnotherStaticBlock: () => import('~/components/AnotherStaticBlock.vue')
  }

Import Wrapper doesn't.

I also have public repo for this example. It would be great if you could look at it. Thank you!

@LuXDAmore
Copy link

I have the same problem, with Nuxt@2.7.1 and Vue@2.6.10

@maoberlehner
Copy link
Owner

@LuXDAmore please provide a reproduction link. I just tested it: fresh install with latest version of create-nuxt-app and latest version of vue-lazy-hydration does work.

@maoberlehner
Copy link
Owner

I found a solution to this. The problem has to do with Babel not including all polyfills by default. So a freshly installed Nuxt.js seems to have all necessary polyfills but Gridsome (and maybe Nuxt.js with customized Babel settings) does not.

I'll release a new version the next couple of days.

@LuXDAmore
Copy link

Thank You @maoberlehner ,

I have this configuration in my project. DOCS

Hope this helps. 馃槃

@mercs600
Copy link

mercs600 commented Sep 4, 2019

@maoberlehner I have to reopen this issue, because I would like to know how can I use with async component factory https://vuejs.org/v2/guide/components-dynamic-async.html#Handling-Loading-State ? Like @Al-Rozhkov wrote, the regular async component injection works, but with this wrapper not.

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