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 release, these modules are passed through node: specifiers
Expose to Deno code:
import { readFileSync } from "node:fs";
console.log(readFileSync("deno.json", { encoding: "utf8" }));
If you use both Deno and Node.js code,node:
Scenarios will work in both runtimes.
deno.json
becomes an import map
This release brings a major update to the configuration files, which can now be used directly deno.json
file as an import map.
In previous releases, it was possible to specify the importMap
key and the path to the import map file to tell Deno where to look for 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 in your config file imports
and scopes
key, Deno will automatically start treating the configuration 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.
right Deno
API changes
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()
accept nowReadableStream
as the second parameter.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)
APIsDeno.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()
It is now stable.No longer required when using these APIs --unstable
sign.
Changes to Unstable API:
exist
new Deno.Command({}).spawn()
middle,stdin
The default value of the option was changed to"inherit”
Means 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()
(need-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 internal Deno.core
This version removes Deno.core
Namespaces.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.can now be accessed by using --options-no-semicolons
flag or specified in the fmt configuration of the Deno configuration file "semiColons": false
to achieve this function.
{
"fmt": {
"options": {
"semiColons": false
}
}
}
For more details, please check: https://github.com/denoland/deno/releases/tag/v1.30.0
#Deno #released #builtin #Node #module #News Fast Delivery