2.0.2
https://github.com/MarcoBoffo/vue-test-render-bug
Run the build and check the browser's console log
Blocks should render normally or, at least, give another warn
Vue says the template or render function is not defined
vue.common.js?e881:2611[Vue warn]: Failed to mount component: template or render function not defined.
(found in component <block>)
This is due to the nature of cyclic dependencies in a module system. When DiagramPath imports Block, Block hasn't finished evaluating yet (because it in turn depends on DiagramPath), so it gets an empty object instead.
What you can do is using a dynamic require() to lazy-load Block in DiagramPath:
export default {
beforeCreate () {
this.$options.components.Block = require('./Block.vue')
}
}
Wouldn't it be nice if we just put this note here?
https://vuejs.org/v2/guide/components.html#Recursive-Component
Most helpful comment
This is due to the nature of cyclic dependencies in a module system. When DiagramPath imports Block, Block hasn't finished evaluating yet (because it in turn depends on DiagramPath), so it gets an empty object instead.
What you can do is using a dynamic
require()to lazy-load Block in DiagramPath: