CommonJS Module Packager for ASP.NET
C# JavaScript ASP
Switch branches/tags
Nothing to show
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
StitchIt.Specs
StitchIt.Web
StitchIt
lib/Jurassic
packages
.gitignore
LICENSE
Readme.md
StitchIt.sln

Readme.md

StitchIt

A CommonJS Module packager for ASP.NET.

Credits

StitchIt is heavily inspired (almost copied) from Stitch - a great CommonJS module packager for node.js. The name also references SquishIt, a great JavaScript and CSS bundler for ASP.NET.

Disclaimer

StitchIt is currently a work in progress and is not suitable for using in anything vaguely close to the term production. There's a ton of stuff which needs to be added and improved, but don't worry - hopefully it'll be there soon.

Usage

Using the sample from CommonJS Module specification.

  • /Scripts/app/math.js
	exports.add = function() {
	    var sum = 0, i = 0, args = arguments, l = args.length;
	    while (i < l) {
		sum += args[i++];
	    }
	    return sum;
	};
  • /Scripts/app/increment.js
	var add = require('math').add;

	exports.increment = function(val) {
	    return add(val, 1);
	};
  • /Scripts/app/program.js
	var inc = require('increment').increment;
	var a = 1;
	var b = inc(a);

	console.log(b); // 2
  • Global.asax
	public static void RegisterRoutes(RouteCollection routes)
	{
		...
		routes.StitchIt()
			.RootedAt("~/Scripts/app")
			.PublishAt("app.js");
		...
	}
  • /Views/Home/Index.cshtml
	...
	<script src="/app.js"></script>
	<script>
	    stitchIt.require('program');
	</script>
	...