Skip to content

Commit 9b2cbd0

Browse files
committed
Respect sourceMaps:false set in config files too.
1 parent 588bde8 commit 9b2cbd0

File tree

1 file changed

+20
-5
lines changed

1 file changed

+20
-5
lines changed

index.js

Lines changed: 20 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ Babelify.prototype._flush = function (callback) {
4747
// to avoid corrupting multibyte characters.
4848
const data = Buffer.concat(this._data).toString();
4949

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

115-
// Since Browserify can only handle inline sourcemaps, we override any other
116-
// values to force inline sourcemaps unless they've been disabled.
117-
sourceMaps: opts.sourceMaps === false ? false : "inline",
118-
119115
// The default sourcemap path is the path of the file relative to the
120116
// basedir. This should mirror Browserify's internal behavior when
121117
// 'debug' is enabled.
@@ -150,3 +146,22 @@ function normalizeTransformOpts(opts) {
150146

151147
return opts;
152148
}
149+
150+
function transform(data, inputOpts, done) {
151+
let cfg;
152+
try {
153+
cfg = babel.loadPartialConfig(inputOpts);
154+
if (!cfg) return done(null, null);
155+
} catch (err) {
156+
return done(err);
157+
}
158+
const opts = cfg.options;
159+
160+
// Since Browserify can only handle inline sourcemaps, we override any other
161+
// values to force inline sourcemaps unless they've been disabled.
162+
if (opts.sourceMaps !== false) {
163+
opts.sourceMaps = "inline";
164+
}
165+
166+
babel.transform(data, opts, done);
167+
}

0 commit comments

Comments
 (0)