grunt-depgraph

0.0.2 • Public • Published

grunt-depgraph

Generate module to module dependancy graph and resolve dependancy at build time

Getting Started

This plugin requires Grunt ~0.4.0

If you haven't used Grunt before, be sure to check out the Getting Started guide, as it explains how to create a Gruntfile as well as install and use Grunt plugins. Once you're familiar with that process, you may install this plugin with this command:

npm install grunt-depgraph --save-dev

Once the plugin has been installed, it may be enabled inside your Gruntfile with this line of JavaScript:

grunt.loadNpmTasks('grunt-depgraph');

depgraph task

Run this task with the grunt depgraph command.

Settings

files

Type: Array

This defines what file patterns this task will watch. It will be an array of files.

dotFile

Type: String

imtermediate generated dot file.

outputFilePath

Type: String

path of the output file.

outputFilesExt

Type: Array

typeof output files. Example png, pdf

Example:

depgraph:{
	options:{
		files : ['src/js/modules/a.js',
				'src/js/modules/b.js',
				'src/js/modules/c.js']
		dotFile: 'build/depGraph.dot',
		outputFilePath: 'build/depGraph',
		outputFilesExt: ['png','pdf'],
	}
},
//src/js/modules/a.js
define({
	'fileName' : 'MyLib',
	'dependsOn' : [],
	'layer' : 'Lib Layer'
}).content(function(){
	return {
		add : function(a,b){
			return a+b;
		},
		sub : function(a,b){
			return a-b;
		}
	}
});
//src/js/modules/b.js
define({
	'fileName' : 'AddModule',
	'dependsOn' : ['MyLib'],
	'layer' : 'Module Layer'
}).content(function(Lib){
	console.log('2 + 3 = ' + Lib.add(2,3));
});
//src/js/modules/c.js
define({
	'fileName' : 'SubModule',
	'dependsOn' : ['MyLib'],
	'layer' : 'Module Layer'
}).content(function(Lib){
	console.log('2 - 3 = ' + Lib.sub(2,3));
});

When you run grunt depgraph, this will generate this image

Run the demo

sudo apt-get install graphviz
git clone https://github.com/nsisodiya/grunt-depgraph.git
cd grunt-depgraph/demo
npm install grunt
grunt depgraph

This will generate 'depGraph.png'

FAQs

What is the purpose of depgraph?

as you can see the example, this will generate depgraph! images your codebase has 1000 javascript files, you do not want to load all 1000 files, you only want to load 5 modules to your homepage and these 5 modules has some dependancy, then you can use this tool to generate a list of files which will be needed to load homepage

Release History

  • 2013-08-29   v0.0.1   Intial base version.

Readme

Keywords

none

Package Sidebar

Install

npm i grunt-depgraph

Weekly Downloads

1

Version

0.0.2

License

none

Last publish

Collaborators

  • nsisodiya