Closed pdalibor closed 8 months ago
Usually, such an error comes up when you try to import a file it is being processed already (aka circular dependencies). However, because of the bundle this should not be an issue at all.
The code from your report seems to indicate this is about the CharStreamImpl
class, which is used by CharStreams
. I don't know Angular (and guess it uses webpack under the hood), so it might be that the CharStreamImpl
has been optimized out with your setting.
CharStreamImpl seems to be available, but I was unable to identify the real reason for the error. Despite that, I was able to solve the problem. For anyone else encountering the same issue in an Angular application, here is what I have done:
In Angular 17, the default builder has been changed from webpack
to esbuild
package bundler. This means that in the angular.json file, "builder": "@angular-devkit/build-angular:browser"
needs to be replaced with "builder": "@angular-devkit/build-angular:application"
.
Glad you could solve the issue and thanks for letting us know. Closing this one then...
We encountered an issue when upgrading from antlr4ts and antlr4-c3 to their latest versions at a time (antlr4-c3 v3.3.5 and antlr4ng v2.0.4). While there were no issues in Angular (v17) development mode, we encountered a runtime error in a production mode with the scripts optimization flag set to true in angular.json. The error message was: "ReferenceError: u0 is not defined." The error points to the following part of the minified JavaScript code:
In our code, we initialize the lexer and parser as follows:
The methods from the problematic section of the JavaScript code are defined in the antlr4ng CharStream.
We attempted to upgrade antlr4ng to version 2.0.8 to address the issue but encountered a compile error as described in https://github.com/mike-lischke/antlr4ng/issues/26 Then, we made a temporary workaround: Changed default[] to any[] as suggested in the mentioned issue, but the error persisted (slightly different javascript code: new u0(), class is now new u0, class