Skip to content
This repository was archived by the owner on May 22, 2025. It is now read-only.
This repository was archived by the owner on May 22, 2025. It is now read-only.

Emit /*@__PURE__*/ before class declaration #452

Closed
@IgorMinar

Description

@IgorMinar

Based on this research, I believe that if we were able to emit a newly supported /*@__PURE__*/ annotation in front of class declaration and ensure that it gets preserved in the final down-leveled output, @angular/cli and any other Uglify-based build tool chains would be able to use dead-code elimination tricks to remove all unused classes (pipes, directives and components) with the exception of unused services.

There is a feature request microsoft/TypeScript#13721 to add this functionality to tsc, but it's unclear when/if it's going to be implemented, so I wonder how easy it would be to implement this kind of feature in tsickle so that we can experiment.

What I'd like is given the following input:

export class SomeClass {}

I'd like tsc + tscikle to output downleveled es5 code that looks like this:

var SomeClass = /*@__PURE__*/(function () {
  function SomeClass() {}
  return SomeClass;
}());

If for some reason we have a concern that /*@__PURE__*/ could cause headaches for Closure, we can also use /*#__PURE__*/, which is equally supported by Uglify.

More info:

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions