vue-loader: Failed to mount component: template or render function not defined. (found in component

I’m making a Vue 2 component. But when I npm link it in other project and import it, I’m seeing this:

Failed to mount component: template or render function not defined. (found in component <input-tag>)

Here is my repo: https://github.com/matiastucci/vue-input-tag/tree/wtf and this is my webpack.prod.conf.js

Also, I saw some answers saying that I need a vue alias pointing to dist and I already have it.

I didn’t want to create an issue here but I’ve already posted in the Vue slack and forum and in SO but I still don’t know what’s going on. Maybe here someone can help me 😃

Thanks!

About this issue

  • Original URL
  • State: closed
  • Created 8 years ago
  • Reactions: 1
  • Comments: 24 (11 by maintainers)

Most upvoted comments

Hey, so I started looking into this. I think I found the reason that it breaks, but don’t know the solution yet.

So it has nothing to do with npm link, as was to be exüected.

  • The build process somehow adds “use strict” to every module (it activates Javascript’s “strict mode”).
  • in strict mode, you cannot do/use somethings. Among those: the with keyword.
  • Vue uses that for its render functions though.

Suspect 1: Webpack. Webpack 2 does add strict mode when you use import instead of require() (which is according to ES-Modules’ spec, so no blame), but 1.) you used Webpack 1, and 2.) changing all imports to require (including in my other test project to which I npm-link’ed your repo).

Suspect 2: Babel. Babel’s transform-es2015-modules-commonjs plugin, which is part of the es2015 babel preset, adds strict mode. But according to its docs, we should be able to dectivate strict mode:

["transform-es2015-modules-commonjs", {
      "strict": false,
    }]

But that didn’t work so far. Still digging, stay tuned.

Btw importing the .vue file directly works fine. So it’s something in the build chain that’s screwing up.

Btw the problem with with is known and in the works: vuejs/vue#4115

Sorry, haven’t had access to my dev machine this weekend, family affairs. Hope to get it done tomorrow evening.