Skip to content

Hard fork latest Goja with PCRE2 and integrated NodeJS - #1

Merged
VillanCh merged 6 commits into
masterfrom
codex/hard-fork-pcre2-nodejs
Aug 31, 2026
Merged

VillanCh merged 6 commits into
masterfrom
codex/hard-fork-pcre2-nodejs

Conversation

@VillanCh

@VillanCh VillanCh commented Aug 31, 2026 •

Copy link
Copy Markdown
Contributor

Summary

  • hard-fork dop251/goja at 8f1c0696a37b221d3b14dc4c2e826cc22a6b723d
  • integrate dop251/goja_nodejs at 1f56ff5bcf1444844c756986ed5fc03069aec1ff under nodejs/
  • use one root module at github.com/yaklang/goja, targeting Go 1.22.12
  • completely remove github.com/dlclark/regexp2 from source and the production module graph
  • retain RE2 as the fast path and use go-pcre2-lite v0.1.6 / embedded PCRE2 10.47 as the only backtracking backend
  • support ECMAScript right-to-left lookbehind captures, nested assertions, and internal/external/forward/mutual backreferences without skipping Test262 cases
  • cache identical regular-expression literals per compiled Program by (pattern, flags) while keeping each RegExp object's mutable state independent
  • add cgo/no-cgo adapters, surrogate compatibility tests, production-bundle benchmarks, and CI module-policy enforcement

Dependency proof

  • exactly one go.mod and one go.sum in Goja
  • go list -m all contains github.com/VillanCh/go-pcre2-lite v0.1.6 and no github.com/dlclark/regexp2
  • no github.com/dlclark/regexp2 reference exists in Go source, go.mod, or go.sum
  • the published PCRE2 repository and module have no dlclark/regexp2 development or production dependency; its complete module graph contains only itself

Validation

  • go test -count=1 ./...
  • go test -race -count=1 ./...
  • go test -count=1 -run '^TestTC39$' .
  • CGO_ENABLED=0 go test -run '^$' ./...
  • go vet ./...
  • go mod verify
  • npm test --workspaces --if-present in nodejs/
  • compiled and benchmarked a real 28.09 MiB minified Yakit production bundle

Performance snapshot

Apple M1 Max, darwin/arm64, Go 1.22.12, cgo enabled, three iterations:

Operation 5 MiB 20 MiB Ratio
Parse 133.1 ms 529.3 ms 3.98x
Compile 249.0 ms 968.7 ms 3.89x
Execute compiled 19.96 ms 94.39 ms 4.73x
Cold load 265.9 ms 1.086 s 4.08x

The measured workload scales approximately linearly with source size. The real 28.09 MiB Yakit bundle compiled in 1.752 s at 16.81 MB/s. See BENCHMARK.md for commands and allocation data.

Compatibility note

Go 1.22 lacks weak.Pointer and runtime.AddCleanup. The compatibility layer stores WeakMap/WeakSet entries on key objects. Observable JS behavior is preserved, but values may remain reachable while their keys remain reachable after the collection is collected. This is documented in FORK.md and should be revisited when Yaklang moves to Go 1.25.

@VillanCh
VillanCh merged commit 68cdec2 into master Aug 31, 2026
12 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant