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
Node.jsの2022年と未来 / Node.js in 2022 and Future
Search
Masashi Hirano
November 16, 2022
Programming
1
1k
Node.jsの2022年と未来 / Node.js in 2022 and Future
Node.js v18とv19の主な変更点や今後について発表しました。
Masashi Hirano
November 16, 2022
Tweet
Share
More Decks by Masashi Hirano
See All by Masashi Hirano
You may not need XXX in Node.js
masashi
5
1.2k
OSSとコミュニティを支える
masashi
1
1k
英語ができなかった自分達が、グローバルチーム立ち上げに挑戦!?
masashi
1
3.1k
フロントエンド開発のためのセキュリティ入門について
masashi
1
450
フロントエンド開発のためのセキュリティ入門
masashi
49
17k
Corepack ~Node.jsに追加されたパッケージマネージャーマネージャー~ / #tng37
masashi
3
12k
Node.js + Web Compatibility
masashi
2
590
サイボウズが行うフロントエンドの品質保証 / Frontend Quality Assurance at Cybozu
masashi
10
2.9k
実践 OSSことはじめ / First Step for OSS Contribution
masashi
4
10k
Other Decks in Programming
See All in Programming
CSC509 Lecture 13
javiergs
PRO
0
110
watsonx.ai Dojo #4 生成AIを使ったアプリ開発、応用編
oniak3ibm
PRO
1
190
flutterkaigi_2024.pdf
kyoheig3
0
170
What’s New in Compose Multiplatform - A Live Tour (droidcon London 2024)
zsmb
1
480
Jakarta EE meets AI
ivargrimstad
0
780
A Journey of Contribution and Collaboration in Open Source
ivargrimstad
0
1.1k
Tauriでネイティブアプリを作りたい
tsucchinoko
0
380
エンジニアとして関わる要件と仕様(公開用)
murabayashi
0
310
.NET のための通信フレームワーク MagicOnion 入門 / Introduction to MagicOnion
mayuki
1
1.9k
ふかぼれ!CSSセレクターモジュール / Fukabore! CSS Selectors Module
petamoriken
0
150
C++でシェーダを書く
fadis
6
4.1k
みんなでプロポーザルを書いてみた
yuriko1211
0
280
Featured
See All Featured
Done Done
chrislema
181
16k
The Language of Interfaces
destraynor
154
24k
Principles of Awesome APIs and How to Build Them.
keavy
126
17k
What’s in a name? Adding method to the madness
productmarketing
PRO
22
3.1k
A better future with KSS
kneath
238
17k
Designing on Purpose - Digital PM Summit 2013
jponch
115
7k
"I'm Feeling Lucky" - Building Great Search Experiences for Today's Users (#IAC19)
danielanewman
226
22k
Designing for Performance
lara
604
68k
Learning to Love Humans: Emotional Interface Design
aarron
273
40k
Making Projects Easy
brettharned
115
5.9k
Rebuilding a faster, lazier Slack
samanthasiow
79
8.7k
Cheating the UX When There Is Nothing More to Optimize - PixelPioneers
stephaniewalter
280
13k
Transcript
Node.jsͷ2022ͱະདྷ Node.js v18, v19ͷओͳมߋͱࠓޙՃ͞ΕΔػೳʹ͍ͭͯ Masashi Hirano (@shisama)
ฏ ণ࢜ / Masashi Hirano Frontend Developer @shisama_ shisama Node.js
Core Collaborator
Agenda • Node.js v18ͷओͳมߋ • Node.js v19ͷओͳมߋ • ݱࡏ࣮தͷػೳ͔ΒPick Up
• Next 10 years
Node.js in 2022
Node.js v18
Node.js v18 • 2022/04/19ɺv18.0.0ϦϦʔε • 2022/10/25ɺv18.12.0͕LTSͱͯ͠ϦϦʔε • 2025/04/30ɺϝϯςφϯεऴྃ༧ఆ
fetch() • ϒϥβͷfetch()͕࣮ؔߦ࣌ϑϥάͳ͠Ͱ༻Մೳ • HTTPͷϦΫΤετΛૹ৴͢Δؔ • ·ͩExperimental • ϒϥβͱಉ͡Α͏ʹάϩʔόϧؔͱͯ͠༻Մೳ
ςετϥϯφʔͷՃ • JestVitestͷΑ͏ͳςετϥϯφʔ͕Node.jsຊମʹՃ͞Εͨ • ‘node:test’͔Βimportͯ͠͏ • ͰςετΛ࣮ߦ • ΦϓγϣϯͰskipͳͲΛࢦఆՄೳ
V8 (JSΤϯδϯ) ͕όʔδϣϯΞοϓ • ϝδϟʔόʔδϣϯ্͕͕ΔλΠϛϯάͰV8͕ߋ৽͞ΕΔ • Node.js v18 Ͱ V8͕10.1ʹόʔδϣϯΞοϓ
• Array# fi ndLast()ɺ Intl.supportedValuesOf()͕ ͑ΔΑ͏ʹͳͬͨ
HTTP requestTimeout()ͷσϑΥϧτͷมߋ • server.requetTimeoutͷλΠϜΞτ࣌ؒͷσϑΥϧτ͕ 0 ͔Β 300000ϛϦඵ (5) ʹͳΓ·ͨ͠ɻ
• http.createServer({ requestTimeout: 600000 })ͷΑ͏ʹࢦఆ͢Δ͜ͱͰ ͖Δ͕ɺ0 Λࢦఆ͢Δ͜ͱඇਪ • 0 λΠϜΞτͳ͠ʹͳΔͨΊɺॲཧ͕͍ϦΫΤετͷྃΛͬ ͨΓDoS߈ܸ͞ΕͨΒ߈ܸ͕ऴΘΒͳ͍ݶΓϦΫΤετ͕ͪൃੜ͢Δ
Web Streams API • ϒϥβʢWebʣͷStream APIͱಉ͡ΠϯλʔϑΣʔε༷ʹԊͬ ͨ Stream ͷ API
• Node.jsͷݹ͍Streamͱޓੑͳ͠ • Node.js v18͔Βϑϥάͳ͠Ͱ ༻Մೳʹͳ͕ͬͨ·ͩExperimental
—watch • Webpack ͳͲͰ͓ͳ͡ΈͷwatchϞʔυ͕Node.jsຊମʹೖͬͨ • ࣮ߦதͷϓϩάϥϜͷґଘؔʹ͋ΔϞδϡʔϧʹมߋ͕͋ͬͨΒࣗ ಈతʹϓϩηε͕࠶ىಈ͢Δ • node index.js
—watch ͷΑ͏ʹ —watchϑϥάΛ͚ͭͯىಈ͢Δ • v18.11.0͔Β͑Δ
Node.js v19
HTTP(S) KeepAlive ͕σϑΥϧτͰ༗ޮʹ • ϦΫΤετΛૹ৴͢Δͱ͖ͷ Keep-Alive ͕σϑΥϧτ༗ޮʹมߋ • Keep-Alive ͕༗ޮʹͳΔͱɺҰఆ࣌ؒଓ͕ҡ࣋͞ΕΔͨΊϋϯυγΣ
ΠΫͷճ͕ݮͬͯύϑΥʔϚϯε͕Α͘ͳΔ • ͜Ε·Ͱ௨Γ໌ࣔతʹࢦఆ͢Δ͜ͱՄೳ const http = require('node:http'); const agent = new http.Agent({ keepAlive: true }); const req = http .get('http://localhost:3000', { agent }, (res) => { // ... })
V8(JSΤϯδϯ)ͷόʔδϣϯΞοϓ • V8͕10.7ʹΞοϓσʔτ͞Εͨ͜ͱͰJSͷ৽ػೳ͕૿͑ͨ • Intl.NumberFormat v3 (https://github.com/tc39/proposal-intl- numberformat-v3) • ൣғΛϑΥʔϚοτΛ
͢ΔformatRange()
--experimental-speci fi er-resolution ϑϥάͷআ • import ‘./foo’; ͱॻ͖͍ͨ߹ɺ—experimental-speci fi er-
resolution=nodeϑϥάΛ͚࣮ͭͯߦ͢Εิͯ͘͠Ε͍ͯͨ • ESM্༷ɺ֦ுࢠͷলུ͕ڐ͞Ε͍ͯͳ͍ • import xxx from ‘./foo’ ͱॻ͚ͳ͍ɻ’./foo.js’ͱ͠ͳ͚ΕͳΒͳ͍ • ସखஈˠCustom LoaderΛ࡞Δ •
https://github.com/nodejs/loaders-test nodejs/loaders-test ʹCustom Loaderͷαϯϓϧ͕͋Δ
Web Crypto API ͕ stable ʹ • ϒϥβ(Web)ͷ Crypto API
ͱΠϯ λʔϑΣʔεޓ͕͋Δ • Node.jsͷݹ͍Crypto APIͱޓͳ͍ • ҉߸Խ෮߸Λ͢Δ͜ͱ͕Ͱ͖ΔAPI
ShadowRealm • JavaScriptΛ࣮ߦ͢ΔͨΊͷάϩʔόϧڥʢRealmʣΛ৽͘͠ੜ͢ΔAPI • ҟͳΔίϯςΩετͷͨΊɺάϩʔόϧڥ͕Ԛછ͞Εͳ͍ • αϯυϘοΫεڥΛ࡞Δ͜ͱ͕Ͱ͖Δ • ݱࡏ ECMAScriptͷproposal
stage 3 • Node.jsͷvm APIͰಉ͜͡ͱͰ͖Δ ͕ɺϒϥβ(Web)ޓͱ͍͏ͷ͕ϙΠϯτ • ·ͩExperimental
https://zenn.dev/petamoriken/articles/6656b387555610
https://shisama.hatenablog.com/ հͰ͖ͳ͔ͬͨओͳมߋʹ͍ͭͯϒϩάಡΜͰ͍ͩ͘͞
Node.js in future
ݱࡏ࣮தͷػೳ͔ΒPick Up
node:test ϞοΫͷػೳ • https://github.com/nodejs/node/pull/45326 (Ϛʔδࡁ) • mock.fnɺmock.methodɺmock.restoreͳͲͷϞοΫ͕ؔ node:testʹՃ͞Εͨ import {
mock, test } from 'node:test'; import assert from 'node:assert'; test(‘should call callback function’, () => { const mockCallback = mock.fn((uuid) => { return uuid; }) assert.strictEqual(mockCallback.mock.calls.length, 0); uuid(mockCallback); assert.strictEqual(mockCallback.mock.calls.length, 1); });
node:http/static (੩తϑΝΠϧ༻ͷHTTPαʔό) • https://github.com/nodejs/node/pull/45096 (ొஃ࣌ͰະϚʔδ) • ੩తϑΝΠϧΛ৴͢ΔαʔόΛىಈ͢Δ͜ͱ͕Ͱ͖Δ • ͷସʹ༻Ͱ͖Δ •
Node.js ຊମ͚ͩͰىಈͰ͖Δͷ͕ར
QUIC • https://github.com/nodejs/node/pull/44325 (ొஃ࣌ͰະϚʔδ) • QUIC τϥϯεϙʔτϓϩτίϧ • σʔλ࠶ૹͷޮԽɺ௨৴ͷܧଓੑɺ෦తʹTLSΛར༻ͯ͠҉߸Խ ͳͲͷಛ͕͋Δ
• HTTP/3QUICͷ্Ͱಈ͘ https://datatracker.ietf.org/meeting/98/materials/slides-98-edu-sessf-quic-tutorial/
https://gihyo.jp/admin/serial/01/http3/0001
Single Executable Application • https://github.com/nodejs/node/pull/45038 (ొஃ࣌ͰະϚʔδ) • JS͔Β୯ҰͷωΠςΟϒͷ࣮ߦϑΝΠϧม • e.g.
Windowsͷ.exeϑΝΠϧ • JSͰॻ͍ͨΞϓϦέʔγϣϯΛNode.js͕Πϯετʔϧ͞Ε͍ͯͳ͍ ڥͰ࣮ߦͰ͖ΔΑ͏ʹͳΔ • ݱࡏͷସखஈͱͯ͠vercel/pkg͕͋Δ • https://github.com/nodejs/single-executable Ͱ׆ಈ͞Ε͍ͯΔ +4 +4 +4 +4 &9& ·ͱΊͯ̍ͭͷ ࣮ߦϑΝΠϧ
ύʔϛογϣϯϞσϧ • https://github.com/nodejs/node/pull/44004 (ొஃ࣌Ͱ·ͩDraft) • DenoͷΑ͏ʹ࣮ߦ࣌ʹύʔϛογϣϯΛ༩͢Δ͜ͱͰϑΝΠϧΞ ΫηεϓϩηεͷىಈͳͲΛ੍ޚͯ͠ηΩϡΞͳ࣮ߦΛՄೳʹ͢Δ • ·ͩͲ͏͍͏ܗࣜʹ͢Δ͔ٞத •
Denoͷ `—allow-…`ͷΑ͏ʹڐՄܗࣜʹ͢Δ͔ɺ `—deny-…`ͷΑ͏ʹېࢭܗࣜʹ͢Δ͔ܾ·͍ͬͯͳ͍
Next 10 years
next-10 • Node.js ͷࠓޙ10Ͳ͏͢Δ͔ͷ͕ٞ͞Ε͍ͯΔ • https://github.com/nodejs/next-10 • ϦϙδτϦͷ TECHNICAL_PRIORITY_WORKING_SUMMARY.mdʹ
༏ઌͷߴ͍ػೳͷҰཡͱؔ࿈ϦϯΫ͕ܝࡌ͞Ε͍ͯΔ • nodejs/node ϦϙδτϦͷ doc/contributing/technical-priorities.md ʹ ༏ઌͷߴ͍ػೳͷ֓ཁ͕ܝࡌ͞Ε͍ͯΔ • ࣮͞Ε࢝Ί͍ͯΔͷ͋Δ͕ٞதͷͷଟ͍
https://github.com/nodejs/node/blob/HEAD/doc/contributing/technical-priorities.md next-10Ͱ༏ઌతͳػೳͷ֓ཁ͕ه͞Ε͍ͯΔ
Technical Priorities • Modern HTTP • Suitable types for end-users
• Documentation • WebAssembly • ESM • Support for features from the latest ECMAScript spec • Observability • Permissions/policies/sec model • Better multithreaded support • Single Executable Applications
Suitable types for end-users • ϝϯςφϒϧͰ৴པͷߴ͍ܕใΛϢʔβʔʹఏڙ͍ͨ͠ • ݱࡏߟ͍͑ͯΔܕใΛఏڙ͢ΔͨΊͷΞϓϩʔν • APIΛՃ͢Δͱ͖ʹMarkdownͰॻ͔ΕͨNode.jsͷAPIͷυΩϡϝϯτΛՃ
• MarkdownͰॻ͔ΕͨAPIͷυΩϡϝϯτ͔ΒϚγϯϦʔμϒϧͳJSONΛࣗಈੜ • ͦͷJSON͔ΒܕใΛੜ͢Δ • Maintaining types for Node.js (https://github.com/nodejs/node/blob/main/doc/ contributing/maintaining-types-for-nodejs.md) ʹৄࡉ͕ܝࡌ͞Ε͍ͯΔ
Support for features from the latest ECMAScript spec • ࠷৽ͷECMAScriptͷ༷Λαϙʔτ͍ͨ͠
• ESͷ༷ਵV8(JSΤϯδϯ)ͷߋ৽ʹΑͬͯߦΘΕ͍ͯΔ • ݱࡏV8ͷߋ৽͕ϝδϟʔόʔδϣϯͷͱ͖ͷΈߦΘΕ͍ͯΔ • ·ͩํ๏ະఆ͕༷ͩਵͷͨΊʹݱࡏͷํ๏Λม͑Δඞཁ͕͋Δ
·ͱΊ • Node.js v18ͱv19ʹfetchWeb Streams APIͳͲWebޓͳػೳ ͕ϑϥάͳ͠Ͱ͑ͨΓstableʹͳͬͨ • ςετϥϯφʔwatchϞʔυͳͲ։ൃମݧΛ্ͤ͞ΔͨΊͷػೳ Ճ͞Εͨ
• Node.jsͷ࣍ͷ10ʹ͚͕ͯٞ։࢝͞Ε͍ͯΔ • ༏ઌ͕ߴ͍ػೳ͔Β࣮͕ٞ࢝·͍ͬͯΔ
https://jsconf.jp JSConf JPͰNode.jsʹ͍ͭͯͷτʔΫ͕͋Γ·͢ʂ
Thanks