How can I compile CoffeeScript from .NET?

2019-01-30 04:53发布

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 don't want to use [Rhino][2] because the Java dependency would make it too difficult to distribute.

How can CoffeeScript be compiled from .NET?

18条回答
Viruses.
2楼-- · 2019-01-30 05:20

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.

查看更多
小情绪 Triste *
3楼-- · 2019-01-30 05:20

You might also want to check out jurassic-coffee, it is also a coffee-script compiler running the original compiler in jurassic.

It features sprocket style "#= require file.coffee" or "#= require file.js" wich can be used to keep .coffee files modular and combined right before compilation as well as embedding .js files.

It sports a HttpHandler with file watchers for .js and .coffee files that keeps track of what .coffee files needs to be re-compiled and pass through to the compiled *.js files for the rest.

jurassic-coffee is also available as a Nuget package

https://github.com/creamdog/JurassicCoffee

查看更多
祖国的老花朵
4楼-- · 2019-01-30 05:22

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

查看更多
SAY GOODBYE
5楼-- · 2019-01-30 05:25

Since the CoffeeScript compiler now runs on Internet Explorer, after a couple of recent tweaks, it should be good to go within other MS-flavors of JavaScript as well. Try including extras/coffee-script.js from the latest version, and you should be good to go with CoffeeScript.compile(code).

查看更多
等我变得足够好
6楼-- · 2019-01-30 05:27

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.

查看更多
姐就是有狂的资本
7楼-- · 2019-01-30 05:28

CoffeeScript is now fully supported by Chirpy: http://chirpy.codeplex.com/

查看更多
登录 后发表回答