grunt-amd-check

Grunt task to check for broken AMD dependencies

grunt-amd-check

grunt-amd-check is a grunt task to check for broken AMD dependencies in a project.

From the same directory as your Gruntfile, run

npm install grunt-amd-check

Then add the following line to your Gruntfile:

grunt.loadNpmTasks('grunt-amd-check');

You can verify that the task is available by running grunt --help and checking that "amd-check" is under "Available tasks".

grunt-amd-check reads two sections of your config: amd-check and requirejs. amd-check can contain these properties (example from class.js):

'amd-check': {
    //String or Array of files for which to trace dependencies 
    //grunt.file.expand() is called, so patterns beginning with "!" will be excluded 
    pool: ['src/**/*.js', 'test/spec/**/*.js']
},

requirejs is a standard r.js configuration object. grunt-amd-check uses basePath, paths, and packages (all optional) to transform AMD module names to absolute file names. If the mainConfigFile property is given, the configuration in that file will be mixed-in to the requirejs property with a lower precedence (that is, in the case of a conflicting configuration property, requirejs will always "win" against mainConfigFile).

grunt amd-check iterates through all files matched in the pool option and reports any dependencies which cannot be resolved to absolute paths.

grunt whatrequires accepts a single argument searchFile and iterates through all files matched in the pool option, looking for modules which list searchFile as a dependency (in any valid RequireJS format). Note: Grunt denotes arguments using a ":" character after the task name, followed by the argument.

Example: grunt whatrequires:src/js/BaseController.js might report src/js/HomeController.js and src/js/NavigationController.js as dependents.