brfs icon indicating copy to clipboard operation
brfs copied to clipboard

Bug in merged source maps

Open goto-bus-stop opened this issue 7 years ago • 3 comments

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.

goto-bus-stop avatar Mar 26 '18 07:03 goto-bus-stop

@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:

image

(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?

goto-bus-stop avatar Mar 30 '18 11:03 goto-bus-stop

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 avatar Mar 30 '18 12:03 goto-bus-stop

@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").

sourcemap

the script.js file is just

import a from './a';

blackgate avatar Apr 03 '18 11:04 blackgate