- IronJS: Currently only a partial implementation and doesn’t appear to run the CoffeeScript compiler fully.
- Command line JScript: Epic fail. Just wouldn’t do what I needed it to.
So lets write the compiler wrapper. Pretty basic really,
Few points worth noting here,
- I create a ThreadStatic instance of the Jurassic Engine and feed the CoffeeScript compiler source into it once. The executions/evaluation of that script is quite slow so I only wanted to take the hit once. Jurassic isn’t thread safe so I made the reference ThreadStatic.
- Just to be extra safe I am locking during the execution of the compilation task.
- Any errors just return null. This is a bare bones implementation I have stripped out custom logging and profiling code and an interface that means little in this context.
This is obviously only the start – if I wanted to use CoffeeScript in a .NET environment I am going to need to consider how it is used. When should I be compiling it? How should I be caching it etc? The usual things. Hopefully I’ll touch on these in a later post.
So right now this is kind of a request for comments, this was knocked up quite quickly and likely I have forgotten something or made a massive mistake. Anything you want to offer fire away.