build!: Modernise build to ANTLR 4.13.2 / antlr4 runtime; bump to 2.0.0-SNAPSHOT#8
Conversation
Replace antlr4-maven-plugin with exec-maven-plugin + build-helper-maven-plugin running ANTLR 4.13.2 directly, so the JVM and (eventually) npm sides share a single generator. ANTLR runtime bumped 4.9.1 -> 4.13.2 to match apex-parser and unblock downstream apex-ls. Maven plugins, JUnit, and Java toolchain all brought current; publishing switched from the legacy nexus-staging-maven-plugin (OSSRH s01) to central-publishing-maven-plugin (Sonatype Central Portal). CI Java bumped 8 -> 11 since <release>8</release> requires JDK 9+ to compile. Refs #6
ANTLR copies @lexer::members and @parser::members blocks verbatim into generated sources, so the existing Java clearCache() helper breaks the TypeScript target. Split each grammar into a language-neutral base file and a per-target overlay (mirroring apex-parser): - /antlr/BaseVF{Lexer,Parser}.g4: shared rules, no embedded actions - /jvm/antlr/VF{Lexer,Parser}.g4: thin overlays adding the Java helper via @members and importing the base The npm side will add its own (action-free) overlays in a follow-up. clearCache() still appears on both VFLexer and VFParser on the JVM side, preserving the apex-ls API surface. Refs #6
Replaces the abandoned antlr4ts 0.5.0-alpha.4 fork with the official
antlr4 4.13.2 runtime (bundled). Generation is now driven by the same
Java ANTLR tool used by the JVM side, via a new npm/pom.xml that runs
exec-maven-plugin with -Dlanguage=TypeScript against the npm/antlr
overlay (which imports the shared BaseVF*.g4 files).
This is a breaking change for consumers — hence the major bump on both
artifacts:
- ThrowingErrorListener now extends antlr4's ErrorListener<Token | number>
(was: implements ANTLRErrorListener<Token>); SyntaxException is now
an Error subclass.
- Package is ESM-only ("type": "module"), with an exports map and
dist/src layout. Node engines bumped to ^20.19 / ^22.13 / >=24.
- Lexer/Parser are exported as default classes via subpath /antlr/*.
- node-dir dropped; check() now uses node:fs/promises recursive readdir.
Tooling bumps:
- patch-package + patches/antlr4+4.13.2.patch (lifted from apex-parser)
replaces the bespoke shelljs sed in npm/patch.
- ESLint v10 flat config (typescript-eslint v8) replaces the legacy
.eslintrc.js.
- tsconfig: es2022 / node20 / strict.
- jest regex points at dist/test/, and npm/.npmrc enables the
experimental-vm-modules flag so jest can load the ESM build.
Root package.json scripts switched to apex-parser's
init / build / build:jvm / build:npm layout; init:npm now runs
mvn exec:exec rather than copying .g4 files into per-target dirs.
Refs #6
The new npm/package.json declares node engines ^20.19 || ^22.13 || >=24, which Node 14 can't satisfy. Build.yml also needs to populate node_modules before the build step now that the npm side is rewritten around npm ci + patch-package. PublishMaven.yml and PublishNPM.yml were still calling the old init-jvm / build-npm script names; renamed to init:jvm / build:npm.
|
@codex review |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: c769ef29af
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| "antlr": "mvn exec:exec", | ||
| "build": "npm run clean && npm run antlr && tsc", | ||
| "build:test": "npm run build && npm test", | ||
| "check": "node -e 'require(\"./dist/src/index.js\").check()'", |
There was a problem hiding this comment.
Replace CommonJS require in ESM check script
The package is now explicitly ESM ("type": "module"), but the check script still invokes require("./dist/src/index.js"). On Node 20+ this throws ERR_REQUIRE_ESM, so npm run check fails before parsing any files. This regression affects anyone using the maintained smoke-check command after building the package.
Useful? React with 👍 / 👎.
The npm package is "type": "module", so the existing CommonJS require() in the check script throws ERR_REQUIRE_ESM on Node 20+. Switch to import() — works in both CJS and ESM contexts without --input-type. Caught by Codex review on #8.
Combines the JVM and npm modernisation into a single PR — they're tightly coupled (the grammar split has no value without the npm overlay that consumes it), so splitting hurt more than it helped.
Tracked in #6.
Summary
exec-maven-plugingeneration, all Maven plugins current, JUnit 5.14.3,<release>8</release>, switched from legacynexus-staging-maven-plugin(OSSRH s01) tocentral-publishing-maven-plugin(Sonatype Central Portal). CI JDK 8 → 11;PublishMaven.ymlserver-id: ossrh→central./antlr/BaseVF{Lexer,Parser}.g4+ per-target overlays underjvm/antlr/andnpm/antlr/. JavaclearCache()helper now lives only in the JVM overlay (apex-ls's API surface preserved); TypeScript output is no longer polluted with embedded Java.antlr4ts0.5.0-alpha.4 → bundledantlr44.13.2. Generation driven by the same Java tool the JVM uses, vianpm/pom.xml. ESM-only (type: module, exports map,dist/srclayout), Node 20+, ESLint v10 flat config,patch-package+patches/antlr4+4.13.2.patch(lifted from apex-parser) replaces the bespokeshelljs sed.2.0.0-SNAPSHOTto reflect the breaking surface (ESM, newThrowingErrorListenerAPI, Node engines, exports).Breaking changes (npm consumers)
ThrowingErrorListenerextendsErrorListener<Token | number>fromantlr4(wasimplements ANTLRErrorListener<Token>fromantlr4ts).SyntaxExceptionis now anErrorsubclass.^20.19 || ^22.13 || >=24.VFLexer/VFParserexported as default classes via subpath./antlr/*.node-dirdependency removed;check()usesnode:fs/promises.Commits
Base*.g4+ per-target overlays.Test plan
rm -rf npm/{node_modules,dist,src/antlr} jvm/target && npm run init && npm run build— greennpm test --prefix npm— 2/2 passingclearCache()present on generatedVFLexer.java/VFParser.javanpm run lint --prefix npm— cleanapex-lsbuilds against a local 2.0.0-SNAPSHOT package — out of scopeNotes for the next release
MAVEN_USERNAME/MAVEN_TOKENGitHub secrets need to be a Sonatype Central Portal user token (not the legacy OSSRH one) when the next release fires.2.0.0-SNAPSHOTis Maven-style; npm itself prefers2.0.0-beta.1. Worth aligning before any actualnpm publish.Closes #7 (superseded). Refs #6.