From b0621f9ae1f611c3573bf901a5dba52fa12b22fc Mon Sep 17 00:00:00 2001 From: Evan You Date: Sat, 18 Jun 2016 22:24:04 -0400 Subject: [PATCH] pad output --- lib/compiler.js | 6 +++--- lib/compilers/babel.js | 1 + 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/lib/compiler.js b/lib/compiler.js index 2b26766..6206803 100644 --- a/lib/compiler.js +++ b/lib/compiler.js @@ -63,7 +63,7 @@ compiler.compile = function (content, filePath, cb) { // generate css scope id var id = 'data-v-' + genId(filePath) // parse the component into parts - var parts = vueCompiler.parseComponent(content) + var parts = vueCompiler.parseComponent(content, { pad: true }) // check for scoped style nodes var hasScopedStyle = parts.styles.some(function (style) { @@ -175,7 +175,6 @@ compiler.compile = function (content, filePath, cb) { var inMap = resolvedParts.map var inMapConsumer = inMap && new sourceMap.SourceMapConsumer(inMap) var generatedOffset = (output ? output.split(splitRE).length : 0) + 1 - var originalOffset = content.slice(0, parts.script.start).split(splitRE).length - 1 script.split(splitRE).forEach(function (line, index) { var ln = index + 1 var originalLine = inMapConsumer @@ -192,7 +191,7 @@ compiler.compile = function (content, filePath, cb) { column: 0 }, original: { - line: originalLine + originalOffset, + line: originalLine, column: 0 } }) @@ -241,6 +240,7 @@ function processStyle (part, filePath, id, parts) { var style = getContent(part, filePath) return compileAsPromise('style', style, part.lang, filePath) .then(function (res) { + res = res.trim() return rewriteStyle(id, res, part.scoped, options).then(function (res) { parts.styles.push(res) }) diff --git a/lib/compilers/babel.js b/lib/compilers/babel.js index 57a676b..d999bfa 100644 --- a/lib/compilers/babel.js +++ b/lib/compilers/babel.js @@ -40,6 +40,7 @@ module.exports = function (raw, cb, compiler, filePath) { try { var babel = require('babel-core') var options = assign({ + comments: false, filename: filePath, sourceMaps: compiler.options.sourceMap }, compiler.options.babel || babelOptions)