WebStorm wraps transpiled CoffeeScript classes into self calling function

As in the topic. Is there any option that when I translate .coffee file into .js it will look like the one I would translate onto CoffeeScript official webpage? For example(from cs page):

 
class animal
  constructor: (@name) ->

  move: (meters) ->
    alert @name + " moved #{meters}m."
  
in webstorm is translated to:

(function() {
  var animal;

  
animal = (function() {
    function animal(name) {
      this.name = name;
    
}

    animal.prototype.move = function(meters) {
      return alert(this.name + (" moved " + meters + "m."));
    
};

    return
animal;

  
})();

}).call(this);
  
and I cant get instance of this class outside animal.coffee file. Is there any option that webstorm would automaticly output .js file like this?:
 
var animal;

animal = (function() {
  function animal(name) {
    this.name = name;
  }

  animal.prototype.move = function(meters) {
    return alert(this.name + (" moved " + meters + "m."));
  };

  return animal;

})();


Maybe it is some silly question, but I just started using webstorm and I cant find any information about this issue. For any help I would be gratefull.

1 comment
Comment actions Permalink

It is not WebStorm, it's a CoffeeScript compiler:) If you like to change this default behavior, you have to pass '--bare' option to compiler. Just add it to file watcher arguments, like:


--bare --map --compile $FileName$


See attached screenshot.

Refer to http://coffeescript.org/, Usage section:

-b, --bare
                   Compile the JavaScript without the           top-level function safety wrapper.         


Attachment(s):
bare.png
0

Please sign in to leave a comment.