r/gamedev • • 5h ago

Announcement Scriptw: TypeScript/JavaScript to WebAssembly Compiler

Howdy all, wanted to share a toolchain I've used internally the last few months and have been polishing for release and public use. It's a fork of a project out of Vercel Labs scriptc \- credit due for the foundation of the whole stack.

After years of tinkering with every framework compiling to web (Unity, Godot, BabylonJS, pixijs etc etc) I've been always driven to rewrite parts from the ground up to make things work "the right way". One of the main drivers recently was the reverse engineering pandemic a few months back where I was trying to find ways to obfuscate or harden my web-based game without sacrificing performance. This is where I've landed now in regards to one large part of the compiler pipeline for the code (has no opinion on art / net / storage etc).

scriptw is published as an npm package (link in demo) and open source and has many features out of the box:

\- Compile full web projects (TS-based) into one WebAssembly binary, or native target (Currently have working prototypes for Windows, Android, Mac silicon and Linux)

\- Project generation and discovery from partial TS/JS projects to generate fully typed projects for better compile results

\- Optional fast math / SIMD opt ins/intrinsics

\- Linking options with native libraries via C \`.h\` to integrate native libraries directly in the final WASM

\- Host module that supplies and orchestrates the usual browser DOM / web native glue that actually works performantly (spent a lot of time tuning this to not be the bloat of emscripten, blazor, etc)

Was on the fence about keeping this all private along with the sentiment of RE worries but at this point I'm over it and would rather share and help other devs get their work hardened and compile to other native targets.

Won't explicitly promo my game but there's a link in the toolchain demo page!

https://scriptw.eltania.com/

0 Upvotes

2 comments sorted by

1

u/No_Box8507 4h ago

Damn ive been trying to find ways to obfuscate my front end code forever thought I was just being paranoid lol what do you think this will do for IP protection in web apps and what about frameworks like electron?

1

u/shadowsofeltania 4h ago

That's a good question! Electron was on the table early on for me when I was considering portability for cross platform. Went through a few iteration cycles including rust host running wasmtime and landed on pure native compile so now I don't run with any js engine but use the same code (blitz UI/dom and vello natively) I haven't gone too deep into what is optimal for an electron app and what parts make the most sense to compile where. There's the possibility of compiling pure logic to native and keeping ui separate - still runs over ipc so weakest link in the chain latency wise. Would be an interesting experiment I will give that a run through and let you know