antlr4ts
antlr4ts copied to clipboard
Use of package`rollup` to address packaging issues, browser compatability, etc.
I've been thinking (for years now) that this project faces a number of issues regarding platform portability that must have some best-practice solutions in the existing node/browser/typescript ecosystem.
I think I've found a TypeScript based architype to consider at https://github.com/MattiasBuelens/web-streams-polyfill . Just examining the directory structure of this project makes clear some options I've only been guessing at till now.
The web-streams-polyfill package builds into a outputs with different JavaScript target flavors, (e.g. , including versions compatible with several different versions of both Node.js and different browser's. At build time, this is being done using a build-orchestrator tool called rollup.
Both rollup and web-streams-polyfill seem well maintained to have active user communities.
It appears that rollup may be an alternative to webpack for generating browser-consumable packaging, so this may be an alternative approach to implementing #343, and to fixing bugs reported in browser environments like #283, #310, #326, etc.
If anyone interested in the antler4ts has experience with rollup, now would be a good time to speak up.
I played around with rollup for this quite a bit yesterday. In short, I don't think it'd work due to the circular dependency issues (your bundles would likely fail at runtime):
https://github.com/tunnelvisionlabs/antlr4ts/issues/466
That said, Webpack likely would work (there's an example in the link above of a package that wraps cashc + antlr4ts using Webpack).
There is this package now though https://github.com/antlr/antlr4/tree/dev/runtime/JavaScript which does have TS declarations (and is a bit more active), so it might be worth considering working off that base.