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
460
フロントエンド開発のためのセキュリティ入門
masashi
49
17k
Corepack ~Node.jsに追加されたパッケージマネージャーマネージャー~ / #tng37
masashi
3
12k
Node.js + Web Compatibility
masashi
2
600
サイボウズが行うフロントエンドの品質保証 / 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
型のインスタンス化は非常に深く、無限である可能性があります。
kimitashoichi
0
190
わたしの星のままで一番星になる ~ 出産を機にSIerからEC事業会社に転職した話 ~
kimura_m_29
0
160
Jakarta EE meets AI
ivargrimstad
0
1.2k
CSC509 Lecture 14
javiergs
PRO
0
130
Effective Signals in Angular 19+: Rules and Helpers @ngbe2024
manfredsteyer
PRO
0
110
42 best practices for Symfony, a decade later
tucksaun
1
160
なまけものオバケたち -PHP 8.4 に入った新機能の紹介-
tanakahisateru
1
110
MCP with Cloudflare Workers
yusukebe
2
170
Thoughts and experiences on Rust and TypeScript
unvalley
2
220
Haze - Real time background blurring
chrisbanes
1
490
Refactor your code - refactor yourself
xosofox
1
220
Cognitoが大型アップデート!Managed Loginとパスワードレスログインを実際に使ってみた@しむそくRadio Special Day1
tmhirai
3
310
Featured
See All Featured
Keith and Marios Guide to Fast Websites
keithpitt
410
22k
The World Runs on Bad Software
bkeepers
PRO
65
11k
Designing for humans not robots
tammielis
250
25k
The Web Performance Landscape in 2024 [PerfNow 2024]
tammyeverts
2
270
How to Think Like a Performance Engineer
csswizardry
21
1.2k
Bash Introduction
62gerente
608
210k
We Have a Design System, Now What?
morganepeng
51
7.3k
Fight the Zombie Pattern Library - RWD Summit 2016
marcelosomers
232
17k
Code Review Best Practice
trishagee
65
17k
The Illustrated Children's Guide to Kubernetes
chrisshort
48
48k
A Philosophy of Restraint
colly
203
16k
Practical Orchestrator
shlominoach
186
10k
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