Ts-morph: make it available for Deno

Created on 17 Jan 2021  路  6Comments  路  Source: dsherret/ts-morph

Describe the solution you'd like
Just make work this awesome lib for Deno

enhancement help wanted

All 6 comments

It would be great. ts-morph was actually previously used in Deno's build system when it was still on node.

ts-morph doesn't have too many dependencies, so I don't believe this would be too hard. I think probably the easiest solution here would be to build code-block-writer for Deno (has no dependencies), then bundle ts-morph and @ts-morph/common into a single file, then implement https://github.com/dsherret/ts-morph/blob/latest/packages/common/src/fileSystem/RealFileSystemHost.ts for Deno.

Opened https://github.com/dsherret/code-block-writer/issues/36

Edit: This is complete now.

One part about this was figuring out how to bundle the .d.ts files (aka lib files) for Deno. https://github.com/dsherret/ts-morph/pull/934 should solve this, but I think for Deno it will have to remove the "require" and always load the lib files module in getLibFiles()

https://github.com/dsherret/ts-morph/blob/3dd5c72a48a7a5852cf5f995126b8cc12567ee86/packages/common/src/getLibFiles.ts#L2-L5

ts-morph/common dependencies

ts-morph dependencies

Remaining Tasks

  • [x] Create a Deno implementation of the Runtime interface.
  • [x] Make a build for Deno. Can just be a single file.
  • [ ] Add some code verification to enforce putting certain stuff in a Runtime and add some basic tests for Deno.

@hemedani this is now available here: https://deno.land/x/ts_morph

Note that I haven't developed a way to run the tests for the Deno module yet, so it might be a little bit unstable. I started using it in some of my Deno code in a different repo and seems to work well so far...

awesome

Was this page helpful?
0 / 5 - 0 ratings