-
-
Notifications
You must be signed in to change notification settings - Fork 4.2k
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
4.0: Multiple Names for one function #1159
Comments
cant got it, but the first example definitely not looks okey to me.
|
Yeah this isn't the right behavior, it seems like gulp.task is mutating the function |
This is due to storing tasks in a weakmap, no idea how to change it. PRs welcome. |
+1 for solution. I'm not too familiar with maps, so I'll just voice my support for a fix and leave it alone. |
I started looking into it, and it seems that task aliases have been defined fine. The problem is ony with displaying them via @phated I have few questions about design decisions to fix that
|
Map shouldn't be used because we don't want to hold function references if they are cleaned up throughout a program. I didn't explicitly decide to make it a singleton but it shouldn't be exposed to consumers. |
There's a couple of ways to resolve the issue. The key questions is - how should Undertaker behave when being fed with tasks referring to the same JS function. I can think of several approaches:
Each way has pros and cons. I vote for (3). I committed PR for Undertaker (gulpjs/undertaker#34) |
I have been using
output
|
I was looking at Undertaker metadata, and ran into this issue as well. Clearly a lot of thought and careful consideration has gone into all this, and I guess I'm just missing something fairly obvious somewhere... So let me just throw this out here, hoping someone can make me see the light:
|
@erikkemperman thanks for digging into this deeper. You are correct that Map and WeakMap would have the same problem because the key would be the function reference. The reason metadata is keyed by the function is that task names aren't unique; e.g. passing a function to gulp.series uses the function displayName/name as the task name, even if you never registered it. The WeakMap is used because Undertaker makes no assumptions about how a registry stores tasks (though the default is in an object). I don't think that registries should have remove/clear but that isn't to say they can't, as Undertaker only looks for the methods it cares about and allows the rest. Undertaker was mainly written for usage inside gulp, but it should be generic enough to use in other scenarios (who knows, maybe even grunt can be powered by it). |
@phated Thanks for detailed response, that pretty much clears it all up for me. Have an idea about this, going to be playing around in my fork with that. Sorry to be imposing on your time a bit much lately -- I'm having a little gap in between projects at work, and wanted to test the waters around Gulp#4.0 in preparation for the next one coming up. I trust you'll feel free to ignore me if it's at all inconvenient :-) |
@erikkemperman Awesome, love having new contributors come in to poke around! Feel free to ping any of us on IRC if you have questions |
@erikkemperman whats your ideas? Love to chat and help you on it. I wouldn't mind jumping into that code base as well. |
@contra Good to know, thanks! @nmccready Well the idea is decidedly half-baked at present, and might very well turn out to not work at all. Didn't have any time to try it out today unfortunately. But very roughly, my thinking was that the metadata might be split in two maps. The first map would map {
foo: <fn-foo-alias>,
bar: <fn-bar-alias>
} where each The second map would reflect the topology, or tree structure, simply by having each parent-alias map to an array of child-aliases. Anyway, the point is that we don't just record which functions are in the tree at a given point but also which name/alias was used to get it there (if any). Then we should be able to get |
@nmccready Scratch that. It's not going to work, is it? Because even if it fixes the output of The other half being the output of running tasks, i.e. regular So... Apologies for inflicting this on you guys. Will think about it some more. |
@erikkemperman thanks for all the work you are putting into this. It is one of the biggest hangups currently and I don't have the time to dig into it. Keep bouncing ideas off and I can respond when I get a chance. |
This was fixed by gulpjs/undertaker#50 and will be released in the next version of Undertaker. |
👍 |
This just landed in the 4.0 branch. There was a breaking change in undertaker 0.13 so I bumped the gulp version to 4.0.0-alpha.2 and added support for the new version in gulp-cli also. Please be sure to update everything to get this fix. |
Awesome! 👍 |
And example of this behavior:
I'd like to be able to alias tasks with multiple names and it doesn't seem possible right now. A use case for this is when a user was to make task A the default task as well like so:
A's name turns to default :(
The text was updated successfully, but these errors were encountered: