アドベントペアプロ #1 denoland/deno

react-native-oss.hatenablog.com

ファシリテータ: @ggtmtmgg セクリタリ: @ggtmtmgg 参加者: @Haga, @binaryta レポジトリ: denoland/deno

denoはnodeの作者がnodeの欠点を補う形で作っているTypeScriptエンジン

Denoのビルドに関する手順

  1. サブモジュールごとclone $ git clone --recurse-submodules https://github.com/denoland/deno.git (chromiumのdepotツール群も内部利用している)

  2. rustの処理系をインストール $ brew install rust

  3. pythonは2.x系を使うのでない場合はinstall $ pyenv install 2.7.x

  4. denoのセットアップ $ ./tools/setup.py

  5. denoのビルド $ ./tools/build.py

  6. ビルドしたdenoを動かす $ ./target/debug/deno tests/002_hello.ts

プルリクエストまでの流れ

  1. テストの実行 $ ./tools/test.py
  2. コードフォーマットの実行 $ ./tools/format.py
  3. リンターの実行 $ ./tools/lint.py

立ち止まって分岐を考える

  • TODOを上から見ていく
  • Issueを上から見ていく
  • ソースコードを上から見ていく
  • ドキュメントを上から見ていく
  • commitを上から見ていく⬅

11月は83個のcommitがマージされている。 commitを見ていく

feat: Support for bigints in console

bigintがconsole.logで使えるようになる

Cargo and GN should build into same directory.

CargoはRustのビルドシステム GNはv8のなんか GNはtarget/debugに出力してる、Cargoはtarget/debug/build/deno-26d2b5325de0f0cf/outとかに出力してる。 これを両方target/debugにする Rustのコードでletを二行続けて使ってるのが特徴的

let out_dir = env::var_os("OUT_DIR").unwrap();
let out_dir = env::current_dir().unwrap().join(out_dir);

Upgrade Prettier to support BigInt syntax in TS

新しいprettierがBigIntに対応しててその新しいPrettierを実行する

Upgrade Rust crates

extern/cratesはRust版importのやつっぽい Cargo.tomlがRust版package.jsonっぽい

test rust version before rustup

rustupはUNIXライクシステムで動作するバージョン管理のやつ nodeでいうnodenv multirustの新しい版。 multirustもRustバイナリをインストールできるバージョン管理システム

Add Process.output

stdoutを最終文字までUint8Arrayにして返す

Add deno.readAll()

deno.readAll()はReaderを渡すとPromise<Uint8Array>を返す。

Fix flaky REPL test

REPLの反応速度のテスト??

clippy fixes

clippyはRustのlinter

Upgrade To TypeScript 3.2

TypeScriptを3.2に上げる

Make //build a git submodule

build_extra/toolchain/win/BUILD.gnを消してサブモジュール化している

立ち止まって分岐を考える

  • TODOを上から見ていく⬅
  • Issueを上から見ていく
  • ソースコードを上から見ていく
  • ドキュメントを上から見ていく x commitを上から見ていく

git grep

$ g grep TODO -- js/
js/blob.ts:  // TODO(qti3e) Implement convertLineEndingsToNative.
js/blob_test.ts:// TODO(qti3e) Test the stored data in a Blob after implementing FileReader API.
js/buffer.ts:      throw Error("ErrTooLarge"); // TODO DenoError(TooLarge)
js/buffer_test.ts:    // TODO buf.writeByte()
js/buffer_test.ts:    // TODO buf.readByte()
js/compiler.ts:  // TODO ideally this are not static and can be influenced by command line
js/compiler.ts:      // TODO: all this does is push the problem downstream, and TypeScript
js/dom_types.ts:  // TODO
js/dom_types.ts:  // TODO
js/fetch.ts:  readonly locked: boolean = false; // TODO
js/fetch.ts:  statusText = "FIXME"; // TODO
js/fetch.ts:  readonly type = "basic"; // TODO
js/fetch.ts:  redirected = false; // TODO
js/fetch_test.ts:// TODO(ry) The following tests work but are flaky. There's a race condition
js/file_info.ts:   * for this file/directory. TODO Match behavior with Go on windows for mode.
js/files.ts:// TODO This is just a placeholder - not final API.
js/net.ts:// TODO support other types:
js/net.ts:// TODO Support finding network from Addr, see https://golang.org/pkg/net/#Addr
js/net.ts: * TODO: `tcp4` (IPv4-only), `tcp6` (IPv6-only), `udp`, `udp4` (IPv4-only),
js/net_test.ts:  // TODO Currently ReadResult does not properly transmit EOF in the same call.
js/net_test.ts:/* TODO Fix broken test.
js/net_test.ts:/* TODO Fix broken test.
js/net_test.ts:/* TODO Fix broken test.
js/net_test.ts:/* TODO Fix broken test.
js/process.ts:// TODO Maybe extend VSCode's 'CommandOptions'?
js/process.ts:  signal?: number; // TODO: Make this a string, e.g. 'SIGTERM'.
js/read_link_test.ts:  // TODO Add test for Windows once symlink is implemented for Windows.
js/read_link_test.ts:  // TODO Add test for Windows once symlink is implemented for Windows.
js/remove_test.ts:  // TODO(ry) Is Other really the error we should get here? What would Go do?
js/stat_test.ts:// TODO Add tests for modified, accessed, and created fields once there is a way
js/symlink.ts:  // TODO Use type for Windows.
js/testing/testing.ts:    // TODO Do this on the same line as test name is printed.
js/testing/util.ts:// TODO(ry) Use unknown here for parameters types.
js/testing/util.ts:// TODO(ry) Use unknown here for parameters types.
js/timers.ts:// TODO(piscisaureus): fix that ^.
js/timers.ts:  // TODO: use a monotonic clock.
js/timers_test.ts:      // TODO: clearInterval(id) here alone seems not working
js/v8_source_maps.ts:      // TODO Support source map URLs relative to the source URL

js/net_test.tsコメントアウトされていたテストをコメントインしてみる

テストは通るっぽい コンパイルエラーが出ている

masterの状態で./tools/unit_tests.py target/debug/deno を実行してみたらエラーがでた

test result: ok. 37 passed; 0 failed; 0 ignored; 0 measured; 182 filtered out

running 8 tests
test getTravisDataSuccess_permW0N1E0R0
HttpOther: an error occurred trying to connect: Connection refused (os error 61)
    at maybeError (deno/js/errors.ts:38:12)
    at handleAsyncMsgFromRust (deno/js/dispatch.ts:27:17)

test result: FAILED. 0 passed; 1 failed; 0 ignored; 0 measured; 211 filtered out

Error: There were 1 test failures.
    at setTimeout (file:///Users/binaryta/git/deno/js/testing/testing.ts:110:13)
    at fire (deno/js/timers.ts:131:3)

-- 思考ログはここまで --

メモ

Rustの疑問

Q: どうやって実行する
A: プレイグラウンド https://play.rust-lang.org/

Q: assert_eq!(x.unwrap(), "air");の!ってなに?
A: !がついてるのはマクロ

Q: unwrap()ってなに?
A: Some(v) から vを取り出す

Q: Some("air")のSomeってなに?
A: なんかOptionと一緒に使うやつ

Q: let x: Option<&str> = None;のOption<&str>ってなに?
A: Optional型になる

Q: Panicってなに?
A: Rustの例外

Q: BUILD.gnってなに?
A:

やること

  • .gitignoreにVSCodeMacOSの記述を追記してPRを送る ← @binaryta
  • js/net_test.tsコメントアウトされていたテストをコメントインしてみる ← @Haga
  • masterの状態で./tools/unit_tests.py target/debug/deno を実行してみたらエラーが出た件issueを立てる ← @binaryta
  • Rustの疑問を解消しておく ← @ggtmtmgg