Skip to content

Commit

Permalink
Avoid defining location/sourceFile parse options when sourceMap is falsy
Browse files Browse the repository at this point in the history
  • Loading branch information
Toilal committed Mar 22, 2017
1 parent bd28f86 commit e0598e5
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions lib/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down

0 comments on commit e0598e5

Please sign in to comment.