Skip to content

Loading configuration is overly complicated #1

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

Closed
jwalton opened this issue Dec 29, 2013 · 2 comments
Closed

Loading configuration is overly complicated #1

jwalton opened this issue Dec 29, 2013 · 2 comments

Comments

@jwalton
Copy link
Contributor

jwalton commented Dec 29, 2013

When loading configuration from package.json, we should start at the cwd and look upwards for package.json, instead of starting at the js file we're transforming.

@jwalton
Copy link
Contributor Author

jwalton commented Jan 17, 2014

The current behavior is to start at the source file in question, walk up the directory tree until we find package.json, and try to load configration from that file. If configuration is not found, then we will continue to walk up the tree until we find another package.json and will try again. This is similar to how browserify-shim looks for configuration.

There are arguments to be made in favor of this algorithm; when you require a file, this is similar to the algorithm that node uses to go looking for the file you're requiring (walk upward looking for "node_modules", if you fail keep walking upwards.)

Here's where I feel this breaks down, though: Suppose you're using debowerify. One of the weird things you're going to run into is that browserify is going to try to run your transforms on packages it loads from bower, which is the opposite of the behavior for packages it loads from npm (see opts.global.) This means that browserify-transform-tools is going to look in the bower component for configuration first, and then fail up to your project. I think that the majority of the time, though, you wouldn't want any configuration found in the child project to be loaded; that configuration is probably there for building that child project, and probably isn't intended to be run when loading that project. Also, you probably do want your transform configuration to run.

So, I'm going to make the default walk from the cwd and stop at the first package.json it finds. If you want the old behavior, it will be available via a fromSourceFileDir option.

@jwalton
Copy link
Contributor Author

jwalton commented Jan 17, 2014

Fixed via 010023c.

@jwalton jwalton closed this as completed Jan 17, 2014
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

No branches or pull requests

1 participant