Skip to content

Commit

Permalink
Pass filename to ast-transform for sourcemaps (#140)
Browse files Browse the repository at this point in the history
This is a solution for #139. Once I had it reproduced properly, it was relatively clear what was going 😄
  • Loading branch information
mantoni authored and goto-bus-stop committed Dec 6, 2018
1 parent 9ac07ff commit dec4f50
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions lib/browserify-transform.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,11 +35,15 @@ module.exports = function yoYoify (file, opts) {
}
function end (cb) {
var src = Buffer.concat(bufs).toString('utf8')
var flags = (opts && opts._flags) || {}
var basedir = flags.basedir || process.cwd()
var filename = path.relative(basedir, file)
var res
try {
res = transformAst(src, { ecmaVersion: 8, parser: acorn }, walk)
if (opts && opts._flags && opts._flags.debug) {
res = res.toString() + '\n' + convertSourceMap.fromObject(res.map).toComment() + '\n'
res = transformAst(src, { ecmaVersion: 8, parser: acorn, inputFilename: filename }, walk)
if (flags.debug) {
var sm = convertSourceMap.fromObject(res.map).toComment()
res = res.toString() + '\n' + sm + '\n'
} else {
res = res.toString()
}
Expand Down

0 comments on commit dec4f50

Please sign in to comment.