Skip to content

Make tsc runnable on Nashorn #1789

Closed
Closed

Description

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).

Activity

  1. bavardage commented on Jan 23, 2015

    @bavardage
    Contributor

    👍

  2. RyanCavanaugh commented on Jan 23, 2015

    @RyanCavanaugh
    Member

    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.

  3. added
    BugA bug in TypeScript
    SuggestionAn idea for TypeScript
    and removed
    BugA bug in TypeScript
    on Jan 23, 2015
  4. DanielRosenwasser commented on Jan 23, 2015

    @DanielRosenwasser
    Member

    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:

    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.

  5. markelliot commented on Jan 23, 2015

    @markelliot
    Author

    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.

  6. basarat commented on Jan 23, 2015

    @basarat
    Contributor

    Mark Elliot (@markelliot) I suspect you will inevitably need node for some other project that does something useful with your JavaScript/CSS

  7. DanielRosenwasser commented on Jan 24, 2015

    @DanielRosenwasser
    Member

    Nashorn-specific IO module for tsc

    Or a Node-compatible interface exposed from Java.

  8. wmono commented on Mar 28, 2015

    @wmono

    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

  9. mhegazy commented on Mar 29, 2015

    @mhegazy
    Contributor

    thanks William Ono (@wmono) for sharing. You mention in your description you mention

    What about watching the directory and recompiling when a file changes?

    Actually tsc on node supports --watch mode that allows for that. just wanted to make sure you know about it.

  10. wmono commented on Mar 29, 2015

    @wmono

    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.

  11. martyglaubitz commented on Apr 1, 2015

    @martyglaubitz

    That would enable Typescript Gradle Plugin to run the compiler without having nodejs installed on the system.

  12. 3 remaining items

  13. added this to the milestone on Apr 27, 2015
  14. ctaggart commented on Dec 18, 2015

    @ctaggart
    Contributor

    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.

  15. angelozerr commented on Dec 18, 2015

    @angelozerr

    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.

  16. ctaggart commented on Dec 18, 2015

    @ctaggart
    Contributor

    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.

  17. vojtechhabarta commented on May 11, 2016

    @vojtechhabarta

    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.

  18. vladima commented on May 24, 2016

    @vladima
    Contributor

    Vojtěch Habarta (@vojtechhabarta) for embedded scripting can you just load typescriptServices.js and then use ts.transpileModule to convert .ts to .js?

  19. vojtechhabarta commented on May 24, 2016

    @vojtechhabarta

    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).

    Thanks

  20. added
    Won't FixThe severity and priority of this issue do not warrant the time or complexity needed to fix it
    on May 24, 2016
  21. mhegazy commented on May 24, 2016

    @mhegazy
    Contributor

    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.

  22. wizawu commented on Apr 30, 2017

    @wizawu

    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).

  23. removed this from the milestone on Apr 26, 2018
  24. locked and limited conversation to collaborators on Jul 31, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Good First IssueWell scoped, documented and has the green lightHelp WantedYou can do thisSuggestionAn idea for TypeScriptWon't FixThe severity and priority of this issue do not warrant the time or complexity needed to fix it

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions