mike-lischke / antlr4ng

Next Generation TypeScript runtime for ANTLR4
Other
85 stars 15 forks source link

build: add --keep-names option to build command #41

Closed HaydenOrz closed 7 months ago

HaydenOrz commented 7 months ago

To Resoved https://github.com/mike-lischke/antlr4ng/issues/38

What's changed

Enabling --keep-names option will change the bundle, as shown below:

  1. Two new lines of code have been added to the file header, which are used to keep the name of the class or function

    var __defProp = Object.defineProperty;
    var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
  2. A static methods will be added to all classes(in the case of ParseTreeWalker):

    var ParseTreeWalker = class _ParseTreeWalker {
      static {
        __name(this, "ParseTreeWalker");
      }
      // ...
     }