ビルドシステム(GYP) 4. package.json 5. node_modules ブラックホールよりも深い依存性を生んでしまった 6. “.js”拡張子なしでのrequire(“module”) 7. index.js module解決アルゴリズムを不必要に複雑化させてしまった → Denoの開発に着手(2018〜) 10 Things I Regret About Node.js/Node.jsに関する10の反省点 Ryan Dahl (JSConf EU 2018)
TypeScript Built in tsconfig.jsonを用意せずとも,TypeScriptの実行が可能に. 3. Secure by default 許可がなければネットワークやファイルシステム,サブプロセス,環境変数にアクセスができない 4. Compatible with web window, locationm, atob/btoa, fetch, setTimeoutなどWeb互換関数をサポート(※ ただし全てでない) 5. Web assembly support wasmバイナリを直接実行可能 今後のマイルストーンにもぜひご注目 https://github.com/denoland/deno/milestones
PermissionDenied: read access to "/Users/hoshi/Code/Deno", run again with the --allow-read flag # OK $ deno run --allow-read dir.ts /Users/hoshi/Code/Deno console.log(Deno.cwd()); dir.ts 他にも --allow-net(ネットワーク), --allow-write(ファイル書き込み) --allow-env(環境変数), --allow-run(サブプロセス)などのオプションが存在 ※ $ deno run --help で参照可能
server started on 8000! import { serve } from "https://deno.land/std@0.50.0/http/server.ts"; const PORT = Number(Deno.env.get("PORT")) || 8000; const s = serve({ port: PORT }); console.log(`deno http server started on ${PORT}!`); for await (const req of s) { req.respond({ body: "<h1>Hello Deno!</h1> <img src=’logo.gif’/>" }); } server.ts serve関数でasync iterableな要素を返却しているので for await … of構文で処理を記述できる このGIFアニメロゴは日本人の@hashrockさんが 作られたものらしいです. https://hashrock.hatenablog.com/entry/2019/02/04/040505 ロゴの元ネタは,Ryan氏いわく 「夜の雨の中に立って、ソフトウェア開発の闇の戦 いにストイックに立ち向かう様子」を表現したそう