browserify / browser-resolve

resolve function which support the browser field in package.json
MIT License
102 stars 70 forks source link

Upgraded resolve and added support for basedir #50

Closed securingsincity closed 9 years ago

defunctzombie commented 9 years ago

Why is basedir support needed?

securingsincity commented 9 years ago

@defunctzombie I fixed some of the things you had above.

As for why its needed, there are a few situations where you would want to resolve files that match certain criteria but you don't have the exact file name as an example from http://github.com/facebook/jest 's repo

return resolve.sync(moduleName, {
      basedir: path.dirname(currPath),
      extensions: this._config.moduleFileExtensions
        .map(function(ext){
          return '.' + ext;
        })
    });

Here they are trying to resolve module's by name but also in a base path. Because it's a test runner it doesn't necessarily need to run at the root of package. . There is an issue in jest https://github.com/facebook/jest/issues/61 that would be resolved by using node-browser-resolve instead of node-resolve assuming that this went through.

With that said if you don't think its necessary, I'd be happy to close the PR

defunctzombie commented 9 years ago

Published as 1.5.0. Thanks!