tunnelvisionlabs / antlr4ts

Optimized TypeScript target for ANTLR 4

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Getting errors with Angular6

yperess opened this issue · comments

When building a new project using ToT angular cli I'm getting the following error:

Uncaught ReferenceError: Cannot access 'process' before initialization

I then added the following to polyfills.ts:

(window as any).process = {
  env: { DEBUG: undefined },
};
(window as any).global = window;

This resolves the issue, though I can't tell you that I'm certain why.

I think antlr4ts was implemented for server-side node applications. This is also reflected in the missing dependency "assert".

Fortunately, assert can be installed as a dependency. I solved the problem with the global process variable by adding the following to index.html:

  <script type="application/javascript">
    /**
     * ANTLR4TS thinks we are in a nodejs environment
     */
    window.process = {
      env: { DEBUG: undefined },
    };
    window.global = window;
  </script>