x/denoify@v0.11.1
🦕 Support Deno and release on NPM with a single codebase.🦕
What's new in
v0.11
: Support or partial support fro many new Node API:console
,cluster
,dgram
,dns
,http
,http2
,https
,inspector
,module
,net
,perf_hooks
,readline
,repl
,string_decoder
,sys
,tls
,tty
,v8
,vm
,wasi
,worker_threads
,zlib
.
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 node_modules/
and require --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 do so without introducing breaking changes.
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.
"https"
or "net"
, while being annoying, is no longer a dead end.require()
is not yet supported.fs.readFile()
files that are part of the module ( files inside a res/
directory for example ). (4)(1) Don't be afraid, renaming your source with .ts
and dropping some any
here
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
placed in node_module
like in node so you won’t be able to access files that are not
on the disk.
Check out this repo to see in practice how to set up Denoify in your project.
Once you'll have successfully build your module for Deno you will want to publish it on deno.land/x
to do that in a clean way, without tracking the deno_dist/
on your main branch you'll need to setup a
CI workflow.
To do that you can use the .github/workflow/ci.yaml
from tsafe, you can copy paste it, it's portable.
When registering your module on deno.land/x you will need to specify the subdirectory:
GitHub API rate limit exceeded
If you run Denoify a lot outside of GitHub Actions pipelines you will eventually get the following error:RequestError [HttpError]: API rate limit exceeded for 176.170.197.165. (But here's the good news: Authenticated requests get a higher rate limit. Check out the documentation for more details.)
.
To fix it, create a GitHub Personal Access Token and provide it as the environnement variable GITHUB_TOKEN
when you run the build tool.
Example:
echo ghp_xn8jsxZrUChs9nmfZPDSmxLrTJPVJy3Sxc5J > ~/.bash_profile
source ~/.bash_profile
npx denoify
NEW IN v0.10
declare module ...
. Exampleindex.ts
is located in the source. DocNEW IN v0.9
tsconfig.json
can be absent if outputDir is specified. See @zxch3n's PRdeno_dist
. See @zxch3n's PRNEW IN v0.7
NEW IN v0.7
node_modules
are located in a parent directory.NEW IN v0.6
v0.6
using a custom replacer
referenced in the package.json
.console.log()
in custom replacers to help debug. crypto
node builtin.NEW IN v0.5 Breaking changes
"denoify"
field. deno_dist
directory (Previously only README.md
was copied).