mozilla/sweet.js — pull request #102 by natefaubion (2013-09-26 02:17:08+00:00)
Title: Use node plumbing to locate macro module.

This is a change to the `sjs` binary that lets it load macros from installed modules, in addition to relative files, by piggybacking off of node's internal API for resolving module locations.

This is a bit hacky as node doesn't expose this API directly, but seeing as how node's module system is locked, I doubt it will be changing significantly any time soon.

If you provide a `--module` that starts with a `./` or `../` it will resolve it based on the cwd. If you provide it with a package name like `somelib/macros` it will walk up the `node_modules` tree.

Overall, a lot could be done to improve macro loading from packages, but I think this is a decent first step that doesn't require users to copy files around.