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
20年もののレガシープロダクトに 0からPHPStanを入れるまで / phpcon2024
hirobe1999
0
720
コンテナをたくさん詰め込んだシステムとランタイムの変化
makihiro
1
140
PSR-15 はあなたのための ものではない? - phpcon2024
myamagishi
0
170
生成AIでGitHubソースコード取得して仕様書を作成
shukob
0
510
フロントエンドのディレクトリ構成どうしてる? Feature-Sliced Design 導入体験談
osakatechlab
8
4.1k
DevFest - Serverless 101 with Google Cloud Functions
tunmise
0
110
テストコード書いてみませんか?
onopon
2
180
Exploring: Partial and Independent Composables
blackbracken
0
100
情報漏洩させないための設計
kubotak
4
700
「とりあえず動く」コードはよい、「読みやすい」コードはもっとよい / Code that 'just works' is good, but code that is 'readable' is even better.
mkmk884
3
650
php-conference-japan-2024
tasuku43
0
350
rails stats で紐解く ANDPAD のイマを支える技術たち
andpad
1
300
Featured
See All Featured
Responsive Adventures: Dirty Tricks From The Dark Corners of Front-End
smashingmag
251
21k
Learning to Love Humans: Emotional Interface Design
aarron
274
40k
Typedesign – Prime Four
hannesfritz
40
2.4k
Building Your Own Lightsaber
phodgson
103
6.1k
A designer walks into a library…
pauljervisheath
205
24k
Testing 201, or: Great Expectations
jmmastey
41
7.1k
[Rails World 2023 - Day 1 Closing Keynote] - The Magic of Rails
eileencodes
33
2k
[RailsConf 2023 Opening Keynote] The Magic of Rails
eileencodes
28
9.1k
Building an army of robots
kneath
302
44k
Facilitating Awesome Meetings
lara
50
6.1k
Thoughts on Productivity
jonyablonski
68
4.4k
The Pragmatic Product Professional
lauravandoore
32
6.3k
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