如何在没有包装函数的情况下将.coffee构建成.js

Val*_*sin 2 node.js coffeescript npm

我正在使用'coffee-script` npm包:

var coffee = require('coffee-script');
var source = coffee.compile('target.js');
Run Code Online (Sandbox Code Playgroud)

我在source变量里面编译了js .但它也包含在自我调用函数中.我不需要那个调用,b/c我Webmake用来管理依赖项,包装每个文件..我将有2个调用.

"some.js": function (exports, module, require) {
  (function() {
    var n;
    n = 5;
    alert("hello world " + n);
  }).call(this);
}
Run Code Online (Sandbox Code Playgroud)

如您所见,我不需要咖啡脚本调用.PS我找不到任何关于CoffeeScript.compile第二个参数的选项的文档.compile.你能告诉我这些信息吗?谢谢.

Jam*_*lin 5

尝试添加{ bare: true }第二个参数compile.

(但是,将代码包装两次不会造成任何伤害.这是出于美观原因吗?)