Dirty. Names are assigned directly into GLOBAL
. It breaks file scope.
main.coffee
using = require('using').using
using require './foo'
console.log new Foo #=> { name: 'Foo' }
require './bar'
using.coffee
exports.using = (mod) ->
for name, obj of mod
GLOBAL[name] = obj
foo.coffee
exports.Foo = class
constructor: () ->
@name = 'Foo'
bar.coffee
console.log new Foo #=> { name: 'Foo' }
There may be another way but I can't find it...