You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Would be useful to be able to use gradle+jvm to run tsc directly to reduce complexity in our build system (today we use gradle to run node to run grunt to run tsc).
Some recent improvements in the JDK suggest this is likely now a fast enough environment (1). Others have tried in the past, so it is definitely possible (2,3).
Looks like someone's done the basic work here: https://github.com/coudy/typescript . We can discuss whether or not taking a PR on this would be appropriate.
First, before anyone tries to work with that directly, that Nashorn system implementation is for the old compiler. Still should be easy enough to rewrite.
These plans will also solidify more for future Java releases, and we hope that Nashorn eventually will turn into a kind of "LLVM for dynamic languages on the JVM". The optimistic typing problem comes back to every dynamic language. To prove this, our excellent thesis student Andreas Gabrielsson has successfully implemented almost everything required to run TypeScript on Nashorn. At the time of this writing, modules in the only large feature missing. Nashorn goes directly to bytecode from TypeScript without generating JavaScript in a mid-level compiler tier. This is pretty awesome and shows how extensible Nashorn already is. We have thought about Ruby and Groovy running in a similar environment. Nashorn TypeScript is still not open sourced, but we hope we have the chance to do it soon.
Not that this should dissuade contributions, but something we should consider discussing further.
My suspicion is that even when TS code is directly runnable on Nashorn that we would still need a Nashorn-specific IO module for tsc, so that tsc itself is also runnable.
I was able to run tsc on Avatar.js without much trouble, though I have not tested it thoroughly. You might be interested in a proof-of-concept Maven plugin that I put together this week: Maven TypeScript Compiler Plugin
This would be great to see! It would be nice to get contacts at Oracle to see if they still plan on open sourcing their Nashorn TypeScript. Otherwise, Apigee's rowboat project is set to use Nashorn instead of Rhino for the JavaScript Engine like trireme does. It may be worth trying out.
Just for your information, I have implemented ternjs server to consume it in Java context with tern.java with several JavaScript engine (node.js, J2V8, Nashorm and Rhino) and the performance is not very good with Nashorn (I have not benchamrk, but when I consume ternjs with Nashorm (like open completion with a lot of JS files), Eclipse freezes a little although with node.js it is very fast)
In other words with ternjs, for performance I have : node.js > J2V8 > Nashorm > Rhino.
I usually run TypeScript compiler using node. When I have Java project with TypeScript code and I don't want to force others to install Node.js I use frontend-maven-plugin which installs node and npm automatically.
But I also wanted to allow users to customize my Java application using TypeScript expressions, snippets, plugins... For this feature I need to run TypeScript compiler inside Java VM so I created PR.
With this PR it should be possible to implement for Java something like typescript-simple.
Vladimir Matveev (@vladima) I was thinking that TypeScript services also need System that's why I wanted first make tsc work. But apparently ts.transpileModule doesn't use System.
ts.transpileModule is probably sufficient in my case. I just tried to compile "Hello world" program with typescriptServices.js running on Nashorn and it worked. It took about 10 seconds which is about 4 times faster than tsc running on Nashorn. This might be usable in cases where caching is possible (and ts code doesn't change often).
Given the perf characteristics of running the compiler on nashorn (see more in #8565 (comment)), and the support requirements on the core ts team, we will have to decline this request in the time being. we can revisit this in the future if any of these assumptions change.
The purpose of this project is not just to Make tsc runnable on Nashorn. Just wanna make JDK and Maven libraries actually programmable in TypeScript (without quirky hacking).
Activity
bavardage commentedon Jan 23, 2015
👍
RyanCavanaugh commentedon Jan 23, 2015
Looks like someone's done the basic work here: https://github.com/coudy/typescript . We can discuss whether or not taking a PR on this would be appropriate.
DanielRosenwasser commentedon Jan 23, 2015
First, before anyone tries to work with that directly, that Nashorn system implementation is for the old compiler. Still should be easy enough to rewrite.
Second, note the following from the somewhat recent Nashorn announcement:
Not that this should dissuade contributions, but something we should consider discussing further.
markelliot commentedon Jan 23, 2015
My suspicion is that even when TS code is directly runnable on Nashorn that we would still need a Nashorn-specific IO module for tsc, so that tsc itself is also runnable.
basarat commentedon Jan 23, 2015
Mark Elliot (@markelliot) I suspect you will inevitably need node for some other project that does something useful with your JavaScript/CSS
DanielRosenwasser commentedon Jan 24, 2015
Or a Node-compatible interface exposed from Java.
DanielRosenwasser commentedon Jan 27, 2015
The linked blog post mentions:
wmono commentedon Mar 28, 2015
I was able to run tsc on Avatar.js without much trouble, though I have not tested it thoroughly. You might be interested in a proof-of-concept Maven plugin that I put together this week: Maven TypeScript Compiler Plugin
mhegazy commentedon Mar 29, 2015
thanks William Ono (@wmono) for sharing. You mention in your description you mention
Actually tsc on node supports --watch mode that allows for that. just wanted to make sure you know about it.
wmono commentedon Mar 29, 2015
Thanks Mohamed Hegazy (@mhegazy) I've added a tsc:watch goal to run with that option and it does seem to work on Avatar.js.
martyglaubitz commentedon Apr 1, 2015
That would enable Typescript Gradle Plugin to run the compiler without having nodejs installed on the system.
3 remaining items
ctaggart commentedon Dec 18, 2015
This would be great to see! It would be nice to get contacts at Oracle to see if they still plan on open sourcing their Nashorn TypeScript. Otherwise, Apigee's rowboat project is set to use Nashorn instead of Rhino for the JavaScript Engine like trireme does. It may be worth trying out.
angelozerr commentedon Dec 18, 2015
Just for your information, I have implemented ternjs server to consume it in Java context with tern.java with several JavaScript engine (node.js, J2V8, Nashorm and Rhino) and the performance is not very good with Nashorn (I have not benchamrk, but when I consume ternjs with Nashorm (like open completion with a lot of JS files), Eclipse freezes a little although with node.js it is very fast)
In other words with ternjs, for performance I have : node.js > J2V8 > Nashorm > Rhino.
ctaggart commentedon Dec 18, 2015
Thanks Angelo (@angelozerr)! Looking at the J2V8 docs, it looks similar to Edge.js, but for Java instead of .NET. I think that will work.
vojtechhabarta commentedon May 11, 2016
I usually run TypeScript compiler using
node. When I have Java project with TypeScript code and I don't want to force others to install Node.js I usefrontend-maven-pluginwhich installsnodeandnpmautomatically.But I also wanted to allow users to customize my Java application using TypeScript expressions, snippets, plugins... For this feature I need to run TypeScript compiler inside Java VM so I created PR.
With this PR it should be possible to implement for Java something like typescript-simple.
vladima commentedon May 24, 2016
Vojtěch Habarta (@vojtechhabarta) for embedded scripting can you just load
typescriptServices.jsand then use ts.transpileModule to convert .ts to .js?vojtechhabarta commentedon May 24, 2016
Vladimir Matveev (@vladima) I was thinking that TypeScript services also need
Systemthat's why I wanted first maketscwork. But apparentlyts.transpileModuledoesn't useSystem.ts.transpileModuleis probably sufficient in my case. I just tried to compile "Hello world" program withtypescriptServices.jsrunning on Nashorn and it worked. It took about 10 seconds which is about 4 times faster thantscrunning on Nashorn. This might be usable in cases where caching is possible (and ts code doesn't change often).Thanks
mhegazy commentedon May 24, 2016
Given the perf characteristics of running the compiler on nashorn (see more in #8565 (comment)), and the support requirements on the core ts team, we will have to decline this request in the time being. we can revisit this in the future if any of these assumptions change.
wizawu commentedon Apr 30, 2017
https://1c.wizawu.com/
The purpose of this project is not just to Make tsc runnable on Nashorn. Just wanna make JDK and Maven libraries actually programmable in TypeScript (without quirky hacking).