Open yoshuawuyts opened 10 years ago
So the reason for this API being as it is right now is to cater to transforms specified from either the CLI or within a package.json
file: in this case, you're expected to export a function with the transform signature, i.e.:
module.exports = function(file, opts) {
return new Stream
}
So in the above example you'd actually have the following, where envify
is passed in directly:
var envify = require('envify')
browserify().transform(envify)
The only way to get the behaviour you're after is to check the first argument for an Object vs. String, which could be a bit quirky but might work! Would definitely want this to be a major version bump though. If you wanna give it a shot send a PR and we'll see :)
I ran into https://github.com/hughsk/envify/issues/7 again today, which made me wonder if we might improve the default behavior or
envify
.Instead of having to choose between
require('envify')
andrequire('envify/custom')
this behavior might be more intuitive.Let me know what you think, if you approve I'll PR the changes.