I have lots of ideas, not so much time. Just dump my ideas here, without any particular order. Feel free to implement them.
When browserifying a file, produce a guard statements where required. E.g.
module.exports = user;
function greet(user) {
return "Hello " + user.getName();
}This code uses method getName of user, without even checking three assumptions:
useris definedgetNameis definedgetNameis a function
We could do:
module.exports = user;
var guard = require('... guard module ... ');
function greet(user) {
guard(greet); // protect ourselves!
return "Hello " + user.getName();
}When this code is browserified we could run a transform which will inject all guarding logic:
module.exports = user;
var guard = require('... guard module ... ');
function greet(user) {
guard(user).has('getName()');
return "Hello " + user.getName();
}When you have a browser-friendly commonjs package, it's often desirable to just play with it
on jsbin/jsfiddle. It would be nice to have a script which automatically browserifies and
publishes package to gh-pages, so, that users can just copy-paste link to browserified
version.
One can use http://requirebin.com/ or browserify as a service too.
These are awesome tools. I just find requirebin less user friendly who needs html/css too.
Whereas browserify-cdn is potentially not as reliable as gh-pages.
Could be fun to write this transpiler...