Closed moongazer07 closed 8 months ago
There are some js to c/wasm transpilers but:
Very, very tricky --- Javascript is a heavily dynamic language where pretty much everything can be changed at run time: object properties, functions, types, etc. As such it maps very badly onto C. Any Javascript translator would have to be able to cope with such things, which means it would have to translate the Javascript into machine code at run-time - which makes it a JIT, which we're already using.
So a transpiler that supported every js feature would still be slower overall.
https://www.assemblyscript.org is very similar to js/ts but would also require rewriting or substantially modifying all libs, in which case using another language is most likely a better choice
For ease of others following along, this thread started in this issue:
And continues in this issue:
swc is probably the closest thing to babel but still too limited:
Originally posted by @j4k0xb in https://github.com/j4k0xb/webcrack/issues/22#issuecomment-1803577842 you could also transpile the libs if possible