Skip to content

Class name mangled after minification #2052

@wuyuntao

Description

@wuyuntao

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'

Metadata

Metadata

Assignees

Labels

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions