From 50cac3a859f44d476248f5b6cedad1bfb394ace8 Mon Sep 17 00:00:00 2001 From: Toilal Date: Wed, 22 Mar 2017 15:32:32 +0100 Subject: [PATCH] Avoid defining location/sourceFile parse options when sourceMap is falsy --- lib/index.js | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/lib/index.js b/lib/index.js index 47574f2..cc4e756 100644 --- a/lib/index.js +++ b/lib/index.js @@ -10,11 +10,14 @@ module.exports = function(contents, sourcemap) { const id = genId(this.resourcePath) let hasComponent = false - const ast = acorn.parse(contents, { - sourceType: 'module', - locations: true, - sourceFile: this.resourcePath - }) + const parseOptions = {sourceType: 'module'} + + if (this.sourceMap) { + parseOptions.locations = true + parseOptions.sourceFile = this.resourcePath + } + + const ast = acorn.parse(contents, parseOptions) const res = estraverse.replace(ast, { enter (node, parent) {