It's possible, but you can also end up with monstrosities like GWT in the end. The best bet is to implement some Actor-like layer like https://github.com/Gozala/actor upon which the "ErlangScript" depends.
Oh wait, JS compile to Erlang? Wouldn't it make sense to do it the other way around?