惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

博客园 - 聂微东
GbyAI
GbyAI
G
Google Developers Blog
大猫的无限游戏
大猫的无限游戏
H
Hackread – Cybersecurity News, Data Breaches, AI and More
博客园 - 叶小钗
A
About on SuperTechFans
M
MIT News - Artificial intelligence
宝玉的分享
宝玉的分享
雷峰网
雷峰网
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
Martin Fowler
Martin Fowler
Google DeepMind News
Google DeepMind News
博客园 - Franky
B
Blog RSS Feed
Y
Y Combinator Blog
Stack Overflow Blog
Stack Overflow Blog
MongoDB | Blog
MongoDB | Blog
Last Week in AI
Last Week in AI
T
The Blog of Author Tim Ferriss
The GitHub Blog
The GitHub Blog
S
SegmentFault 最新的问题
罗磊的独立博客
Apple Machine Learning Research
Apple Machine Learning Research

Deno

Deno 2.8 | Deno Claw Patrol: an open-source security firewall for agents | Deno Fresh 2.3: Zero JS by default, View Transitions, and Temporal support | Deno Deno 2.7: Temporal API, Windows ARM, and npm overrides | Deno Build a dinosaur runner game with Deno, pt. 6 | Deno Build a dinosaur runner game with Deno, pt. 5 | Deno Deno Deploy is Generally Available | Deno Introducing Deno Sandbox | Deno Build a dinosaur runner game with Deno, pt. 4 | Deno Build a dinosaur runner game with Deno, pt. 3 | Deno Build a dinosaur runner game with Deno, pt. 2 | Deno React / Next.js Denial-of-Service Vulnerability: Deno Deploy users protected | Deno Deno 2.6: dx is the new npx | Deno Build a dinosaur runner game with Deno, pt. 1 | Deno React Server Functions / Next.js Vulnerability: Deno Deploy users protected | Deno My highlights from the new Deno Deploy | Deno Deno's Other Open Source Projects | Deno How Deno protects against npm exploits | Deno Help Us Raise $200k to Free JavaScript from Oracle | Deno Deno 2.5: Permissions in the config file | Deno Fresh 2.0 Graduates to Beta, Adds Vite Support | Deno Deno 2.4: deno bundle is back | Deno JavaScript™ Trademark Update | Deno What's coming to JavaScript | Deno A brief history of JavaScript | Deno Reports of Deno's Demise Have Been Greatly Exaggerated | Deno An Update on Fresh | Deno How Plaid migrated 100 services to a new database platform 5x faster with Deno | Deno Deno 2.3: Improved deno compile, local npm packages, and more | Deno Add JSR packages with pnpm and Yarn | Deno
Deno 1.30: Built-in Node modules | Deno
2023-01-26 · via Deno

Deno 1.30 has been tagged and released with the following new features and changes:

  • Support for built-in Node.js modules
  • deno.json becomes an import map
  • Changes to Deno APIs
  • deno fmt supports configuring semicolons

📝 Help improve Deno and be entered for the chance to win a $100 Amazon giftcard by taking our survey.

If you already have Deno installed, you can upgrade to 1.30 by running:

If you are installing Deno for the first time:


curl -fsSL https://deno.land/x/install/install.sh | sh


iwr https://deno.land/x/install/install.ps1 -useb | iex

Click here for more installation options.

Support for built-in Node.js modules

In Deno, npm packages have already had access to built-in Node.js modules such as fs, path, process, and many more through Deno’s Node.js compatibility layer.

In this release, these modules are exposed to Deno code via node: specifiers.

import { readFileSync } from "node:fs";

console.log(readFileSync("deno.json", { encoding: "utf8" }));

Take note that importing via a bare specifier (ex. import { readFileSync } from "fs";) without an import map is not supported. If you attempt to do so and the bare specifier matches a Node.js built-in module not found in an import map, Deno will provide a helpful error message asking if you meant to import with the node: prefix. Additionally the LSP provides a quick fix to update to a node: specifier.

A screenshot of an editor showing the bare specifier to node: specifier quick fix.

If you are using code both with Deno and Node.js, the node: scheme will work in both runtimes and it’s recommended to update to them for your Node.js code anyway.

deno.json becomes an import map

This release brings a major update to the configuration file - it is now possible to directly use a deno.json file as an import map. In previous releases it was possible to tell Deno where to look for an import map file, by specifying importMap key with a path to the import map file. Many users found it useful, however this approach meant that there are two files with configuration. To make it more concise you can now specify imports and scopes keys in your configuration file and Deno will automatically start treating the configuration file as an import map.

Example deno.json:

{
  "imports": {
    "std/": "https://deno.land/std@0.174.0/"
  }
}

Then the following script with a std bare specifier works:

import { assertEquals } from "std/testing/assert.ts";

assertEquals(1, 2);

Can you see where we’re going with this?

Node/npm and LSP fixes

This release includes over 25 bug fixes related to the npm functionality and Node-API. Additionally, the LSP continues to be improved with over 10 bug fixes. See Releases for a full list.

Changes to Deno APIs

Changes to stable APIs:

  • Deno.permissions APIs get synchronous counter-parts:

    Deno.permissions.querySync({ name: "read", path: "./log.txt" });
    Deno.permissions.revokeSync({ name: "read", path: "./log.txt" });
    Deno.permissions.requestSync({ name: "read", path: "./log.txt" });

    Thanks to Asher Gomez for implementing this feature.

  • Deno.writeFile() and Deno.writeTextFile() now accept a ReadableStream for 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]));
  • A new Deno.env.has(name) API was added:

    Deno.env.set("TEST_VAR", "A");
    assert(Deno.env.has("TEST_VAR"));
    Deno.env.delete("TEST_VAR");
    assert(!Deno.env.has("TEST_VAR"));
  • Deno.Seeker API gets support for bigint offsets.

    You can now use the bigint type as an argument to the Seeker interface:

    const file = await Deno.open("./log.txt");
    const cursor = await file.seek(150n, Deno.SeekMode.Start);
  • Test steps can be functions:

    Previously, using the test steps API required the first argument of the test step to be a name or test definition:

    Deno.test("my test", async (t) => {
      const success = await t.step("step1", async () => {
        await t.step(function inner1() {});
        await t.step(function inner1() {});
      });
      if (!success) throw new Error("Expected the step to return true.");
    });

    Starting with this release, the first argument can also be a named function:

    Deno.test("my test", async (t) => {
      const success = await t.step(async function step1() {
        await t.step(function inner1() {});
        await t.step(function inner1() {});
      });
      if (!success) throw new Error("Expected the step to return true.");
    });

API stabilizations:

Deno.Listener.ref() and Deno.Listener.unref() are now stable. The --unstable flag is no longer required to use these APIs.

Changes to unstable APIs:

  • In new Deno.Command({}).spawn(), the default value for the stdin option was changed to "inherit" - meaning that if you don’t configure this option specifically, standard input will be inherited from the parent process.

  • Deno.dlopen adds 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,
    ]);

    Thank you to @DjDeveloperr and Aapo Alasuutari for implementing this feature.

New unstable APIs:

This release adds 3 new APIs:

  • Deno.osUptime() (requires --allow-sys=osUptime permission)
  • Deno.Conn.ref()
  • Deno.Conn.unref()

These APIs require the --unstable flag, but we plan to stabilize them in the next release.

Thank you to Kamil Ogórek for implementing this feature.

Removal of internal Deno.core

This release removes the Deno.core namespace. Deno.core was a private API with no stability guarantees. This change should have no impact to the majority of users.

deno fmt supports configuring semicolons

A long repeatedly requested feature for deno fmt has been the ability to format without semicolons. It’s now possible to do this by using the --options-no-semicolons flag or by specifying "semiColons": false in the fmt configuration in a Deno configuration file:

{
  "fmt": {
    "options": {
      "semiColons": false
    }
  }
}

📝 Help improve Deno and be entered for the chance to win a $100 Amazon giftcard by taking our survey.