Deno is a simple, modern and secure runtime for JavaScript and TypeScript that uses V8 and is built in Rust.
Deno 1.30 has been released, notable updates include:
Support for built-in Node.js modules
In Deno, npm packages can already access built-in Node.js modules such as fs, path, process, etc. through Deno's Node.js compatibility layer.
In this version, these modules are node: specifiers
exposed to Deno code via:
import { readFileSync } from "node:fs";
console.log(readFileSync("deno.json", { encoding: "utf8" }));
If you use both Deno and Node.js code, the node:
solution will work on both runtimes.
deno.json
becomes an import map
This release brings a major update to the config file, it is now possible to directly use the config deno.json
file as an import map.
In previous versions, it was possible to tell Deno where to find the import map file by specifying the importMap
key and the path to the import map file.
Many users find it useful, but this approach means there are two configuration files. To be more concise, you can now specify the imports
and scopes
keys in your config file, and Deno will automatically start treating the config file as an import map.
Fixes for Node/npm and LSP
This release includes over 25 bug fixes related to npm functions and Node-API. Additionally, LSP continues to be improved with over 10 bug fixes.
Changes to the Deno
API
Changes to stable API:
- Deno.permissions APIs gained a synchronous counterpart
Deno.permissions.querySync({ name: "read", path: "./log.txt" }) 。
Deno.permissions.revokeSync({ name: "read", path: "./log.txt" })。
Deno.permissions.requestSync({ name: "read", path: "./log.txt" });
-
Deno.writeFile()
andDeno.writeTextFile()
now acceptsReadableStream
as a second argument.const stream = new ReadableStream({ pull(controller) { controller.enqueue(new Uint8Array([1])); controller.enqueue(new Uint8Array([2])); controller.close(); }, }); await Deno.writeFile("/tmp/test.txt", stream); assertEquals(Deno.readFileSync(filename), new Uint8Array([1, 2]));
-
Added a new
Deno.env.has(name)
APIDeno.env.set("TEST_VAR", "A"); assert(Deno.env.has("TEST_VAR")); Deno.env.delete("TEST_VAR"); assert(!Deno.env.has("TEST_VAR"));
-
...
API stabilization:
Deno.Listener.ref()
and Deno.Listener.unref()
are now stable. The --unstable
flag .
Changes to Unstable API:
-
new Deno.Command({}).spawn()
In , thestdin
option's default value was changed to"inherit”
mean that if you don't specifically configure this option, standard input will be inherited from the parent process. -
Deno.dlopen
Add support for passing structs by value:const Rect = ["f64", "f64", "f64", "f64"]; const dylib = Deno.dlopen("./dylib.so", { make_rect: { parameters: ["f64", "f64", "f64", "f64"], result: { struct: Rect }, }, }); const rect_sync = dylib.symbols.make_rect(10, 20, 100, 200); assertInstanceOf(rect_sync, Uint8Array); assertEquals(rect_sync.length, 4 * 8); assertEquals(Array.from(new Float64Array(rect_sync.buffer)), [ 10, 20, 100, 200, ]);
New unstable API:
This release adds 3 new APIs:
Deno.osUptime()
(requires-allow-sys=osUptime
permissions )Deno.Conn.ref()
Deno.Conn.unref()
These APIs require --unstable
flags , but we plan to stabilize them in the next release.
remove internalDeno.core
This release removes Deno.core
the namespace. Deno.core
is a private API with no stability guarantees. This change should have no effect on most users.
Deno fmt
Support configuration semicolon
Deno fmt
A long-repeated feature of , is the ability to format without semicolons. This is now possible by using the --options-no-semicolons
flag or specifying in the fmt config in the Deno config file "semiColons": false
.
{
"fmt": {
"options": {
"semiColons": false
}
}
}
For more details, please check: https://github.com/denoland/deno/releases/tag/v1.30.0