Closed thekalinga closed 4 years ago
Integrating TypeScript compilation is a big challenge that, frankly, I don't think should be handled directly by Orchid. SCSS is a little different in that it's handled just as a library and doesn't require integration with other tooling, like TypeScript would require.
The Node ecosystem is really difficult and brittle to integrate with directly, and it's better to just use the Webpack/Angular CLI or whatever to compile your frontend assets separately from Orchid, and then let Orchid pick up the generated assets afterward. I have issue #302 which would provide a standard way to implement this kind of feature, but until that's available I'd suggest just manually running your Angular build before the Orchid build.
I'm a bit noob in this area
Is it the case that we have java libraries to process SCSS, but not for Typescript?
No worries! And yes, that is the case. Sass is actually a C library and has a bunch of wrapper libraries in other languages. In Java, we have jsass that wraps that C library with JNI to compile SCSS to CSS. All the tools that compile Sass from Webpack or other frontend build systems do something similar.
The Typescript compiler is itself written in Typescript and can only be run from Node, so you'd need the Node runtime in order to use it. About the best Orchid could do to compile Typescript is to run the native shell commands for an existing Angular project.
Thanks for that detailed explanation. Shall I close this as this issued already refers to the other open issue?
Is this helpful in any way (they point to some eclipse version. Not sure if language server can compile along with giving suggestions. I think they are launching node to launch the language server which itself is written in typescript)
That project seems a bit outdated and also looks to mostly be static analysis, not necessarily running JS code. For actually running JS in a JVM, I think GraalVM would be the best option.
But like I mentioned earlier, I don't think this is something that should be natively handled in Orchid. There's bound to be issues with the integration, and relative to the complexity in getting it working I just don't think it would be worth it. And except for SSGs based in web technologies like Gatsby, it's pretty commonly accepted that the asset compilation pipeline is best handled separately. You'll find the same thing in Hugo, Jekyll, Middleman, and even full backend CMS frameworks, where the frontend asset pipeline is simply too complex and diverse to be handled natively, and should just be run on its own and have the outputs copied back to the theme.
As of now, we need to write everything in javascript, but typescript is a far better alternative & also has type support (+ java like, which is other advantage)
Just like SCSS support, can you also add typescript support so that people can create themes using Angular framework