Denoばた会議 Monthly 第12回

Deno v1.25

npmパッケージのサポート

npm:<パッケージ名>でnpmパッケージをimportできます。

import express from "npm:express@4.18.1";

const app = express();
app.get("/", function (req, res) {
  res.send("Hello");
});

app.listen(3000);
$ deno run --unstable --allow-env --allow-read --allow-net main.mjs

npmパッケージのサポート

npxライクにパッケージを実行することもできます。

$ deno run --unstable \
  --allow-env \
  --allow-read \
  --allow-write \
  npm:make-dir-cli@3.0.0 src/components

新しいHTTPサーバ (Flash)

const ac = new AbortController();

Deno.serve((req) => new Response("Hello, Flash"), {
  port: 4500,
  onListen: ({ port, hostname }) => {
    console.log(`Started at http://${hostname}:${port}`);
  },
  onError: (error) => {
    return new Response("Internal Server Error", { status: 500 });
  },
  signal: ac.signal,
});

deno initコマンド

$ deno init my-first-project
✅ Project initialized
Run these commands to get started
  cd my-first-project
  deno run main.ts
  deno test

npm inityarn initなどのようにプロジェクトの初期化ができます。

FFIへの"buffer"型の追加 (破壊的変更)

const dylib = Deno.dlopen(libPath, {
  "do_something_with_buffer": { parameters: ["buffer", "usize"], result: "void" },
});

const data = new Uint8Array([1, 2, 3, 4]);
dylib.do_something_with_buffer(data, data.length);

今後は、TypedArrayを渡す際は"pointer"型ではなく"buffer"型を使う必要があります。

パフォーマンス最適化

  • 依存関係の解析結果をキャッシュすることによる起動時間の高速化
  • V8 Fast Calls を使用したopsの最適化の仕組みが導入
  • Deno.open(Sync)やWeb Streams APIなどが最適化

Big Changes Ahead for Deno

Denoの今後の計画について発表されました。

  • Node.jsとの互換性の向上
  • パフォーマンスの向上
  • エンタープライズユーザへのサポートの強化
  • 開発体験の向上

Deno Merch

Freshのロードマップ

  • プラグインシステム (例: Twindプラグイン)
    import { start } from "$fresh/server.ts";
    import twindPlugin from "$fresh/plugins/twind.ts";
    import manifest from "./fresh.gen.ts";
    import twindConfig from "./twind.config.js";
    
    await start(manifest, { plugins: [twindPlugin(twindConfig)] });
    
  • <Head>の非推奨化 (代わりに<head>を使う)

PrismaのDenoサポート

Hey folks, we are working hard with Prisma team on support for both Deno CLI and Deno Deploy. We expect to share some news in the coming weeks.

Bartekさんの発言より (prisma/prisma: Add support for Deno (#2452))

まもなくprisma generateコマンドが動かせるようになるかもしれないとのことです

$ PRISMA_CLIENT_ENGINE_TYPE=binary deno run -A --unstable npm:prisma generate

deno-jaのLP🍣

hashrockさんがdeno-jaのLPを作ってくださいました!

Deno Newsでも紹介されてます👀

## `deno bundle`の非推奨化と`deno pack`の追加 - [Proposal: deprecate deno bundle, add deno pack (#15463)](https://github.com/denoland/deno/issues/15463) - コマンド名に関する誤解の解消や安定性の向上などが目的のようです。 ---