SFC template content is ignored when module.exports is a promise #54
Description
First of all, thanks for creating http-vue-loader. It has been a lifesaver in a demo situation.
README.md states that module.exports may be a promise. But when I do that, it looks like the template element in the SFC is ingnored.
Although my use case is more involved, the simplest complete example that replicates this is:
- index.html
<!DOCTYPE html>
<html>
<head>
<script src="https://unpkg.com/vue@2.5.17/dist/vue.js"></script>
<script src="https://unpkg.com/http-vue-loader@1.3.5"></script>
</head>
<body>
<div id="app"></div>
<script>
new Vue({
template: '<my-greeting></my-greeting>',
components: {
'my-greeting': httpVueLoader('my-greeting.vue')
},
mounted: function() {
console.log('Mounted from root')
}
}).$mount('#app')
</script>
</body>
</html>
- my-greeting.vue
<template>
<div>Hello</div>
</template>
<script>
module.exports = Promise.resolve({
mounted: function() {
console.log('Mounted from my-greeting')
}
})
</script>
<style>
</style>
If index.html is viewed in a browser, the following vue warning is displayed in the developer tools console:
Failed to mount component: template or render function not defined. found in ---> <MyGreeting>
.
And when I examine the returned component via httpVueLoader('my-greeting)().then(c => {console.log(c)...})
then indeed it contains no template property.
But if module.exports is a regular object, the example runs without problems and the component passed to the 'then' callback function contains a template property with the content of the template element.
Also when the object, resolved in the promise assigned to module.exports, contains a template property itself, there are no problems (although the value of the template property is used, and not the content of the template elelement).