compile

fun compile(source: String, fileName: String, parentClassLoader: ClassLoader): ByteCodeRunner

Compile source to runnable JVM classes (inlining Event.*, auto-wrapping top-level code).

Tries, in order: the textual top-level wrap, the AST-based wrap, then the source as-is. Each attempt both compiles and force-loads the $ class, so a swc4j codegen bug that emits unverifiable bytecode is caught here and the next strategy is tried — a bad attempt can never escape as a raw VerifyError. The textual wrap is primary because the AST wrap slices the source using swc4j byte-position spans, which drift across the shared parser's lifetime (a later module sees offset spans) and can yield bad bytecode; the textual wrap is deterministic. If no strategy yields a loadable class, throws with the real cause.