Skip to content
This repository was archived by the owner on Jan 18, 2022. It is now read-only.

Dynamic import vue components #328

Open
ruipvs opened this issue Feb 10, 2020 · 1 comment
Open

Dynamic import vue components #328

ruipvs opened this issue Feb 10, 2020 · 1 comment
Milestone

Comments

@ruipvs
Copy link

ruipvs commented Feb 10, 2020

Version

5.0.0

Reproduction link

https://codesandbox.io/s/dawn-sea-zsjtn?fontsize=14&hidenavigation=1&theme=dark

Steps to reproduce

Is there a wait to pass on options of Vue.use() the name of components and dynamically import them?
I'm trying it but the normalizeComponent is just applied to imported components as:

import TextImage from '../src/components/modules/TextImage.vue';

let component = Object.values(await import('../src/components/modules/TextImage.vue'))[0];
    if (options.modules) {
      options.modules.map(async moduleName => {
        Vue.component(moduleName, component);
    });
}

What is expected?

Dynamic import of components
Is there a wait to pass on options of Vue.use() the name of components and dynamically import them?

What is actually happening?

getting an error on dependent side that says:
Uncaught SyntaxError: Unexpected token < on template

I'm trying it but the normalizeComponent is just applied to imported components as:

import TextImage from '../src/components/modules/TextImage.vue';

@akauppi
Copy link

akauppi commented Feb 16, 2020

I likely share the same problem.

Some sample code I found has this:

    component: () => import('../views/SignIn.vue')

Up til now, I didn't know why that didn't work in my project - using rollup-plugin-vue (5.1.6). This may be the reason.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants