This module has been replaced by @andreypopp's implementation, which you can find here.
A browserify transform for sweet.js, which brings hygienic macros to JavaScript.
npm install sweetify
browserify -t sweetify index.sjs
You might want to have to avoid copying and pasting your macros between files,
so included is an unofficial means to require
them into your script.
Take, for example, first.sjs
:
// first.sjs
macro first {
case ($a + $b) => { $a }
}
You can use require.macro
to include its contents in your script.
// index.sjs
require.macro('./first.sjs')
var x = first(1 + 2)
console.log(x)
Bundling index.sjs
will result in output along these lines:
// bundle.js
var x$2 = 1;
console.log(1);
require.macro
uses browser-resolve to find
the file too, so you can throw your macros up on NPM if you so please.
Note however that inlining is pretty rudimentary: it literally prepends the file contents to your script before passing it to sweet.js. Pull requests are welcome if you find a way to bend the parser to exclude everything but the macros, or any other improvements you can think of :)