Skip to content

Add the wasmJs target - #75

Open
cloudigits wants to merge 2 commits into
h0tk3y:masterfrom
cloudigits:wasmjs-target
Open

cloudigits wants to merge 2 commits into
h0tk3y:masterfrom
cloudigits:wasmjs-target

Conversation

@cloudigits

Copy link
Copy Markdown

Closes #74.

What

Adds the wasmJs target. js and wasmJs form a single web source set in Kotlin's default hierarchy, and Compose Multiplatform builds web as Wasm-first with Kotlin/JS as the fallback, so a js-only artifact misses the half modern browsers run.

Why the toolchain bump is part of this

wasmJs does not exist in Kotlin 1.6.20, and the current build does not configure under any Kotlin that has it: the presets API, js(BOTH), the kotlin("js") plugin and jvmTarget = "1.6" are all removed. The bump is a prerequisite, not a separate cleanup, so it is here as its own commit for separate review.

Source changes beyond the new actual

Metadata compilation requires RegexToken to declare match() on the expect class, with each actual marked actual override. It also rejects @Language in nativeMain, since @OptionalExpectation is limited to common sources; jsMain already omitted it for the same reason. Token.match() stays abstract.

Targets

Kept every target 0.4.4 publishes that Kotlin still supports, including the four androidNative* ones. Dropped only what Kotlin removed: iosArm32, linuxArm32Hfp, linuxMips32, linuxMipsel32, mingwX86, wasm32, watchosX86. Added watchosDeviceArm64.

Verified

commonTest green on jvm (44), js node and browser (41 each), wasmJs node and browser (41 each), macosArm64 (41), iosSimulatorArm64 (41). assemble green for all targets. Demos, benchmarks and POM generation all still build.

One thing worth your call

wasmJsMain/RegexToken.kt is byte-identical to nativeMain's. The js implementation relies on a sticky-flag RegExp via asDynamic(), which Kotlin/Wasm has no equivalent for, so wasmJs uses the \A-anchored native form. I left it duplicated rather than introducing a custom source-set group shared by native and wasmJs. Happy to do that instead if you prefer.

kotlin-js-store/yarn.lock is generated by the js/wasmJs setup and not included, since committing it is a repo-policy call. Let me know and I will add it.

azevio added 2 commits July 29, 2026 01:50
The presets API, js(BOTH), the kotlin("js") plugin and jvmTarget 1.6 are all
gone in current Kotlin, so the existing build no longer configures. Targets are
now declared explicitly and the default hierarchy template replaces the manual
nativeMain wiring.

Metadata compilation additionally requires RegexToken to declare match() on the
expect class, with each actual marked accordingly, and rejects @language in
nativeMain because @OptionalExpectation is limited to common sources (jsMain
already omitted it for the same reason).

Native targets removed from Kotlin since 0.4.4 (iosArm32, linuxArm32Hfp,
linuxMips32, linuxMipsel32, mingwX86, wasm32, watchosX86) are dropped; every
other published target is kept and watchosDeviceArm64 is added.
js and wasmJs form a single web source set in Kotlin's default hierarchy, and
Compose Multiplatform builds web as Wasm-first with Kotlin/JS as the fallback,
so a js-only artifact leaves out the half modern browsers run.

The actual mirrors nativeMain rather than jsMain: the js implementation relies
on a sticky-flag RegExp reached through asDynamic(), which Kotlin/Wasm has no
equivalent for, so the \\A-anchored form is used instead.
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.

Add the wasmJs target

2 participants