Updating codegen
disnet opened this issue · 1 comments
I have a PR to add async
/await
support #741 and @slotik is working on adding type nodes to sweet's AST sweet-js/sweet-spec#4. Both of these efforts require some way of doing codegen but at the moment we are relying on shift-codegen which only supports ES2016 (no async/await). Shift-codegen will be updated to ES2017 soon but it is unlikely to get support for type annotations so what should we do?
There are a few options I can see.
- Fork shift-codgen and add type annotation support ourselves. This involves also forking shift-spec and shift-reducer.
- Write our own sweet-codegen using sweet-spec.
- Convert our AST to a babel AST (which supports type nodes) after expansion and let babel do our codegen.
At the moment I'm leaning towards the babel option since I think it's the least amount of work for us and often you want to use babel as a backend anyway. Arguably writing our own codgen is the best long-term since that give us the most flexibility (and it would allow us to do things like rendering syntax declarations syntax m = ctx => ...
).
Thoughts? Am I forgetting an option?
/cc @gabejohnson
I'd be in favor of the Babel option. Perhaps even better would be to do an AST transform instead. Then handoff to Babel. See #515 and shapesecurity/shift-spidermonkey-converter-js#16