stitch
stitch copied to clipboard
Using 'this' instead of 'exports' doesn't seem to work
In node it's possible to use 'this' instead of 'exports' in a module. However, this does not seem to work when compiling with Stitch.
I've mad a configuration file in CoffeeScript that references a lot of its own values:
@DATA_SERVER_HOST = '192.168.0.1'
@DATA_SERVER_PORT = 8042
@DATA_SERVER_URL = "http://#{@DATA_SERVER_HOST}:#{@DATA_SERVER_PORT}"
(Note that in CoffeeScript "@" is syntactic sugar for "this".)
To make this work with Stitch I instead have to write:
exports.DATA_SERVER_HOST = '192.168.0.1'
exports.DATA_SERVER_PORT = 8042
exports.DATA_SERVER_URL = "http://#{exports.DATA_SERVER_HOST}:#{exports.DATA_SERVER_PORT}"
...which is slightly inconvenient.
Edit: I'm using Stitch 0.3.1 on Node.js 0.4.7
this in a browser, outside of any context, is usually the DOM window so not a recommended practice
You could do something like this
config = ->
@DATA_SERVER_HOST = '..'
@DATA_SERVER_PORT = '..'
this
module.exports = new config