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

processing plugin after it is loaded #116

Closed
vinitm opened this issue Jul 9, 2016 · 9 comments
Closed

processing plugin after it is loaded #116

vinitm opened this issue Jul 9, 2016 · 9 comments

Comments

@vinitm
Copy link
Contributor

vinitm commented Jul 9, 2016

var gulp = require('gulp'),
    plugins = require('gulp-load-plugins')({
        pattern: ['*'],
        rename: {
            'browser-sync': 'browserSync',
        }
    });

plugins.browserSync = plugins.browserSync.create();

Is this the right way of manually calling plugins.browserSync = plugins.browserSync.create(); after loading plugins or there is some option provided for doing the same?

@jackfranklin
Copy link
Owner

This is the right and only way to do this.

I'm 50/50 on wanting an API to do this. How common is it that plugins need this? I don't want to add yet another config option if this is a very rare case but if enough people need it I'd be open to suggestions.

@vinitm
Copy link
Contributor Author

vinitm commented Jul 13, 2016

plugins.browserSync = plugins.browserSync.create();
plugins.reload = plugins.browserSync.reload;
plugins.underscorify = plugins.underscorify.transform({
    extensions: ['tpl']
});
plugins.babelify=babelify.configure({
  presets: ["es2015", "react"]
});

Above are some of the plugins that I have been using, and it seems it is quite common for plugins to ask for plugin-specific options for initializing.

And Browsersync and Babel are only some of the many popular plugins which have a good user base.

@jackfranklin
Copy link
Owner

OK - particularly given babelify then I can see the potential argument. What are your thoughts on a potential API?

@vinitm
Copy link
Contributor Author

vinitm commented Jul 14, 2016

gulpLoadPlugins({
  camelize: true,
  lazy: true,
  rename: {},
  parseFns: {
    plugin1NameAfterRename: function(pluginInstance) {
      var parsedPlugin = doSomethingWith(pluginInstance);
      return parsedPlugin;
    },
    plugin2NameAfterRename: function(pluginInstance) {},
    plugin3NameAfterRename: function(pluginInstance) {}
  }
});

parseFns option can be provided which takes a parse function for each plugin and returns a parsed plugin.

@jackfranklin
Copy link
Owner

So for babelify you'd have:

parseFns: {
  babelify: (babelify) => babelify.configure(...)
}

I think that's quite nice. I'd rename parseFns to postRequireTransforms or something I think.

@callumacrae any thoughts?

@vinitm
Copy link
Contributor Author

vinitm commented Jul 14, 2016

That is exactly what I mean

@jackfranklin
Copy link
Owner

@vinitm how do you feel about working on a PR? :)

@vinitm
Copy link
Contributor Author

vinitm commented Jul 15, 2016

sure, I will create a PR

@jackfranklin
Copy link
Owner

Closed as of #119

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