Skip to content

Instantly share code, notes, and snippets.

@junosuarez
Created October 15, 2012 07:03
Show Gist options
  • Select an option

  • Save junosuarez/3891149 to your computer and use it in GitHub Desktop.

Select an option

Save junosuarez/3891149 to your computer and use it in GitHub Desktop.
macro module {
case $body => {
define(function (require, exports, module) {
$body
});
}
}
module {
var x = require('x');
exports = function foo() {
return 'foo' + x
}
}
// outputs:
define(function (require$1, exports$2, module$3) {
{
var x$6 = require('x');
exports = function foo() {
return 'foo' + x$6;
};
}
});
@junosuarez

Copy link
Copy Markdown
Author

Note, exports$2 does not match the reference to exports in the function body (line 21) - same with require$1 and require (line 20). It's fine to sanitize symbols, but you gotta be consistent in scope.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment