Angular4: Component.name doesn't work on production

后端 未结 4 1693
有刺的猬
有刺的猬 2021-01-03 10:42

So I\'ve been facing this weird issue but I\'m not sure if it\'s a bug or it\'s me missing something here.
So I have a component called TestComponent and in

4条回答
  •  独厮守ぢ
    2021-01-03 11:35

    Function name contains actual function name. If the function is minified to one-letter name, it loses its original name. It should never be relied on in applications that can possibly be minified at some point i.e. every client-side application. There may be exceptions for Node.js.

    name is read-only in some browsers and and thus can't be overwritten. If a class needs identifier, it should be specified explicitly under different name:

    class Foo {
      static id = 'Foo';
      ...
    }
    

    Here is a related question.

提交回复
热议问题