How can I compile CoffeeScript from .NET?

后端 未结 18 2000
后悔当初
后悔当初 2020-12-23 01:54

I want to write an HttpHandler that compiles CoffeeScript code on-the-fly and sends the resulting JavaScript code. I have tried MS [JScript][1] and IronJS without success. I

18条回答
  •  无人及你
    2020-12-23 02:31

    I've managed to compile CoffeeScript from .NET using IKVM, jcoffeescript and Rhino. It was straightforward, except that the JCoffeeScriptCompiler constructor overload without parameters didn't work. It ran OK with a java.util.Collections.EMPTY_LIST as parameter.

    This is how I did it:

    1. Download IKVM, jcoffeescript and Rhino.
    2. Run ikvmc against js.jar, creating js.dll.
    3. Run ikvmc against the jcoffeescript jar.
    4. Add a reference to the jcoffeescript dll in Visual Studio. More references may be needed, but you will be warned about those.
    5. Run new org.jcoffeescript.JCoffeeScriptCompiler(java.util.Collections.EMPTY_LIST).compile() in your code.

    The next step would be to create a build task and/or an HTTP handler.

提交回复
热议问题