I am facing an issue with my Vue.js library that I included in a Nuxt.js project. The problem is that there are duplicate instances of Vue.js being created from both the Nuxt instance and the library, which is causing various issues:
https://i.sstatic.net/13pOH.png
It's printing twice from two different instances, and I need to ensure only one instance is used.
How can I resolve this and make sure only one instance is utilized? This duplication is leading to errors.
Here are the steps I have already taken:
- The webpack configuration of the library specifies 'vue' as an external dependency. (I'm puzzled how it still dynamically imports despite being marked as external in the library)
- 'vue' is set as a peerDependency in the package.json file of the library.
Additional details:
- The library is linked in the Nuxt project using npm link
- This issue results in errors such as '$attrs is readonly.'
- This occurs only in development; production builds work without any errors.
- The first instance is from webpack:///./node_modules/vue/dist/vue.runtime.esm.js?2b0e (Nuxt.js), while the second instance is from webpack-internal:///../minerva/node_modules/vue/dist/vue.runtime.esm.js (the library).
The library exports a component and has the following webpack configuration:
[Code snippet omitted for brevity]
It is imported and used in the Nuxt project as follows:
[Code snippet omitted for brevity]
Your assistance in resolving this issue would be greatly appreciated. Thank you!