title: Using Vueify for components with the runtime-only build in Vue.js
body: <p>I've been working on porting a vue.js component from vue 1.0 to Vue 2.0 using Vueify. In the <a href="https://github.com/vuejs/vue/wiki/Vue-2.0-RC-Starter-Resources" rel="nofollow">Starter resources</a> it states:</p>
  
  <blockquote>
    <p>When you use vue-loader or vueify to import *.vue files, their  parts are automatically compiled into render functions. It is therefore recommended to use the runtime-only build with *.vue files.</p>
  </blockquote>
  
  <p>However, this does not appear to be the case. If I have a simple component like:</p>
  
  <pre><code>&lt;template&gt;
      &lt;div&gt;
          {{ msg }}
      &lt;/div&gt;
  &lt;/template&gt;
  
  &lt;script type="text/javascript"&gt;
  export default {
      props: {
          msg: {
              default: "Child Message"
          }
      }
  }
  &lt;/script&gt;
  </code></pre>
  
  <p>And in my <em>main.js</em> file I do:</p>
  
  <pre><code>import Vue from 'vue'
  import MyComponent from './my-component.vue';
  
  Vue.component('my-component', MyComponent);
  
  new Vue({
      el: '#app',
      render: function(createElement) {
          return createElement(MyComponent)
      }
  });
  </code></pre>
  
  <p>Then compile with Gulp using:</p>
  
  <pre><code>browserify('./main.js')
      .transform(vueify)
      .bundle()
      .pipe(fs.createWriteStream("bundle.js"))
  </code></pre>
  
  <p>I cannot do anything at all with the component except get it to render. In fact, it will actually render the component as soon as it finds the div with the id "app":</p>
  
  <pre><code>&lt;div id="app"&gt;
    &lt;!-- my-component renders even though I didn't ask it to --&gt;
  &lt;/div&gt;
  </code></pre>
  
  <p>And any props added to the component are not received, so:</p>
  
  <pre><code>    &lt;div id="app"&gt;
        &lt;!-- 
        Message displays as default "Child Message" rather than "Parent Message". The prop wasn't passed
        --&gt;
        &lt;my-component msg="Parent Message"&gt;&lt;/my-component&gt;
      &lt;/div&gt;
  </code></pre>
  
  <p>Similarly, if I add <code>data</code> to <code>main.js</code>, it's not accessible from the web page:</p>
  
  <pre><code>import Vue from 'vue'
  import MyComponent from './my-component.vue';
  
  Vue.component('my-component', MyComponent);
  
  new Vue({
      el: '#app',
      render: function(createElement) {
          return createElement(MyComponent)
      },
      data() {
          return {
              msg: "Parent Message"
          }
      }
  });
  </code></pre>
  
  <p>in HTML:</p>
  
  <pre><code>&lt;div id="app"&gt;
    {{ msg }} // This will not print
  &lt;/div&gt;
  </code></pre>
  
  <p>And anything inside "#app" doesn't render at all (remember "my-component" is rendered even if I don't add it):</p>
  
  <pre><code>&lt;div id="app"&gt;
    &lt;!-- This doesn't render--&gt;
    &lt;strong&gt;A component &lt;/strong&gt;
    &lt;my-component&gt;&lt;/my-component&gt;
  &lt;/div&gt;
  </code></pre>
  
  <p>So it looks to me like you can render a component, without any control over it, and you cant do anything further with the view model, so is it really the case that I should be using the runtime-only build as suggested?</p>
  
  <p>In the end I've used the standalone build using <a href="https://github.com/benbria/aliasify" rel="nofollow">aliasify</a> and everything works fine, but I'd really like to know what it is I am missing when using <em>vueify</em> with the runtime build. Surely the behavior I'm describing isn't what is supposed to happen, so I can only assume I have misunderstood something somewhere.</p>