-
Notifications
You must be signed in to change notification settings - Fork 74
-
Notifications
You must be signed in to change notification settings - Fork 74
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
Plugins encapsulation #6
Comments
I see what you mean. How can we achieve this without breaking the current way to compose tasks? exports.babel = function* () {
yield this
.source("babel/src/*.js")
.babel({ stage: 0 })
.uglify()
.concat("all.min.js")
.target("babel/dist")
} |
@bucaran I think we should open 1.0 branch |
@bucaran However maybe we can make it without breaks. |
What do you suggest? Basically you don't want other plugins to access other plugins right. |
@bucaran FIrstly, plugin should be simpler like module.exports = function (src, opts) {
return uglify.minify(src, assign(opts, { fromString: true })).code
}; which will be wrapped with "runner" function |
Or you have reasons for iterators inside plugins? |
In Fly, a plugin is a the default function exported by a module. Inside of that function I simply add the method I want to be able to call inside my task to Now, what you are proposing is also interesting. Currently, transform plugins call |
Or we can make like this. For now at least module.exports = function (opts) {
return this
.filter(function (src) {
return uglify.minify(src, assign(opts, { fromString: true })).code;
});
}; |
The problem is you want to be able to call module.exports = function (opts) {
return this
.filter("uglify", function (src) {
return uglify.minify(src, assign(opts, { fromString: true })).code;
});
}; What do you think? :) |
@bucaran The name of the task is module name without fly-* |
@TrySound Yeah, that's another option, but having both options would be useful, people will complain that Fly is doing too much otherwise |
@bucaran Or if yout want we can try make it like postcss module.exports = fly.plugin('uglify', function (inst) {
inst.filter(function (src) {
return uglify.minify(src, assign(opts, { fromString: true })).code;
});
}); |
@bucaran In this case we don't need to wrap inside fly. Just let it user. Also we can validate plugins. |
The problem with this option is that you need to import Can't we also validate plugins with the previous option anyway? |
Why not import fly? It still in dependencies. |
It will be if you are using Fly during development, but plugin authors don't need to currently because the Fly instance is bound to Wait, don't you agree that the following is an improvement? const uglify = require("uglify")
const assign = require("object-assign")
module.exports = function (opts) {
return this
.filter("uglify", (src) =>
uglify.minify(src, assign(opts, { fromString: true })).code)
} |
Either one is fine, but I would prefer the one above because there is only one callback in there, it's a tab block improving the current solution and still looks Fly-ish 😄 |
@bucaran Okay. I like it too. But still I want to replace |
@bucaran |
@TrySound I wonder how Koa handles this issue, because I was inspired to do this after using Koa in a couple of projects and liking how they handled the use of Here is one idea, we can still bind |
@TrySound You just said and I didn't notice, 😄 Cool! Roadmap! |
@bucaran So.. function(inst, opts) ? |
Basically what you just said. |
@bucaran Not bind, just pass as an argument. |
@bucaran Give me access, please. I will open "next" branch. |
@TrySound Do you have a good reason to pass an argument? I see where you are coming from, but one of Fly "features", or design goals from the start was to bind |
@bucaran Okay. Let's use |
@bucaran Access? Promise will not make direct commits:) |
@TrySound Sure. Hold on. |
@TrySound Welcome aboard 😄 |
@TrySound Do you mind coming over to the gitter room? |
I think this is the most important topic and post it in own issue.
We shouldn't let any plugins have access to another. In this case we need to initialize every plugin call with own instance which will be initialized with some properties of previous instance.
The text was updated successfully, but these errors were encountered: