I recently came across the efficient magic of load-grunt-tasks, but am wondering why its utilization seems to be the exception and not the rule in most examples I have seen. If you are not familiar with this module, it does this:
This module will read the
dependencies/devDependencies/peerDependencies
in your package.json and load grunt tasks that match the provided patterns.
For example, this mess in your Gruntfile.js:
grunt.loadNpmTasks('grunt-shell');
grunt.loadNpmTasks('grunt-sass');
grunt.loadNpmTasks('grunt-recess');
grunt.loadNpmTasks('grunt-sizediff');
grunt.loadNpmTasks('grunt-svgmin');
// and likely many, many more
...can be replaced with a simple:
require('load-grunt-tasks')(grunt);
So, is there any downside to this one-liner? If not, then why is it not the standard for registering Grunt tasks in online examples? I couldn't find anything on SO or The Googz, and am not very familiar with Node or Grunt, so any insight would be appreciated.
As far as I can see, there is basically only one drawback which might outweight the advantages: Performance. If you're using watch the module loads the components every time a change is triggered. I had larger projects where the speed decrease was significant. You could circumvent the problem by using kit-grunt which on the other hand is not compatible with every grunt-module (e.g. spritesmith).
Maybe less important is the speed decrease for a single load of the modules. load-grunt-tasks has index your tasks configurations first, before it can load the modules.