Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
Contributing to Deno is fun!
Search
petamoriken / 森建
October 20, 2023
Programming
0
170
Contributing to Deno is fun!
Deno Fest ディノフェス - presented by toranoana.deno
https://deno-fest-2023.deno.dev/
petamoriken / 森建
October 20, 2023
Tweet
Share
More Decks by petamoriken / 森建
See All by petamoriken / 森建
DOM Observable
petamoriken
1
89
Deno に Web 標準 API を実装する / Implementing Web Standard API to Deno
petamoriken
0
390
Stage 2 Decorators の変遷 / Stage 2 Decorators history
petamoriken
0
5.8k
linaria: Zero-Runtime CSS in JS
petamoriken
2
2k
ESNext の議論に参加しよう / Join the ESNext discussion
petamoriken
3
690
Multithreading WebAssembly by Rust
petamoriken
3
930
WebAssembly で WebP のデコードを試した / Decode WebP with WebAssembly by Pure Rust
petamoriken
0
1k
TC39 で提案されている ECMAScript 最新仕様 / ECMAScript latest specification proposed in TC39
petamoriken
2
740
バイト列から整数を得る
petamoriken
1
500
Other Decks in Programming
See All in Programming
Java 22 Overview
kishida
1
200
Node.js v22 で変わること
yosuke_furukawa
PRO
12
4k
PHPはいつから死んでいるかの調査
chiroruxx
2
420
2 週間で Twitter Bot を作ってみた
contour_gara
0
790
GitHub Copilotのススメ
marcy731
1
240
SIMD Parallel Programming with the Vector API
josepaumard
0
240
Direct Style Effect Systems The Print[A] ExampleA Comprehension Aid
philipschwarz
PRO
0
190
Three ways to use AI on Android: The Good, the Bad and the Ugly
marxallski
0
110
Compose-View Interop in Practice (mDevCamp 2024)
stewemetal
0
170
Fast JSX: Don't clone props object #28768
yossydev
1
200
Polars入門
daikikatsuragawa
1
190
Ruby Function Composition
bkuhlmann
1
340
Featured
See All Featured
The Cost Of JavaScript in 2023
addyosmani
21
3.9k
Rebuilding a faster, lazier Slack
samanthasiow
74
8.3k
Done Done
chrislema
178
15k
Dealing with People You Can't Stand - Big Design 2015
cassininazir
358
22k
Save Time (by Creating Custom Rails Generators)
garrettdimon
PRO
0
35
Web Components: a chance to create the future
zenorocha
306
41k
Producing Creativity
orderedlist
PRO
338
39k
RailsConf & Balkan Ruby 2019: The Past, Present, and Future of Rails at GitHub
eileencodes
126
32k
Code Reviewing Like a Champion
maltzj
515
39k
Building Your Own Lightsaber
phodgson
100
5.7k
The Illustrated Children's Guide to Kubernetes
chrisshort
32
47k
Let's Do A Bunch of Simple Stuff to Make Websites Faster
chriscoyier
501
140k
Transcript
Contributing to Deno is fun! pixiv Inc. 森内建太 petamoriken 2023.10.20
2 自己紹介 • Web エンジニア • ECMAScript や WHATWG を追うのが好き • よく仕様についての記事を書いています petamoriken プロダクト支援本部
課題解決部(福岡)
3
4 目次 • Deno の構成 • Deno 内部の JavaScript • primordials.js について • コントリビュート手順
• プルリクエストの具体例
5 Deno の構成 • Cargo (Rust) ワークスペースで管理されている • https://github.com/denoland/deno ◦ cli コマンドライン
◦ runtime 実行部分 ◦ ext Web 標準 API、FFI、Node.js 互換レイヤーなど • https://github.com/denoland/deno_core ◦ core V8、JS と Rust を仲介する部分 (ops) など
6 Deno 内部の JavaScript • Deno API のインターフェースは JavaScript で実装されている ◦ Web 標準 API、Node.js 互換レイヤーなど ◦ ファイルシステム、ネットワークなど外界とのやり取りは Rust
• 実行時に都度テキストとして読み込むと時間がかかる 👉 V8 スナップショット機能で JavaScript と ops の初期化処理を高速化
pub fn create_runtime_snapshot(snapshot_path: PathBuf) { let fs = std::sync::Arc::new(deno_fs::RealFs); let
mut extensions: Vec<Extension> = vec![ deno_webidl::deno_webidl::init_ops_and_esm(), deno_console::deno_console::init_ops_and_esm(), deno_url::deno_url::init_ops_and_esm(), deno_web::deno_web::init_ops_and_esm::<Permissions>( Default::default(), Default::default(), ), // ... ]; 7 deno/runtime/build.rs
function quoteString(string, ctx) { const quote = ArrayPrototypeFind( ctx.quotes, (c)
=> !StringPrototypeIncludes(string, c), ) ?? ctx.quotes[0]; const escapePattern = new SafeRegExp(`(?=[${quote}\\\\])`, "g"); string = StringPrototypeReplace(string, escapePattern, "\\"); if (ctx.escapeSequences) { string = replaceEscapeSequences(string); } return `${quote}${string}${quote}`; } 8 deno/ext/console/01_console.js
9 primordials.js について • プロトタイプ汚染されても問題なく内部コードが実行できるようするためのもの ◦ deno_core/core/00_primordials.js で提供される • CI で dlint prefer-primordials ルールでチェックされる // NG
["foo", "bar"].include("foo"); // OK const { ArrayPrototypeInclude } = window.__bootstrap.primordials; ArrayPrototypeInclude(["foo", "bar"], "foo");
10 コントリビュート手順 1. イシューを見つける • good first issue ラベルが付いているものが取っつきやすいです 2. 取り組むことを宣言する
3. プルリクエストを作成する • わからない箇所は Discord や日本コミュニティ Slack などで気軽に聞いて👌 • 見てもらう前に cargo test ./ tools/format.js ./tools/lint.js を 実行して CI を通す くわしくはコントリビュートガイドへ https://docs.deno.com/runtime/manual/references/contributing/
11 プルリクエストの具体例 • feat(console): Display cause errors in console #12462