- Notifications
You must be signed in to change notification settings - Fork 2k
Closed
Description
JavaScript minification tools rename local functions for performance, and this mangles CoffeeScript class names too.
Since Function.name is a read-only property, forcing class names which implemented in #494 does not work.
How about setting class name to some other property, like Foo.__name__
or Foo.className
?
A brief example
class Foo constructor: -> console.log(this.constructor.name) foo = new Foo()
Compiles into
(function() { var Foo, foo; Foo = (function() { Foo.name = 'Foo'; function Foo() { console.log(this.constructor.name); } return Foo; })(); foo = new Foo(); }).call(this); // Outputs 'Foo'
Minified
(function(){ var a,b; a=(function(){ a.name='Foo'; function a(){ console.log(this.constructor.name); } return a; })(); b=new a(); }).call(this); // Outputs 'a'