Skip to content

Commit

Permalink
feat(compiler): Disable outputSourceRange in production env
Browse files Browse the repository at this point in the history
  • Loading branch information
gzzhanghao committed Nov 28, 2017
1 parent 5991522 commit facacc1
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 8 deletions.
2 changes: 1 addition & 1 deletion src/compiler/create-compiler.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ export function createCompilerCreator (baseCompile: Function): Function {
}

if (options) {
if (options.outputSourceRange) {
if (process.env.NODE_ENV !== 'production' && options.outputSourceRange) {
// $flow-disable-line
const leadingSpaceLength = template.match(/^\s*/)[0].length

Expand Down
2 changes: 1 addition & 1 deletion src/compiler/parser/html-parser.js
Original file line number Diff line number Diff line change
Expand Up @@ -245,7 +245,7 @@ export function parseHTML (html, options) {
name: args[1],
value: decodeAttr(value, shouldDecodeNewlines)
}
if (options.outputSourceRange) {
if (process.env.NODE_ENV !== 'production' && options.outputSourceRange) {
attrs[i].start = args.start + args[0].match(/^\s*/).length
attrs[i].end = args.end
}
Expand Down
8 changes: 4 additions & 4 deletions src/compiler/parser/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ export function parse (
element.ns = ns
}

if (options.outputSourceRange) {
if (process.env.NODE_ENV !== 'production' && options.outputSourceRange) {
element.start = start
element.rawAttrsMap = element.attrsList.reduce((cumulated, attr) => {
cumulated[attr.name] = attr
Expand Down Expand Up @@ -244,7 +244,7 @@ export function parse (
// pop stack
stack.length -= 1
currentParent = stack[stack.length - 1]
if (options.outputSourceRange) {
if (process.env.NODE_ENV !== 'production' && options.outputSourceRange) {
element.end = end
}
endPre(element)
Expand Down Expand Up @@ -296,7 +296,7 @@ export function parse (
}
}
if (child) {
if (options.outputSourceRange) {
if (process.env.NODE_ENV !== 'production' && options.outputSourceRange) {
child.start = start
child.end = end
}
Expand All @@ -310,7 +310,7 @@ export function parse (
text,
isComment: true
}
if (options.outputSourceRange) {
if (process.env.NODE_ENV !== 'production' && options.outputSourceRange) {
child.start = start
child.end = end
}
Expand Down
4 changes: 2 additions & 2 deletions src/sfc/parser.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ export function parseComponent (
sfc.errors.push(msg)
}

if (options.outputSourceRange) {
if (process.env.NODE_ENV !== 'production' && options.outputSourceRange) {
warn = (msg, range) => {
const data: WarningMessage = { msg }
if (range.start != null) {
Expand Down Expand Up @@ -99,7 +99,7 @@ export function parseComponent (
currentBlock.end = start
currentBlock.blockEnd = end
let text = content.slice(currentBlock.start, currentBlock.end)
if (!options.outputSourceRange && !options.disableDeindent) {
if (!(process.env.NODE_ENV !== 'production' && options.outputSourceRange) && !options.disableDeindent) {
text = deindent(text)
}
// pad content so that linters and pre-processors can output correct
Expand Down

0 comments on commit facacc1

Please sign in to comment.