Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve default behavior #10

Open
yoshuawuyts opened this issue Aug 29, 2014 · 1 comment
Open

Improve default behavior #10

yoshuawuyts opened this issue Aug 29, 2014 · 1 comment

Comments

@yoshuawuyts
Copy link
Collaborator

I ran into #7 again today, which made me wonder if we might improve the default behavior or envify.

Instead of having to choose between require('envify') and require('envify/custom') this behavior might be more intuitive.

var envify = require('envify');

// detects the process.env.NODE_ENV variable
browserify()
  .transform(envify())

// manually override the environment
browserify()
   .transform(envify({env: 'custom'});

Let me know what you think, if you approve I'll PR the changes.

@hughsk
Copy link
Owner

hughsk commented Aug 29, 2014

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants