How can I compile CoffeeScript from .NET?

后端 未结 18 1806
后悔当初
后悔当初 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:36

    You could simply write a port of it to C#. I have ported Jison to C# (which is the underlying project that makes CoffeeScript run). I would think it may be a bit different, but both Jison parsers work the same.

    I have not pull requested it back yet to Jison's main architecture, but will be doing so soon.

    https://github.com/robertleeplummerjr

    0 讨论(0)
  • 2020-12-23 02:39

    Check out the new coffeescript-dotnet project, which uses the Jurassic JavaScript implementation.

    0 讨论(0)
  • 2020-12-23 02:41

    CoffeeScript in Visual Studio 2010

    It's Chirpy's fork (chirpy is a tool for mashing, minifing, and validating javascript, stylesheet, and dotless files)

    "OK, I think I got it working on my fork, based mostly on other peoples' work. Check it out: http://chirpy.codeplex.com/SourceControl/network/Forks/Domenic/CoffeeScriptFixes"

    from http://chirpy.codeplex.com/workitem/48

    0 讨论(0)
  • 2020-12-23 02:48

    I've tried to compile the extras/coffee-script.js file, unmodified, to jsc, the JScript.NET compiler for .NET, and I got many errors. Here are the noteworthy ones:

    • 'require' is a new reserved word and should not be used as an identifier
    • 'ensure' is a new reserved word and should not be used as an identifier
    • Objects of type 'Global Object' do not have such a member

    Other errors were caused by the above said errors.

    0 讨论(0)
  • 2020-12-23 02:50

    CoffeeScript-dotnet

    Command line tool for compiling CoffeeScript. Includes a file system watcher to automatically recompile CoffeeScripts when they change. Roughly equivalent to the coffee-script node package for linux / mac.

    CoffeeSharp

    Includes a command line tool similar to CoffeeScript-dotnet as well as a http handler that compiles CoffeeScripts when requested from an asp.net site.

    SassAndCoffeeScript

    Library for Asp.net mvc that compiles sass and coffeescript files on request. Also supports minification and combination.

    Manually Compile With IronJS

    IronJS is a .NET javascript interpreter that can successfully load the CoffeeScript compiler and compile CoffeeScript.

    Manually Compile With Node.js

    Get the node binaries and add the bin directory to your path. Write a node.js script to load the CoffeeScript compiler and your CoffeeScript files and save the compiled javascript.

    0 讨论(0)
  • 2020-12-23 02:50

    I've done an HttpHandler that uses Windows Script Host behind the scenes: https://github.com/duncansmart/LessCoffee and works great (it also compiles *.less files).

    It's on NuGet: http://nuget.org/List/Packages/LessCoffee

    It's based on this simple wrapper: https://github.com/duncansmart/coffeescript-windows

    0 讨论(0)
提交回复
热议问题