jonschlinkert / load-plugins

Thin wrapper around resolve-dep for loading plugins from node_modules or local directories. Like load-gulp-plugins, match dep, etc, but works for gulp, grunt, assemble, verb or anything other task runner or build system that uses plugins.
https://github.com/jonschlinkert
MIT License
22 stars 1 forks source link

camelize: true by default #4

Closed TrySound closed 9 years ago

TrySound commented 9 years ago

Why it false? Performace issue is not so important here. More comfortable to access all plugins out of the box without any brackets. Or maybe better combine both of them in one object?

cache[key] = cache[camelize(key)] = require(key);
tunnckoCore commented 9 years ago

Actually it's not needed as option. It more part of "renaming", so ... and that's why I not implemented it in load-deps. And in second place, because that thing shouldn't be part of lib like this, it's user-specific and worth nothing to use separate libs like that

var appname = require('app-name')
var camelcase = require('camelcase')
var loadDeps = require('load-deps')

var strip = ['gulp', 'handlebars', 'helpers']
function rename (name) {
  return camelcase(appname(name, strip))
}

var plugin = loadDeps('gulp-*', {renameKey: rename})
jonschlinkert commented 9 years ago

I think @TrySound is looking at it from a different perspective - e.g. as a user versus as an implementor. IMHO it makes sense to do what users expect here - and a user wouldn't want to do all of that work to get names to be camelcased. When implementors use this library in other node.js applications, they can still customize the renaming however they want.

jonschlinkert commented 9 years ago

@TrySound yeah if you want to do a pr to make it camelize by default, that would be great. @ianstormtaylor made a much better camelcase lib: to-camel-case if you want to use that.

I'm a fan of the module pattern, to @tunnckoCore's point, so if you wanted to use app-name there somehow that would be great too. thoughts?

tunnckoCore commented 9 years ago

e.g. as a user versus as an implementor

agreed. but yea, other than that performance hit shouldn't be an issue.