Skip to content

Commit facacc1

Browse files
committed
feat(compiler): Disable outputSourceRange in production env
1 parent 5991522 commit facacc1

File tree

4 files changed

+8
-8
lines changed

4 files changed

+8
-8
lines changed

src/compiler/create-compiler.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ export function createCompilerCreator (baseCompile: Function): Function {
1919
}
2020

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

src/compiler/parser/html-parser.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -245,7 +245,7 @@ export function parseHTML (html, options) {
245245
name: args[1],
246246
value: decodeAttr(value, shouldDecodeNewlines)
247247
}
248-
if (options.outputSourceRange) {
248+
if (process.env.NODE_ENV !== 'production' && options.outputSourceRange) {
249249
attrs[i].start = args.start + args[0].match(/^\s*/).length
250250
attrs[i].end = args.end
251251
}

src/compiler/parser/index.js

+4-4
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,7 @@ export function parse (
127127
element.ns = ns
128128
}
129129

130-
if (options.outputSourceRange) {
130+
if (process.env.NODE_ENV !== 'production' && options.outputSourceRange) {
131131
element.start = start
132132
element.rawAttrsMap = element.attrsList.reduce((cumulated, attr) => {
133133
cumulated[attr.name] = attr
@@ -244,7 +244,7 @@ export function parse (
244244
// pop stack
245245
stack.length -= 1
246246
currentParent = stack[stack.length - 1]
247-
if (options.outputSourceRange) {
247+
if (process.env.NODE_ENV !== 'production' && options.outputSourceRange) {
248248
element.end = end
249249
}
250250
endPre(element)
@@ -296,7 +296,7 @@ export function parse (
296296
}
297297
}
298298
if (child) {
299-
if (options.outputSourceRange) {
299+
if (process.env.NODE_ENV !== 'production' && options.outputSourceRange) {
300300
child.start = start
301301
child.end = end
302302
}
@@ -310,7 +310,7 @@ export function parse (
310310
text,
311311
isComment: true
312312
}
313-
if (options.outputSourceRange) {
313+
if (process.env.NODE_ENV !== 'production' && options.outputSourceRange) {
314314
child.start = start
315315
child.end = end
316316
}

src/sfc/parser.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ export function parseComponent (
2929
sfc.errors.push(msg)
3030
}
3131

32-
if (options.outputSourceRange) {
32+
if (process.env.NODE_ENV !== 'production' && options.outputSourceRange) {
3333
warn = (msg, range) => {
3434
const data: WarningMessage = { msg }
3535
if (range.start != null) {
@@ -99,7 +99,7 @@ export function parseComponent (
9999
currentBlock.end = start
100100
currentBlock.blockEnd = end
101101
let text = content.slice(currentBlock.start, currentBlock.end)
102-
if (!options.outputSourceRange && !options.disableDeindent) {
102+
if (!(process.env.NODE_ENV !== 'production' && options.outputSourceRange) && !options.disableDeindent) {
103103
text = deindent(text)
104104
}
105105
// pad content so that linters and pre-processors can output correct

0 commit comments

Comments
 (0)