Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings
This repository was archived by the owner on Jan 25, 2024. It is now read-only.
This repository was archived by the owner on Jan 25, 2024. It is now read-only.

SFC template content is ignored when module.exports is a promise #54

Copy link
Copy link
Closed
@ronaldborman

Description

@ronaldborman
Issue body actions

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).

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      Morty Proxy This is a proxified and sanitized view of the page, visit original site.