A build tool that 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 ready to be deployed as a Deno module.
NOTE: Denoify won’t run on Deno, it is a Node module.
If you are just looking for a quick way to load NPM modules in your Deno project
you can check out CommonJS module Loading,
unlike Denoify, it won’t give you types definitions, it will involve
--allow-read but it will also be easier to get working.
Some NPM modules can also be imported into Deno using CDN like Skypack (ex Pika) or jspm
checkout Soremwar/deno_types for some examples.
This tool is mainly for NPM module maintainer, to enable them to bring first-class citizen Deno support to their modules and doing so without introducing breaking changes.
- Although it is quite easy to port a module to Deno no one wants to maintain two codebase.
- Wouldn’t it be great to have a tool able to bring Deno support to NPM modules?
Modules that have been made cross-runtime using Denoify:
NOTE: New features have been introduced since this meeting was hold
Coming up next is a detailed guide on how to set up denoify with your project and how
to publish on deno.land/x but before anything
here are the current limitations you need to be aware of.
- If your module is vanilla JS it needs to be ported to TypeScript first. (1)
- Not all Node’s builtin are supported yet. (2) But thanks to the new
à la React Native,
that let you have specific deno implementation for some of your files, the
lack of support for
"net", while being annoying, is no longer a dead end.
- If your module has dependencies you will have to enable those dependencies to run on Deno.
While it is well documented, be aware that it is a time consuming process.
require()is not yet supported.
- You can’t (yet)
fs.readFile()files that are part of the module ( files inside a
directory for example ). (4)
(1) Don’t be afraid, renaming your source with
.ts and dropping some
and there will do the trick.
You will be able to pull it off even if you aren’t familiar with typescript. Ref
(2) You can consult here the current state of the Node’s builtin support.
(4) In Deno the files that forms your module won’t be pre-fetched and
node_module like in node so you won’t be able to access files that are not
on the disk.
Setting up an existing project
Check out this repo to see in practice how to set up Denoify in your project.
Starting a project from scratch
denoify_ci is a template repo that automates the boring and tedious tasks of:
- Filling up the
- Setting up TypeScript and Denoify.
- Writing a README.md with decent presentation and instructions on how to install/import your module in different environments.
- Testing with multiple
Denoversions before publishing.
- Publishing on NPM and deno.land/x ( via GitHub releases ).
NEW v0.4.0: Now that deno.land/x allows to publish modules under a subdirectory of a GitHub repo
denoify no longer generate a
mod.ts at the root of the project but under
deno_dist should be stipulated
as subdirectory when registering your module on deno.land/x.