Deno 1.31, the latest version of the Node.js rival runtime for JavaScript, TypeScript, and WebAssembly, adds package.json
support. The new feature is one of several improvements designed to make it easier for developers to transition from existing Node.js projects.
Deno now will automatically detect a package.json
and use it to install and resolve dependencies used. This also enables the running of project-specific scripts defined in the scripts
section with deno task
. However, current support is limited to simple scripts. Programs such as rimraf
or cross-env
will not yet work, but support for them will be added in an upcoming release.
Deno 1.31 also stabilizes the Node-API (N-API). Developers no longer need use the unstable
flag when using NPM packages that rely on this API. Many bug fixes were applied to Node-API and more packages can be used without issue. Remaining bugs will be addressed in upcoming weeks.
In addition, Deno 1.31 moves the compatibility layer for Node.js directly into the Deno runtime. Previously, compatibility for Node.js was provided by using https:/deno.land/std.node
, a collection of polyfills in userland code in the Deno standard library. Because dependency on https://deno.land/std
had to be bumped with each release of Deno, the compatibility layer had to downloaded after each upgrade. Now the compatibility layer is embedded in the runtime and V8 JavaScript engine snapshots are used to reduce startup time. The tighter integration enables easier polyfilling of missing APIs and improves the performance of built-in Node.js modules. To use embedded polyfills, developers can import from node: specifiers
.
Unveiled February 24, Deno 1.31 can be accessed via deno upgrade
for current users. Other installation options are listed on GitHub. Deno 1.31 follows last month’s release of Deno 1.30, which improved support for Node.js modules.
Also in Deno 1.31:
- In a breaking change, pointers now are represented as plain objects, or null for null pointers. These objects are created by V8 and supported by V8 Fast API, improving performance of FFI (Foreign Function Interface) when working with
“pointer”
type parameters and return values from previous versions. Pointer objects are opaque and cannot be manipulated directly from JavaScript. Thus, FFI becomes safer to use, with pointer spoofing no longer as easy as writing a JavaScript number. Note that the FFI API is unstable. - The
Deno.Command
andDeno.osUptime()
APIs now are stabilized. Developers are advised to migrate from theDeno.run()
API toDeno.Command
. - The
Deno.build.os
API now returns more variants for operating systems, such as"darwin"
,"linux"
,"windows"
, and"solaris"
. - For the standard library, modules for
https://deno.land/std/node
have been removed. This code is now directly embedded in the Deno runtime. - For the command interface, the
deno bundle
command is no longer supported and will not show up in the help output. - Also for the CLI,
deno benchcode
now accepts a--json
flag that will print benchmark results as JSON. - The interactive permission prompt now accepts a new option,
A
. This option enables granting of permission for subsequent calls to APIs using the granted domain. deno compile
now understands dynamic imports that can be resolved at compile time.