jackfranklin / gulp-load-plugins

Automatically load in gulp plugins
https://github.com/jackfranklin/gulp-load-plugins
MIT License
757 stars 55 forks source link

Repackage as a generic module #77

Closed fregante closed 6 years ago

fregante commented 9 years ago

This module is thankfully set up to be very configurable and it allows to load other prefixes as well, like postcss-*, but I didn't know that until after I searched all the internet for a similar but generic plugin.

It turns out I can just do this:

var requireAll = require('gulp-load-plugins');
var $          = requireAll();
var postcss    = requireAll({pattern: 'postcss-*', replaceString: /^postcss-/});

My question is, can we get a generic load-plugins module and have this one rely on it to load gulp plugins? Nothing really would change, with the exception of the findability of the extracted module for generic use.

callumacrae commented 9 years ago

+1, I actually thought this the other day when I was using postcss.

load-plugins already exists, but doesn't support everything gulp-load-plugins supports. It's looking at paths instead of a package.json which probably makes it less performant, and it doesn't support lazy loading which definitely makes it less performant.

cc @jonschlinkert because open source competition is pointless :)

jackfranklin commented 9 years ago

:+1: a few people have asked for this now. I've been kind of hesitant but I'm being pushed in the direction of doing it. If we can collab with @jonschlinkert that'd be awesome. Be cool to update load-plugins with some of the features this plugin has.

callumacrae commented 9 years ago

It would pretty much just be a case of taking the code from this module and changing the default options, right?

There's also load-modules, again by Jon(?!): https://www.npmjs.com/package/load-modules

jackfranklin commented 9 years ago

Basically, yeah. And then making this module effectively be that new module + some predefined config.

jonschlinkert commented 9 years ago

Be cool to update load-plugins with some of the features this plugin has.

I'd be happy to collaborate on implementing whatever changes are needed. I can add anyone as a collab as well

jonschlinkert commented 9 years ago

@jackfranklin how about if I take a stab at implementing some of the features in load-plugins. if anything is missing, or if I miss a nuance somewhere, we can tweak until it get where it needs to be...

jackfranklin commented 9 years ago

@jonschlinkert that sounds great! More than happy to collab or work on some PRs. Just let me know :)

jonschlinkert commented 9 years ago

@jackfranklin added you as a collab. PRs would be great :)

jonschlinkert commented 9 years ago

@jackfranklin just wanted to follow up on this. if we re-work some of the logic/options in load-plugins so it more closely matches the API of this lib - while also being more generic than this lib, would you be open to using load-plugins here? that way we can combine efforts and share knowledge on what's working best for users?

so basically we would just implement load-plugins with the defaults that make the most sense for gulp, and users would end up with the same experience and API they have now on gulp-load-plugins. but if someone needs to do customization or wants to load non-gulp plugins, then they could use load-plugins (while still having a similar API and experience).

thoughts?

callumacrae commented 9 years ago

I think the goal here should be to get gulp-load-plugins to this state:

var loadPlugins = require('load-plugins');

module.exports = function (options) {
  options = Object.assign({}, options, {
    pattern: ['gulp-*', 'gulp.*'],
    replaceString: /^gulp(-|\.)/
  });

  return loadPlugins(options);
};

(ES6 for example only)

That would be neat :)

jackfranklin commented 9 years ago

@jonschlinkert thanks for the reminder, sorry for not getting involved before as I said I would.

I completely agree with @callumacrae here, if we can make sure load-plugins provides everything we need, then gulp-load-plugins can become a simple wrapper around it, with some configuration that makes sense for Gulp specific cases. Any more complex cases can just customise the options gulp-load-plugins exposes, or just skip this plugin entirely and use load-plugins. Does that sound about right?

jonschlinkert commented 9 years ago

great! that sounds perfect, and don't sweat it, I've had a lot on my plate too!

I'll take a stab at refactoring load-plugins and report back here when it's done. then we can make any changes needed to get it to where it needs to be

fregante commented 8 years ago

Is https://github.com/jonschlinkert/load-plugins done? Seems to be working fine for my use case (postcss)!