Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for Typescript #337

Closed
thekalinga opened this issue Dec 6, 2019 · 6 comments
Closed

Add support for Typescript #337

thekalinga opened this issue Dec 6, 2019 · 6 comments

Comments

@thekalinga
Copy link

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

@cjbrooks12
Copy link
Contributor

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.

@thekalinga
Copy link
Author

thekalinga commented Dec 6, 2019

I'm a bit noob in this area

Is it the case that we have java libraries to process SCSS, but not for Typescript?

@cjbrooks12
Copy link
Contributor

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.

@thekalinga
Copy link
Author

Thanks for that detailed explanation. Shall I close this as this issued already refers to the other open issue?

@thekalinga
Copy link
Author

thekalinga commented Dec 6, 2019

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)

https://github.com/angelozerr/tern.java

@cjbrooks12
Copy link
Contributor

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants