0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

deno v1.0.0-rc1の変更点まとめ

Posted at

denoのv1.0.0-rc1の変更点をまとめます。

破壊的変更

(std/ws) WebSocketからreceiveメソッドが削除され、直接AsyncIteratorを実装するよう変更された

Deno.Listener等の型との一貫性を向上させることを目的とした変更のようです。

v1.0.0-rc1
const ws = await connectWebSocket(endpoint);
for await (const msg of ws) { // v0.42.0までは`ws.receive()`とする必要があった
  ...
}

deno <script>.ts形式が廃止された

v0.42.0までは、以下の形式でスクリプトを実行することができました。

$ deno ./mod.ts

v1.0.0-rc1からはこの形式が廃止されます。スクリプトを実行する際はrunサブコマンドを使用する必要があります。

$ deno run ./mod.ts

JSONファイルのimportが廃止された

セキュリティ上の理由から廃止されました。

window.locationglobalThis.location、及びself.locationが削除されました

現時点ではWeb標準に準拠できていないなどの理由から削除されました。

(std/io/utils) copyBytes関数の引数の順序が変更されました

copyBytes関数のsrc引数とdst引数の順番が入れ替わりました。

v0.42.0におけるDeno.copyの変更に合わせた修正のようです。

v0.42.0
copyBytes(src, dst, off)
v1.0.0-rc1
copyBytes(dst, src, off) 

新機能

(deno install) スクリプト名が、インストールするファイルの名前を元に決定されるよう変更された

例えば、以下を実行すると、ファイル名であるfile_server.tsを元に、スクリプト名がfile_serverと決定されます。

$ deno install --allow-net --allow-read https://deno.land/std/http/file_server.ts
$ file_server

この変更に伴い、スクリプト名を明示的に指定できるよう--nameフラグがサポートされました。

例えば、以下を実行した場合、スクリプト名はfsになります。

$ deno install --name fs --allow-net --allow-read https://deno.land/std/http/file_server.ts
$ fs

(deno fmt) deno-fmt-ignore/deno-fmt-ignore-fileコメントがサポートされた

deno fmtの実行を制御するための特殊なコメントが追加されました。

特定のコードのフォーマットを無効化したいときは、deno-fmt-ignoreコメントを使います。

// deno-fmt-ignore
function add(
     a: number,
  b: number,
): number {
  return a + b;
}

特定のファイルに対してフォーマットを無効化したいときは、deno-fmt-ignore-fileコメントを使います。

// deno-fmt-ignore-file

function add(
     a: number,
  b: number,
): number {
  return a + b;
}

add(
     1
  ,      2);

(std/node/process) global.processが設定されるようになった

std/node/process.tsimportとした際に、globalオブジェクトのprocessプロパティが自動で設定されるようになりました。

WritableStream/TransformStreamが実装された

const r = new ReadableStream();
const w = new WritableStream();
r.pipeTo(w);

https://github.com/denoland/deno/pull/5042
https://github.com/denoland/deno/pull/4980

Deno.cwd--allow-readを要求するようになった

その他変更点

特定の文字が含まれていると、console.tableを使用した際に、列の幅が揃わなくなる問題が修正された

(std/http) ServerRequest#respond(r: Response)が引数のheadersプロパティを変更しないよう修正された

以下のようにHeadersオブジェクトを再利用していると、ServerRequest#respondの呼び出しがhangするケースが存在したため、修正されました。

const headers = new Headers({ 'Content-Type': 'text', });
for await (const req of server) {
  ...
  req.respond({ headers, body });
}

Deno.chdir--allow-writeではなく--allow-readフラグを要求するようになった

リモートモジュールからローカルモジュールへのimportが禁止された

リモートモジュール(http://..., https://...)からローカルモジュール(file://...)のimportが禁止されました。

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?