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
3 Effective Rules for Using Signals in Angular
manfredsteyer
PRO
0
100
Content Security Policy入門 セキュリティ設定と 違反レポートのはじめ方 / Introduction to Content Security Policy Getting Started with Security Configuration and Violation Reporting
uskey512
1
520
C++でシェーダを書く
fadis
6
4.1k
Arm移行タイムアタック
qnighy
0
300
ローコードSaaSのUXを向上させるためのTypeScript
taro28
1
610
よくできたテンプレート言語として TypeScript + JSX を利用する試み / Using TypeScript + JSX outside of Web Frontend #TSKaigiKansai
izumin5210
6
1.7k
【Kaigi on Rails 2024】YOUTRUST スポンサーLT
krpk1900
1
330
AWS IaCの注目アップデート 2024年10月版
konokenj
3
3.3k
2024/11/8 関西Kaggler会 2024 #3 / Kaggle Kernel で Gemma 2 × vLLM を動かす。
kohecchi
5
910
シールドクラスをはじめよう / Getting Started with Sealed Classes
mackey0225
4
640
A Journey of Contribution and Collaboration in Open Source
ivargrimstad
0
870
「今のプロジェクトいろいろ大変なんですよ、app/services とかもあって……」/After Kaigi on Rails 2024 LT Night
junk0612
5
2.1k
Featured
See All Featured
The Straight Up "How To Draw Better" Workshop
denniskardys
232
140k
VelocityConf: Rendering Performance Case Studies
addyosmani
325
24k
GraphQLとの向き合い方2022年版
quramy
43
13k
Bootstrapping a Software Product
garrettdimon
PRO
305
110k
XXLCSS - How to scale CSS and keep your sanity
sugarenia
246
1.3M
Why You Should Never Use an ORM
jnunemaker
PRO
54
9.1k
[Rails World 2023 - Day 1 Closing Keynote] - The Magic of Rails
eileencodes
33
1.9k
Let's Do A Bunch of Simple Stuff to Make Websites Faster
chriscoyier
506
140k
Thoughts on Productivity
jonyablonski
67
4.3k
Understanding Cognitive Biases in Performance Measurement
bluesmoon
26
1.4k
How to Ace a Technical Interview
jacobian
276
23k
Facilitating Awesome Meetings
lara
50
6.1k
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