JS.Class 3.0.1: an npm package and deployment tools

I don’t usually make announcements for bug-fix releases but this release adds a couple of things that are external to the runtime library that will hopefully make working with it a little easier.

The first is an npm package that you can install if you just want to use JS.Class on Node and don’t care about other environments. Once you’ve installed it, using JS.Class components is simple:

require('jsclass');

// Then use JS.require() to load components
JS.require('JS.Set', function() {
    var s = new JS.Set([1,2,3]);
    // ...
});

Note we’re still sticking to the more portable JS.require() method of loading things rather than adapting to CommonJS; the npm package is purely a convenience method for downloading the library.

Except, it’s not just a convenience. Thanks to npm’s support for executables, the npm package contains a program called jsbuild. As helpful as JS.Packages is for managing the development of your project, it’s not always the most optimal tool to use in production. To help with this, jsbuild gives you a tool to bundle all the modules you need into one file. You tell it which packages you’re using, and it generates a single script including all the dependencies for those packages. It can even include scripts from external domains if you want to cut out HTTP round-trips for those too.

It’s simple to use, just tell it where your package manifest and files are, and which modules you’re using, and it will print the combined script to standard output.

jsbuild --manifest public/javascript/manifest.js \
        --root public/javascript/ \
        --external \
        jQuery JS.Set

Note that it does not include minification, this step is up to you. It also cannot bundle modules that have custom loader functions, for obvious reasons, but for 95% of common webdev use cases it works quite well.

As usual, the changelog is on GitHub and you can download the new version from the website.