0

I'm writing a Node.js library that needs to import modules written by the user. If the user writes a module in Typescript he needs to transpile it into Javscript before feeds it into the library. I want to go one step further and make the library compatible with typescript modules in a transparent way. I can transpile the mdoule in os.tempdir(), read it into memory and delete it. It is a three step solution but i thought may be there is a more direct way.

Sohan
  • 6,252
  • 5
  • 35
  • 56
pouya
  • 3,400
  • 6
  • 38
  • 53
  • Do you want something like you change in your TS file and that should be compiled and saved at runtime on save? – Sohan May 16 '19 at 10:57
  • @Sohan not necessarily, TS modules are imported once when the library is bootstrapped. But maybe in future such a need arises. – pouya May 16 '19 at 11:09
  • I have my application where I have everything written in TS (70-80) modules. There are many interdependent modules that are installed at node module. SO I always do gulp build or compile module and install that dependent node module as node library that might be required by other application What are you saying is very rare and could not imagine if this is a feasible and a must required by any application developer – Sohan May 16 '19 at 12:45
  • Are you talking about conditional module loading here? I think what @Sohan commented above makes sense, in the way that the TS tooling should always be independent of the module system in Node runtime. So any library which uses TS should ship a build which is compatible with the module system in the Node runtime. – Shobhit Chittora May 27 '19 at 08:07

0 Answers0