2013-01-22 84 views
0

我刚刚开始使用CodeKit,迄今为止它非常棒,但我在包含CoffeeScript文件中的JavaScript文件时遇到了麻烦。CodeKit编译错误,包括咖啡文件中的JS文件

在CoffeeScript的文件我也行:

# @codekit-prepend './vendor/backbone.js' 

这将导致以下错误:

SyntaxError: In /var/folders/t1/h24_m5yx2yq5sjc2jztvh2xr0000gn/T/CodeKitTempFolder.rrBQ5JI7WP7b1dQ/temp.coffee, reserved word "function" on line 27 
at SyntaxError (unknown source) 
at Lexer.exports.Lexer.Lexer.error (/Users/makala/Downloads/CodeKit.app/Contents/Resources/engines/coffee/lib/coffee-script/lexer.js:682:13) 
at Lexer.exports.Lexer.Lexer.identifierToken (/Users/makala/Downloads/CodeKit.app/Contents/Resources/engines/coffee/lib/coffee-script/lexer.js:86:16) 
at Lexer.exports.Lexer.Lexer.tokenize (/Users/makala/Downloads/CodeKit.app/Contents/Resources/engines/coffee/lib/coffee-script/lexer.js:33:19) 
at Object.exports.compile.compile (/Users/makala/Downloads/CodeKit.app/Contents/Resources/engines/coffee/lib/coffee-script/coffee-script.js:47:32) 
at compileScript (/Users/makala/Downloads/CodeKit.app/Contents/Resources/engines/coffee/lib/coffee-script/command.js:182:33) 
at fs.stat.notSources.(anonymous function) (/Users/makala/Downloads/CodeKit.app/Contents/Resources/engines/coffee/lib/coffee-script/command.js:152:18) 
at fs.readFile (fs.js:176:14) 
at Object.oncomplete (fs.js:297:15) 

的CoffeeScript的文件完全编译没有该行。

我试图预先的JS文件是而不是直接编译,并且是“连接+缩小”。 CS文件是而不是被JSHint/Lint检查,并且缩小。

我想这个错误可能是由于缺少错误抑制(请参阅“JavaScript和CoffeeScript导入”>“抑制错误”,位于http://incident57.com/codekit/help.php)。但是“显示错误”复选框在CodeKit应用程序中不可见。

哦,还有一件事,输出的JavaScript文件包含原始咖啡文本。我不确定这是编译失败的原因还是结果。

什么可能导致编译失败的想法?

感谢您的期待:)。

回答

2

For technical reasons (variable/function shadowing, etc), it's not possible to combine CS and JS files directly. What you'd need to do is create a NEW Javascript file that imports (using the prepend/append statements) the OUTPUT file that is generated when your CS file is compiled and the JS file you want to import.

Then, whenever you save your Coffee file, CodeKit will do the right thing and recompile the javascript file. Cheers!

来源:布莱恩·琼斯,CodeKit作者