TypeScript support
Currently, in order to execute TypeScript code inside GraalJS, one should use the TypeScript compiler (or some other compiler like swc or esbuild) in order to prepare the sources for execution in GraalJS. Although this is possible, there are some disadvantages like:
- supporting an extra build step which is quite different from standard Java setups
- good understanding of how TypeScript modules are translated to JavaScript modules and using a custom Truffle File System for resolving them
- additional configuration for debugging support
Having a way to execute TypeScript code in a Truffle context would simplify all those aspects as ideally the developer should be concerned only with writing his code and not dealing with any additional setup. Any necessary configurations should be done using the standard way of configuring a Graal context through its options.
Having said that, I have created a PoC how I imagine TypeScript support could look like:
- https://github.com/vmutafov/graalts
It would be great to hear your thoughts about it and see if it's possible to contribute this into GraalJS itself. Huge thanks to @chumer for providing valuable feedback and support for implementing this!
Related issue: https://github.com/oracle/graaljs/issues/611.
A TSC based solution usually is 10x-20x slower than an SWC / esbuild based one. It might be worthy of checking Run TypeScript Directly in Java out.