Skip to content
Permalink
Browse files

Respect sourceMaps:false set in config files too.

  • Loading branch information...
loganfsmyth committed Sep 4, 2018
1 parent 588bde8 commit 9b2cbd07fac72d743ac48e403e794b28fe9d509a
Showing with 20 additions and 5 deletions.
  1. +20 −5 index.js
@@ -47,7 +47,7 @@ Babelify.prototype._flush = function (callback) {
// to avoid corrupting multibyte characters.
const data = Buffer.concat(this._data).toString();

babel.transform(data, this._opts, (err, result) => {
transform(data, this._opts, (err, result) => {
if (err) {
this.emit("error", err);
} else {
@@ -112,10 +112,6 @@ function normalizeOptions(preconfiguredOpts, transformOpts, filename) {
),
filename: absoluteFilename,

// Since Browserify can only handle inline sourcemaps, we override any other
// values to force inline sourcemaps unless they've been disabled.
sourceMaps: opts.sourceMaps === false ? false : "inline",

// The default sourcemap path is the path of the file relative to the
// basedir. This should mirror Browserify's internal behavior when
// 'debug' is enabled.
@@ -150,3 +146,22 @@ function normalizeTransformOpts(opts) {

return opts;
}

function transform(data, inputOpts, done) {
let cfg;
try {
cfg = babel.loadPartialConfig(inputOpts);
if (!cfg) return done(null, null);
} catch (err) {
return done(err);
}
const opts = cfg.options;

// Since Browserify can only handle inline sourcemaps, we override any other
// values to force inline sourcemaps unless they've been disabled.
if (opts.sourceMaps !== false) {
opts.sourceMaps = "inline";
}

babel.transform(data, opts, done);
}

0 comments on commit 9b2cbd0

Please sign in to comment.
You can’t perform that action at this time.