-
Notifications
You must be signed in to change notification settings - Fork 209
node loader
Ryan Scheel edited this page Jan 9, 2014
·
4 revisions
If you'd like to skip using the sjs binary to compile your sweet.js code, you can use the node loader. This allows you to require sweet.js files that have the .sjs extension:
var sjs = require('sweet.js'),
example = require('./example.sjs');
example.one;Where ./example.sjs contains:
// example.sjs
macro id {
rule { ($x) } => {
$x
}
}
exports.one = id (1);Note that require('sweet.js') must come before any requires of .sjs code. Also note that this does not import any macros, it just uses sweet.js to compile files that contain macros before requiring them. If you're looking to modularize macros check out the modules wiki page.