$30 off During Our Annual Pro Sale. View Details »

Node.js 最新動向 TFCon 2022

Node.js 最新動向 TFCon 2022

TFCon で発表する Node.js 最新動向です。

Yosuke Furukawa
PRO

May 14, 2022
Tweet

More Decks by Yosuke Furukawa

Other Decks in Programming

Transcript

  1. ݹ઒ཅհ /PEFKT࠷৽ಈ޲ !5FDI'FFE$POGFSFODF 

  2. Twitter: @yosuke_furukawa Github: yosuke-furukawa

  3. Node.js v18

  4. fetch (experimental)

  5. Fetch Example const res = await fetch('https://nodejs.org/api/documentation.json'); if (res.ok) {

    const data = await res.json(); console.log(data); } // $ node fetch.mjs
 { type: 'module', source: 'doc/api/documentation.md', introduced_in: 'v0.10.0', ... }
  6. WHATWG Stream (experimental)

  7. WHATWG Stream example import { ReadableStream } from 'node:stream/web'; import

    { setInterval as every } from 'node:timers/promises'; import { performance } from 'node:perf_hooks'; const stream = new ReadableStream({ async start(controller) { for await (const _ of every(1000)) controller.enqueue(performance.now()); } }); for await (const value of stream) console.log(value);
  8. Test Runner (experimental)

  9. Test Runner Example import test from 'node:test'; import assert from

    'node:assert'; test('top level test', async (t) => { await t.test('subtest 1', (t) => { assert.strictEqual(1, 1); }); await t.test('subtest 2', (t) => { assert.strictEqual(2, 2); }); }); $ node test.mjs
 TAP version 13 ok 1 - subtest 1 --- duration_ms: 0.000283375
  10. userland snapshot

  11. userland snapshot • bootstrap ࣌ʹେ͖͍ϑΝΠϧΛಡΈࠐ·ͳ͍ͱ͍͚ͳ ͍৔߹ʹىಈ͕஗͘ͳΔʢྫ: TypeScriptΛಡΈࠐΉʣɻ • ͢ͰʹಡΈࠐΜͩঢ়ଶͰΠϝʔδΛ࡞͓͖͍ͬͯͨ •

    ͜Ε͕Ͱ͖Δͷ͕ userland snapshot • Node.js build ࣌ʹಡΈࠐ·ͤΔ `./configure --node- snapshot-main=typescript-bootstrap.js && make`
  12. 5/27 Node.js 13th Birthday 🎂 🎉🎉🎉

  13. Node.js next 10

  14. Next 10 Milestones • Modern HTTP • Suitable Types for

    End Users • Documentation • Web Assembly • ESM • Latest ECMAScript Spec • Observability • Permissions • Better Multithread • Single Executable Applications
  15. Next 10 Milestones • Modern HTTP • Suitable Types for

    End Users • Documentation • Web Assembly • ESM • Latest ECMAScript Spec • Observability • Permissions • Better Multithread • Single Executable Applications
  16. Modern HTTP

  17. Modern HTTP • http 1 / 2 [already supported] •

    fetch [experimentally supported] • http3 ˒ next target
  18. Suitable Types / Document

  19. Fetch Example const res = await fetch('https://nodejs.org/api/documentation.json'); if (res.ok) {

    const data = await res.json(); console.log(data); } // $ node fetch.mjs
 { type: 'module', source: 'doc/api/documentation.md', introduced_in: 'v0.10.0', ... }
  20. ઈରؾ͍ͮͯͳ͍ϙΠϯτ fetch("https://nodejs.org/api/documentation.json") ͜ͷURLؾ͍ͮͯΔ...?

  21. fetch('https://nodejs.org/api/documentation.json') • ͜ͷURL͸Node.jsͷυΩϡϝϯτΛJSONʹͨ͠΋ͷ • ࣮͸APIҎԼͷdocs͸HTMLʹ΋ͳͬͯΔ͠ɺશ෦JSONʹ ΋ͳͬͯΔɻ(/api/fs.json ͱ͔ /api/http.json ΋͋Δ) •

    ͚ͩ͜͜ͷ৘ใͩͱͨͩͷʮ΁ʔʯͰऴྃ • ࣮͸Ҿ਺ύϥϝʔλͱ͔໭Γ஋ͱ͔ͷܕ΋JSON͔ΒऔΕΔ • ͔ͬ͜Βܕ৘ใੜ੒Ͱ͖ΔΑ͏ͳ৘ใ͕औΕΔɻ
  22. Types / Document • ܕ৘ใ͸ԿΒ͔ͷํ๏ͰΤϯυϢʔβʔʹಧ ͚Δ • ·ͣ͸ܕ৘ใΛϓϩάϥϚ͕Ճ޻͠΍͍͢ܗ Ͱಧ͚Δ •

    ಛఆͷݴޠʹಛԽͨ͠৘ใ΋ಧ͚Δ͔Ͳ͏͔ ͸Ϣʔβʔͷ੠࣍ୈ
  23. Single Executable Apps

  24. Single Executable Apps • ࠓͷ Node.js ΞϓϦέʔγϣϯ͸ϦϦʔεɾσϓϩΠʹ࣌ ͕͔͔ؒΔ • docker

    ౳Ͱ΍Δͱຖճ npm install => typescript compile => bundle ͱͳΔ • ୯Ұͷ࣮ߦՄೳͳϑΝΠϧΛ࡞ΓɺͦΕΛ഑ஔ͢Δ͚ͩͰ σϓϩΠͰ͖ΔΑ͏ʹ͢Δ • ·ͩݱ࣌఺Ͱ͸ draft ஈ֊ɺࠓޙʹظ଴
  25. Node.js ͷϢʔβʔ͸ ଟछଟ༷

  26. ͨͩ͠େ͖͘෼͚Δͱ2छྨ Application Developer Site Reliability Engineer

  27. ྆ऀͷࢥ࿭ Application Developer Site Reliability Engineer ৽͍͠ػೳΛ࢖͍͍ͨ Ͱ͖Δ͜ͱΛ૿΍͍ͨ͠ ։ൃऀମݧΛ্͍͛ͨ

  28. ྆ऀͷࢥ࿭ Application Developer Site Reliability Engineer ৽͍͠ػೳΛ࢖͍͍ͨ Ͱ͖Δ͜ͱΛ૿΍͍ͨ͠ ։ൃऀମݧΛ্͍͛ͨ ϒϥ΢β౳ଞͷ8FCϓϥοτϑΥʔ

    Ϝͱͷޓ׵ੑΛ্͛ͯ΄͍͠
  29. ྆ऀͷࢥ࿭ Application Developer Site Reliability Engineer Ϗϧυ΍σϓϩΠΛ҆ఆ͍ͤͨ͞ ੑೳΛ༧ଌͰ͖ΔΑ͏ʹ͍ͨ͠ ϞχλϦϯά΍਍அՄೳʹ͍ͨ͠

  30. ྆ऀͷࢥ࿭ Application Developer Site Reliability Engineer Ϗϧυ΍σϓϩΠΛ҆ఆ͍ͤͨ͞ ੑೳΛ༧ଌͰ͖ΔΑ͏ʹ͍ͨ͠ ϞχλϦϯά΍਍அՄೳʹ͍ͨ͠ ,VCFSOFUFT౳ίϯςφٕज़ͱͷ਌

    ࿨ੑ޲্
  31. ྆ऀͷχʔζΛ׎͑Δඞཁ͕ ͋Δ

  32. ࣍ͷ Node.js 10೥Λݟਾ͑ͯ ͷ׆ಈத

  33. Thanks