Denoを触ってみる - ライブラリ周り -
Denoのライブラリ周り
Denoには,NodeのnpmみたいなPackageManagerはない.
コードのimport文にurlとversionを指定することで,Denoの実行時に外部モジュールのダウンロードがされる.
また, Deno単体にlint
やformater
が組み込まれている.
lintやformater戦争はDeno側が吸収してくれるようだ.ありがたい.
❯ deno -h deno 1.0.0 ~~~ 省略 ~~~ SUBCOMMANDS: bundle Bundle module and dependencies into single file cache Cache the dependencies completions Generate shell completions doc Show documentation for a module eval Eval script fmt Format source files help Prints this message or the help of the given subcommand(s) info Show info about cache or info related to source file install Install script as an executable repl Read Eval Print Loop run Run a program given a filename or url to the module test Run tests types Print runtime TypeScript declarations upgrade Upgrade deno executable to given version ENVIRONMENT VARIABLES: DENO_DIR Set deno's base directory (defaults to $HOME/.deno) DENO_INSTALL_ROOT Set deno install's output directory (defaults to $HOME/.deno/bin) NO_COLOR Set to disable color HTTP_PROXY Proxy address for HTTP requests (module downloads, fetch) HTTPS_PROXY Same but for HTTPS
スタンダードライブラリ
Denoのコアメンバーによって運用されているモジュール.
Denoのバージョンごとにスタンダードライブラリにもバージョンがあるとのこと. なので,使用時はバージョン指定をしたものを使って管理してほしいとこ.
ただ,stdに1.0.0
がまだ無いので,最新の0.51.0
がimportでただしい??
http/server
を取り込む場合
import { serve } from "https://deno.land/std@v0.51.0/http/server.ts";
サードパーティライブラリ
公式のサードパーティ?がここに登録されている.
すでに,スタンダードライブラリに同じ機能がるものは追加しないと記述があるので公式ということになるのかな?
lodash
とかmysql
とか王道なのが確認できる.
Node時代の王道のWebFrameworkのExpress
は整備が進んでいる状態みたい.
こういうのはスタンダードライブラリにWebServer機能があるけど,公式側に追加せれるのかな?
締め
いろいろと開発進んでいて整備されている状態だけど,簡単なスクリプトを書くとか十分できる環境は整っている.
公式のサードパーティーライブラリの位置づけがよくわからなかったけど,
期待されている言語なので,ちょくちょく更新状況は追ってみる.