[gulp 4] allow forward references to tasks
See original GitHub issueCurrently, forward references to tasks do not work in gulp 4 (and gulp 3, but I don’t care about that):
gulp.task('default', gulp.series('clean', 'build', 'watch', 'server'));
gulp.task('clean', function () {
// do something
});
...
This results in AssertionError: Task never defined: clean
.
From a stylistic standpoint, many people prefer to place the broadest tasks first and then define component tasks later, since this is how most people think and design code. Also the current ‘bottom up’, Forth-like restriction is no longer necessary considering how gulp 4 works.
From a design standpoint, since tasks are interchangeable with functions now, and since functions (like most stuff in Javascript) can be referenced from anywhere within the current scope regardless of where it was declared, to be consistent tasks should work the same way.
Issue Analytics
- State:
- Created 9 years ago
- Reactions:3
- Comments:77 (43 by maintainers)
Top Results From Across the Web
Forward reference tasks not defined before use
Use the require-dir package to include all files within the ./tasks/ directory. · convert tasks that were designed for gulp@3.9.1 into functions ......
Read more >How to use the gulp.registry function in gulp
@todo: Do we need the svg-sprite task? gulp.task("default", ... require('undertaker-forward-reference'); // NOTE: Allow tasks to be referenced in any order ...
Read more >AssesrtionError: Task never defined : clean; on gulp version 4
In newer versions, you'll get an error, with the message "Task never defined", if you try to use forward references. You may experience...
Read more >Learn How to Use Gulp
Node's require() function allows us to specify the plugins that are needed in order to run our Gulp tasks. These are called dependencies....
Read more >run-task — AWS CLI 1.27.38 Command Reference
Description¶. Starts a new task using the specified task definition. You can allow Amazon ECS to place tasks for you, or you can...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
This makes migration to v4 much more time-consuming than it needs to be.
I’m defining tasks here, with names as strings. I expect them to exist.
Upon discovering this, I’m ready to stick with v3 for the next 6 decades.
I kind of agree with @alvint here - what’s the point of a registry if everything needs to be defined in order? It seems super inflexible. If construction of the function is really a perf problem why can’t we use caching to only construct once on first run?
Possible use case for this is splitting tasks across multiple files, which with the current impl would all have to be loaded in the right order.