Unfortunately the project I'm working on lives entirely in the browser, there is no server as such. Very limited prepackaging is available.
1) Users specify a grammar and lexer in the browser
2) ANTLR is run in a JavaScript-based JavaVM to compile the corresponding lexers and parsers in the browser
3) Requirejs is used to import the generated lexer+parser back into the page to build parse-trees, transpilers etc.
In step (2) it is optimal to use the JavaScript target since the JavaScript ANTLR runtime is orders of magnitude faster to run than using the Java target and Java-runtime with the JavaVM option in the browser to also parse the code in step (3). When using the JavaScript target the parser runs natively in JavaScript in the browser with no overhead whatsoever. In comparison the JavaVM adds a LOT of overhead.
This worked with Antlr 4.8 when using requirejs to import the CommonJS modules generated in combination with the CommonJS-based JavaScript runtime.
Unfortunately now with 4.9+ the generated code being ESM and the JavaScript runtime still being CommonJS the browsers can no longer figure out how to load the generated code.
Personally I would prefer to have both the generated code and the runtime be ESM rather than CommonJS - that way there would be no requirement for requirejs anymore.
But it seems we are stuck in a kinda half-way-there scenario right now.
-- JBK