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
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
Webエンジニア主体のモバイルチームの 生産性を高く保つためにやったこと
igreenwood
0
330
今年一番支援させていただいたのは認証系サービスでした
satoshi256kbyte
1
250
CSC305 Lecture 25
javiergs
PRO
0
130
The Efficiency Paradox and How to Save Yourself and the World
hollycummins
1
440
テスト自動化失敗から再挑戦しチームにオーナーシップを委譲した話/STAC2024 macho
ma_cho29
1
1.3k
htmxって知っていますか?次世代のHTML
hiro_ghap1
0
330
Keeping it Ruby: Why Your Product Needs a Ruby SDK - RubyWorld 2024
envek
0
180
103 Early Hints
sugi_0000
1
220
採用事例の少ないSvelteを選んだ理由と それを正解にするためにやっていること
oekazuma
2
1k
N.E.X.T LEVEL
pluu
2
300
KubeCon + CloudNativeCon NA 2024 Overviewat Kubernetes Meetup Tokyo #68 / amsy810_k8sjp68
masayaaoyama
0
240
.NET 9アプリをCGIとして レンタルサーバーで動かす
mayuki
1
770
Featured
See All Featured
Evolution of real-time – Irina Nazarova, EuRuKo, 2024
irinanazarova
5
440
Fireside Chat
paigeccino
34
3.1k
KATA
mclloyd
29
14k
Building a Modern Day E-commerce SEO Strategy
aleyda
38
7k
Easily Structure & Communicate Ideas using Wireframe
afnizarnur
191
16k
Save Time (by Creating Custom Rails Generators)
garrettdimon
PRO
28
900
Designing Dashboards & Data Visualisations in Web Apps
destraynor
229
52k
Raft: Consensus for Rubyists
vanstee
137
6.7k
The Power of CSS Pseudo Elements
geoffreycrofte
73
5.4k
GraphQLの誤解/rethinking-graphql
sonatard
67
10k
Imperfection Machines: The Place of Print at Facebook
scottboms
266
13k
The Illustrated Children's Guide to Kubernetes
chrisshort
48
48k
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