How it works...

The official Webpack template contains the configuration rule to never compile files inside the node_modules directory. This means that authors of web components are encouraged to distribute an already compiled file because otherwise users will import raw JavaScript files (since Webpack won't compile them) in their projects, causing all sorts of errors in browsers. Personally, I don't think this is good engineering. One problem with this setup is that since the files you are importing in your project are compiled against one version of Vue, the component might not work (this actually happened in the past) if you use a newer version of Vue.

A better approach is to import the raw files and components and let Webpack compile ...

Get Vue.js 2 Cookbook now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.