Skip to content

Dynamic import of native ES modules for async components causes error #6751

Closed
@anthonygore

Description

Version

2.4.4

Reproduction link

https://github.com/anthonygore/vue-dynamic-import

Steps to reproduce

Must use a browser where dynamic module import is supported e.g. the latest Safari or Chrome Canary.

What is expected?

Async component should load and auto-resolve module

What is actually happening?

Uncaught error "Cannot add property _Ctor, object is not extensible".


As of v2.4.0, ES modules are auto-resolved when used as dynamic components e.g.

new Vue({
  el: '#app',
  components: {
    MyComponent: () => import('./MyComponent.js')
  }
});

However, this only works if the module has been transpiled from ES to CommonJS since it checks for the flag __esModule. It does not work for native ES modules where the flag is not present.

If you agree, I could easy put in a PR to remove the check for comp.__esModule on line 15 of resolve-async-component.js, which would solve the issue

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions