brfs
brfs copied to clipboard
Bug in merged source maps
Via @blackgate:
Sure:
const fs = require("fs"); const browserify = require("browserify"); browserify("./script.js", { debug: true }) .transform("babelify", {presets: ["env"], sourceMaps: true}) .transform("brfs") .bundle() .pipe(fs.createWriteStream("bundle.js"));With the
.transform("brfs")line, the sourcemap contains the transpiled source instead of the original.
@blackgate I'm having trouble reproducing this issue with the latest browserify/babelify/brfs versions.
//script.js
const fs = require('fs')
fs.readFile(__filename, 'utf8', (err, res) => {
if (err) console.error(err)
alert(res)
})
// build.js
const fs = require("fs");
const browserify = require("browserify");
browserify("./script.js", { debug: true })
.transform("babelify", {presets: ["env"], sourceMaps: true})
.transform("brfs")
.bundle()
.pipe(fs.createWriteStream("bundle.js"));
This gives me a bundle.js with the correct source contents:

(left is bundle.js, right is source contents)
Which versions are you using? Or could you make a smallish source file that does reproduce the issue?
I did find and fix another issue here: https://github.com/browserify/static-module/pull/44 But I believe it's different (it doesn't involve the source contents, only mappings)
@goto-bus-stop Sorry, I just had time to check this out today. The problem only seems to happen on files that don't have a require("fs").

the script.js file is just
import a from './a';