Skip to content

Commit 2a720e8

Browse files
author
Nathan Reid
committed
enable loading of .vue files from npm packages
1 parent 4c45da4 commit 2a720e8

File tree

1 file changed

+13
-2
lines changed

1 file changed

+13
-2
lines changed

packages/vue-component/plugin/vue-compiler.js

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -153,11 +153,22 @@ VueComponentCompiler = class VueCompo extends CachingCompiler {
153153

154154
const { js, templateHash } = generateJs(vueId, inputFile, compileResult)
155155

156+
let outputFilePath = inputFile.getPathInPackage();
157+
// Meteor will error when loading .vue files on the server unless they are postfixed with .js
158+
if (inputFile.getArch().indexOf('os') === 0 && inputFilePath.indexOf('node_modules') !== -1) {
159+
outputFilePath += '.js';
160+
}
161+
162+
// Including the source maps for .vue files from node_modules breaks source mapping.
163+
const sourceMap = inputFilePath.indexOf('node_modules') === -1
164+
? compileResult.map
165+
: undefined;
166+
156167
// Add JS Source file
157168
inputFile.addJavaScript({
158-
path: inputFile.getPathInPackage(),
169+
path: outputFilePath,
159170
data: js,
160-
sourceMap: compileResult.map,
171+
sourceMap: sourceMap,
161172
lazy: false,
162173
});
163174

0 commit comments

Comments
 (0)