diff --git a/packages/vue-component/plugin/vue-compiler.js b/packages/vue-component/plugin/vue-compiler.js index 017df94..a3b5e7a 100644 --- a/packages/vue-component/plugin/vue-compiler.js +++ b/packages/vue-component/plugin/vue-compiler.js @@ -153,11 +153,22 @@ VueComponentCompiler = class VueCompo extends CachingCompiler { const { js, templateHash } = generateJs(vueId, inputFile, compileResult) + let outputFilePath = inputFile.getPathInPackage(); + // Meteor will error when loading .vue files on the server unless they are postfixed with .js + if (inputFile.getArch().indexOf('os') === 0 && inputFilePath.indexOf('node_modules') !== -1) { + outputFilePath += '.js'; + } + + // Including the source maps for .vue files from node_modules breaks source mapping. + const sourceMap = inputFilePath.indexOf('node_modules') === -1 + ? compileResult.map + : undefined; + // Add JS Source file inputFile.addJavaScript({ - path: inputFile.getPathInPackage(), + path: outputFilePath, data: js, - sourceMap: compileResult.map, + sourceMap: sourceMap, lazy: false, }); @@ -610,7 +621,7 @@ function generateJs (vueId, inputFile, compileResult, isHotReload = false) { js += `__vue_options__.packageName = '${inputFile.getPackageName()}';`; // Export - js += `module.export('default', exports.default = __vue_script__);`; + js += `module.export('default', exports.default = __vue_script__);exports.__esModule = true;`; if (!isHotReload) { // Hot-reloading