vue: Cannot add property _Ctor, object is not extensible

Version

2.6.11

Reproduction link

https://github.com/mjmnagy/error-sept-10-2020

Steps to reproduce

  1. npm run rollup:inline
  2. Include the package into a nuxt project (I have been doing it internally by replacing the dist folder in node_modules)
  3. npm run dev
  4. Error Cannot add property _Ctor, object is not extensible

What is expected?

  1. Attempting to create a component library that has SSR support

What is actually happening?

Cannot add property _Ctor, object is not extensible


The package has additional components and i have gone through one by one and tried to eliminate other factors. It seems that when l refresh the page, the error is present but when navigating the components it works.

About this issue

  • Original URL
  • State: closed
  • Created 6 years ago
  • Comments: 19 (1 by maintainers)

Most upvoted comments

@mjmnagy could you fix the error?

Yes

changed:

components:{
  MyComp:() => import('...')
}

to

import MyComp from '....';

components:{
 MyComp
}

A: () => import('@/components/A.vue').then(d => d.default) Great, it’s really work for me

Hi,

Due to a circle dependancy that I need to break with inline import, I had been the same issue.

A:() => async () => (await import('@/components/A.vue')).default, doesn’t work for me.

but I’ve resolve it with:

A: () => import('@/components/A.vue').then(d => d.default)

HTH

A: () => import('@/components/A.vue').then(d => d.default) Great, it’s really work for me Thank, you are great

@mjmnagy sorry that it was not clearly explained. What I mean is circular references between components.

I have e.g. three components A (parent), B (child) and C (grandchild). However, C uses also A. If I use your solution, circular reference problem will occur. However, I found a way how to solve it in Vue and Rollup bundle.

I change the code in C.vue component from

// C.vue
...
components: {
  A:() => import('@/components/A.vue')
},
...

to

// C.vue
...
components: {
  A:() => async () => (await import('@/components/A.vue')).default,
},
...

I am not really sure, why it does work, but I think that in this way Rollup understand the reference between components easier. I hope it can help someone.

Hi, thanks for your interest but Github issues are for bug reports and feature requests only. You can ask questions on the forum, the Discord server or StackOverflow.


When reporting a bug make sure to remove any external dependencies. Unfortunately, there is too much there for us to check it.