Node.js 最新動向 TFCon 2022

Node.js 最新動向 TFCon 2022

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

Yosuke Furukawa PRO

May 14, 2022

Annual Pro sale · Save $30

Have presentations of your own?

Share with private links, password protection, and more control over your work.

Transcript

33 slides
  1. 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', ... }
  2. 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);
  3. 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
  4. userland snapshot • bootstrap ࣌ʹେ͖͍ϑΝΠϧΛಡΈࠐ·ͳ͍ͱ͍͚ͳ ͍৔߹ʹىಈ͕஗͘ͳΔʢྫ: TypeScriptΛಡΈࠐΉʣɻ • ͢ͰʹಡΈࠐΜͩঢ়ଶͰΠϝʔδΛ࡞͓͖͍ͬͯͨ •

    ͜Ε͕Ͱ͖Δͷ͕ userland snapshot • Node.js build ࣌ʹಡΈࠐ·ͤΔ `./configure --node- snapshot-main=typescript-bootstrap.js && make`
  5. Next 10 Milestones • Modern HTTP • Suitable Types for

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

    End Users • Documentation • Web Assembly • ESM • Latest ECMAScript Spec • Observability • Permissions • Better Multithread • Single Executable Applications
  7. Modern HTTP • http 1 / 2 [already supported] •

    fetch [experimentally supported] • http3 ˒ next target
  8. 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', ... }
  9. fetch('https://nodejs.org/api/documentation.json') • ͜ͷURL͸Node.jsͷυΩϡϝϯτΛJSONʹͨ͠΋ͷ • ࣮͸APIҎԼͷdocs͸HTMLʹ΋ͳͬͯΔ͠ɺશ෦JSONʹ ΋ͳͬͯΔɻ(/api/fs.json ͱ͔ /api/http.json ΋͋Δ) •

    ͚ͩ͜͜ͷ৘ใͩͱͨͩͷʮ΁ʔʯͰऴྃ • ࣮͸Ҿ਺ύϥϝʔλͱ͔໭Γ஋ͱ͔ͷܕ΋JSON͔ΒऔΕΔ • ͔ͬ͜Βܕ৘ใੜ੒Ͱ͖ΔΑ͏ͳ৘ใ͕औΕΔɻ
  10. Single Executable Apps • ࠓͷ Node.js ΞϓϦέʔγϣϯ͸ϦϦʔεɾσϓϩΠʹ࣌ ͕͔͔ؒΔ • docker

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

More Decks by Yosuke Furukawa

Other Decks in Programming