🦕 Support Deno and release on NPM with a single codebase. 🦕
WARNING: This is a pre-release that might be broken in some way. Polished release coming soon.
This tool takes as input a TypeScript codebase that was meant to target node and/or the web and spits out a modified version of the source files that are ready to be deployed as a Deno module.
Denoify does for Deno what browserify does for the browser.
A way to import node modules in Deno projects. For that purpose you can try CommonJS module Loading
Although it is quite easy to port a module to Deno it is a chore to maintain two codebases.
Modules that have been made cross-runtime using Denoify:
- Does your users need to have
@types/node
installed to use your module ? If yes then, unfortunately, your module is not denoifiable as it is. Even if you are allowed to use (some, not all) node builtins such asfs
,path
orevent
you will need to remove all Node reference from your exposed API before you can use Denoify. You can't for example expose a class that extendsEventEmitter
or if you do you will have to export a type definition forEventEmitter
. - You will need to provide a Deno polyfill for each of your project dependencies that are not known by Denoify.
Here is the list of modules for which Denoify has already a polyfill for.
Note that Denoify work recursively meaning that you can fork your dependencies repo and Denoify them yourself.
However, depending on how deep your dependency tree goes it might not be feasible. - Is your module a vanilla JS project? If yes you will have to port it into TypeScript first.
The project is at an early stage. Current TODO list;
- Allows require() ( synchronous dynamic loading of modules )
- Using the typescript compiler API to parse source files instead of making the change with RegExps. ts-morph seems to be a good option here.
- Polyfills global node API that are not imported like Buffer and process. ( Language parsing must land first. )
Check out this repo to see in practice how to set up your Denoify with your repo.
denoify_ci is a template repo that automate the boring and tedious tasks of:
- Filling up the
package.json
- Setting up Typescript and Denoify.
- Writing a README.md with decent presentation and instructions on how to install/import your module.
- Testing on multiples
Node
andDeno
version before publishing. - Maintaining a CHANGELOG
- Publishing on NPM and deno.land/x on your behalf.
All you have to do is write the code.