I have a Vue.js application (m4ops), and am developing a public Vue.js package (vfg-display-fields) to be part of it. As it is a tree structure, the package has a pair of components which are circular references. I have resolved this using the methods in the Vue.js Guide.
Within my vfg-display-fields package this works well using either method. When I publish the package and import it into my main m4ops package it also works fine using either method.
The problem comes when I try to showcase the package within a CodeSandbox (see https://codesandbox.io/s/ykpj1jpxvv).
With the first suggested method I use
beforeCreate() {
this.$options.components['vfg-display-fields'] = require('./DisplayFields.vue').default;
},
and in CodeSandbox I get the error:
[Vue warn]: Unknown custom element: <vfg-display-fields> - did you register the component correctly? For recursive components, make sure to provide the "name" option.
Using the second method
components: {
'vfg-display-fields': () => import('./DisplayFields.vue'),
},
I get the error
proxyConsole.js:72 [Vue warn]: Failed to resolve async component: function vfgDisplayFields() {
return _promise.default.resolve().then(function () {
return require("".concat(function () {
return require('./DisplayFields.vue');
}));
});
}
Reason: DependencyNotFoundError: Could not find dependency: 'function () {
return require('.' relative to '/node_modules/vfg-display-fields/src/DisplayGroups.vue'
This is only my first package and I am feirly new to Vue.js. My package seems to work fine in its intended location (my m4ops application) but not within CodeSandbox. Is this my error or something within CodeSandbox?