forked from browserify/browserify
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Pass "flags" option to each transform
Essentially, "flags" is set to the value of the bundler's "_options" property. This should enable more intelligent transform behaviours, for example toggling source maps when --debug is supplied through the CLI or module API. Closes browserify#844 Fixes hughsk/uglifyify#16 Fixes hughsk/uglifyify#18 This should enable more intelligent transform behaviours, for example toggling source maps when --debug is supplied through the CLI.
- Loading branch information
Showing
2 changed files
with
40 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
var through = require('through2'); | ||
var browserify = require('../'); | ||
var test = require('tap').test; | ||
var vm = require('vm'); | ||
|
||
test('--debug passed to transforms', function (t) { | ||
var empty = require.resolve('../lib/_empty'); | ||
|
||
t.plan(3); | ||
|
||
[true, false].forEach(function(debug) { | ||
var b = browserify(empty, { debug: debug }); | ||
|
||
b.transform(function(file, opts) { | ||
t.equal(opts.flags.debug, debug, 'debug: ' + debug); | ||
return through(); | ||
}); | ||
|
||
b.bundle(function (err, src) { | ||
if (err) return t.fail(err.message); | ||
}); | ||
}); | ||
|
||
var b = browserify(empty, { debug: true }); | ||
|
||
b.transform({ | ||
flags: Infinity | ||
}, function(file, opts) { | ||
t.equal(opts.flags, Infinity, 'transform arguents are preserved'); | ||
return through(); | ||
}); | ||
|
||
b.bundle(function(err, src) { | ||
if (err) return t.fail(err.message); | ||
}); | ||
}); |