A CommonJS Module packager for ASP.NET.
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.
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.
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> ...