Skip to content

Commit dec4f50

Browse files
mantonigoto-bus-stop
authored andcommitted
Pass filename to ast-transform for sourcemaps (#140)
This is a solution for #139. Once I had it reproduced properly, it was relatively clear what was going 😄
1 parent 9ac07ff commit dec4f50

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

lib/browserify-transform.js

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -35,11 +35,15 @@ module.exports = function yoYoify (file, opts) {
3535
}
3636
function end (cb) {
3737
var src = Buffer.concat(bufs).toString('utf8')
38+
var flags = (opts && opts._flags) || {}
39+
var basedir = flags.basedir || process.cwd()
40+
var filename = path.relative(basedir, file)
3841
var res
3942
try {
40-
res = transformAst(src, { ecmaVersion: 8, parser: acorn }, walk)
41-
if (opts && opts._flags && opts._flags.debug) {
42-
res = res.toString() + '\n' + convertSourceMap.fromObject(res.map).toComment() + '\n'
43+
res = transformAst(src, { ecmaVersion: 8, parser: acorn, inputFilename: filename }, walk)
44+
if (flags.debug) {
45+
var sm = convertSourceMap.fromObject(res.map).toComment()
46+
res = res.toString() + '\n' + sm + '\n'
4347
} else {
4448
res = res.toString()
4549
}

0 commit comments

Comments
 (0)