A build tool that transforms Deno modules into npm packages for Node.js, handling module specifiers, shims, and testing.
dnt (Deno to Node Transform) is a build tool that converts Deno modules into npm packages compatible with Node.js. It rewrites module specifiers, injects shims for Deno APIs, generates ESM and CommonJS outputs, and runs tests in Node.js, solving the problem of publishing Deno code to the npm registry.
Deno developers who want to distribute their libraries as npm packages for use in Node.js projects, or teams maintaining dual Deno/Node.js codebases.
Developers choose dnt because it automates the entire Deno-to-Node conversion process with robust shimming, type checking, and testing, reducing manual effort and ensuring compatibility. Its flexibility in handling custom shims, specifier mappings, and multiple entry points makes it the most comprehensive tool for this niche.
Deno to npm package build tool.
Open-Awesome is built by the community, for the community. Submit a project, suggest an awesome list, or help improve the catalog on GitHub.
Transforms Deno import URLs to Node.js-compatible specifiers, including esm.sh and remote modules, handling a complex manual process automatically.
Injects shims for the Deno namespace and other globals using packages like @deno/shim-deno, enabling Deno code to run in Node.js with minimal code changes.
Generates both ESM and CommonJS/UMD packages alongside TypeScript declaration files by default, ensuring broad compatibility across Node.js environments.
Runs Deno.test suites in Node.js after transformation, verifying functionality and catching issues before publishing, as shown in the build logs.
Setting up custom shims, specifier mappings, and handling edge cases like top-level await requires manual intervention and deep familiarity with the tool's options.
The README admits that targeting Node v14 and below is problematic, with certain shims not working reliably and necessitating workarounds like Deno.test-only shimming.
The transformation process adds build time, and injected shims can increase package size and runtime overhead, which may impact performance-sensitive applications.