Upgrade to PRO for Only $50/Year—Limited-Time Offer! 🔥
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
Node.js v22 で変わること
Search
Yosuke Furukawa
PRO
April 24, 2024
Programming
13
5.4k
Node.js v22 で変わること
2024/04/24 令和トラベルで発表した Node.js v22 で変わることの話です。
Yosuke Furukawa
PRO
April 24, 2024
Tweet
Share
More Decks by Yosuke Furukawa
See All by Yosuke Furukawa
Welcome JSConf.jp 2024
yosuke_furukawa
PRO
0
3.1k
tc39 x jsconf.jp Panel Discussion 2024
yosuke_furukawa
PRO
0
160
Removing Corepack
yosuke_furukawa
PRO
9
1.3k
JavaScript Runtime とはなにか
yosuke_furukawa
PRO
15
2.5k
Strip Types と Storage
yosuke_furukawa
PRO
4
340
Module Harmony について
yosuke_furukawa
PRO
3
1.5k
LTのやり方
yosuke_furukawa
PRO
16
2.2k
AppRouter Panel Talk
yosuke_furukawa
PRO
3
720
リアーキテクトと開発生産性について
yosuke_furukawa
PRO
25
9.8k
Other Decks in Programming
See All in Programming
ソフトウェアの振る舞いに着目し 複雑な要件の開発に立ち向かう
rickyban
0
820
flutterkaigi_2024.pdf
kyoheig3
0
470
Discord Bot with AI -for English learners-
xin9le
1
110
42 best practices for Symfony, a decade later
tucksaun
1
140
CSC305 Lecture 25
javiergs
PRO
0
120
我々のデザインシステムは Chakra v3 にアップデートします
shunya078
2
2.9k
Thoughts and experiences on Rust and TypeScript
unvalley
2
220
Modular Monolith Monorepo ~シンプルさを保ちながらmonorepoのメリットを最大化する~
yuisakamoto
11
4k
似たもの同士のPerlとPHP
uzulla
1
110
DevTools extensions で 独自の DevTool を開発する | FlutterKaigi 2024
kokiyoshida
0
450
14 Years of iOS: Lessons and Key Points
seyfoyun
1
690
急成長期の品質とスピードを両立するフロントエンド技術基盤
soarteclab
0
760
Featured
See All Featured
Stop Working from a Prison Cell
hatefulcrawdad
267
20k
Design and Strategy: How to Deal with People Who Don’t "Get" Design
morganepeng
126
18k
The MySQL Ecosystem @ GitHub 2015
samlambert
250
12k
Building an army of robots
kneath
302
43k
KATA
mclloyd
29
14k
Creating an realtime collaboration tool: Agile Flush - .NET Oxford
marcduiker
26
1.8k
How GitHub (no longer) Works
holman
310
140k
Code Review Best Practice
trishagee
64
17k
A Philosophy of Restraint
colly
203
16k
Git: the NoSQL Database
bkeepers
PRO
427
64k
YesSQL, Process and Tooling at Scale
rocio
169
14k
The Myth of the Modular Monolith - Day 2 Keynote - Rails World 2024
eileencodes
17
2.2k
Transcript
Node.js v22 ͰมΘΔ͜ͱ 2024/4/24 @ ྩτϥϕϧ
X: @yosuke_furukawa Github: yosuke-furukawa
Node.js v21 => v22 ͰมΘͬͨ͜ͱΛ· ͱΊ·͢
໔ • v21 Ͱ͢ͰʹೖͬͯΔͷؚΈ·͢ • 21 ͱ 22 Major
Version up Ͱ͋ΓɺػೳͷՃ Minor Version up Ͱ͢ͰʹߦΘΕͯΔͷଟ͍ͨΊ
1ݸ!!!
Ϛείοτര
Ϛείοτ
Ϛείοτ • ࣮ੲ͔ΒϚείοτΩϟϥΫλʔͱͯ͠ΧϝͱϩέοτͷΞ ΠσΞ͋ͬͨɻ
αΫαΫߦ͘Αʂ2ݸ!!!
require(ESM)
require(ESM) • ͜Ε·Ͱͷঢ়گ • Node.js ٴͼ JS ʹ̎ͭͷmodule load ํ͕ࣜ͋Δ
• ESM ͱ CJS • ैདྷ͋ͬͨͷ͕ CJS, 2015Ҏ߱ʹͰ͖ͨͷ͕ESM • ESM ͔Β CJS ಡΊ͕ͨɺٯͷCJS͔ΒESMΛಡΉ͜ͱ͕Ͱ͖ͳ͔ͬͨ
require(ESM) • ྫ͑ΔͳΒɺ USB-C ͱ USB-A Έ͍ͨͳɾɾɾʁ • USB-CରԠσόΠε USB-CɺUSB-A྆ํରԠͰ͖ΔʢΞμϓλചͬͯΔ͠ɺن֨
తʹೝΊΒΕͯΔʣ • USB-AରԠσόΠεUSB-C͔Βܨ͛ͳ͍ɻʢΞμϓλചͬͯΔ͚Ͳɺن֨֎ͰೝΊ ΒΕͯͳ͍ʣ • CରԠ AରԠ AରԠ CରԠ
require(ESM) • ͖݅Ͱ CJS => ESM ೝΊΔ͜ͱʹͳͬͨ • ͖ͬ͞ͷྫͰݴ͑ɺ USB-A
σόΠε͔Β USB-C ͷม͕ ن্֨ೝΊΒΕΔΑ͏ʹͳͬͨɻ • ݅͋ΔɺதͰ top-level-await Λ͍ͯ͠Δͱμϝ • USB-A=>USB-CUSB-Cͷಠࣗػೳ͑ͳ͍ͷͱಉ͡
require(ESM) • --experimental-require-moduleϑϥά͕ࠓඞཁ • ͭ·Γ·࣮ͩݧஈ֊ • ࠓޙϑϥάແ͠Ͱ͑ΔΑ͏ʹ͍ͯ͘͠༧ఆ
3ݸʂʂʂ
v8 Maglev
v8 Maglev • v8 ͱ͍͏ JavaScript ࣮ߦΤϯδϯ͕มΘͬͨɻ • Just In
Time Compiler ʹ֊͕͋Δɻ • ࠓ·Ͱ Ignition, Sparkplug, TurboFan ͷ3ͩͬͨͷ͕ɺ4ʹ ͳͬͨɻ Ignition, Sparkplug, Maglev, TurboFan
v8 Maglev • ઈͬ͘͟Γݴ͏ͱ: • 3ஈมΪΞ͔Β4ஈมΪΞʹมΘͬͨ • ΪΞ͕૿͑Δ㲈͍ΖΜͳہ໘ʹରԠͰ͖Δ • ݁Ռɺੑೳ໘Ͱશମతʹߴʹɻ
v8 Maglev • Node.js ͷதͰݴ͏ͱɺServer Side ͷվળͱ͍͏ΑΓCLIΈ ͍ͨͳγϣʔτλΠϜͰ͏Α͏ͳΞϓϦέʔγϣϯͰվળ͞ ΕͯΔɻ •
tsc ࣮ߦ, linter, formatter etc
4ݸʂʂʂ
node --run
node --run • npm run hogehoge Ͱ࣮ߦ͍ͯͨ͠ script ࣮ߦʹ৽͍͠ํ๏͕ ೖͬͨɻ
• node --run hogehoge Ͱ࣮ߦՄೳ • ͜ΕʹΑΓɺ npm ্ཱͪ͛·Ͱͷىಈ࣌ؒΛݮΒͯ͠ύ ϑΥʔϚϯεվળͰ͖ΔΑ͏ʹͳ͍ͬͯΔɻ
node --run • npm run test ΑΓ node --run test
ͷํ͕͍ͬͯ͜ͱ • దͳڥͰ࣮ߦͨ݁͠Ռͩͱ100msલޙ͍ɻ
5ݸʂʂʂ
fs.glob, fs.globSync
fs.glob,fs.globSync import { glob } from 'node:fs/promises'; for await (const
entry of glob('**/*.mjs')) { console.log(entry); } // foo.mjs // bar/baz.mjs // hoge/fuga/piyo.mjs
͜Μͳײ͡Ͱ
Node.js v22 • ৭ʑϦϦʔε͞ΕͯΔ͚Ͳɺجຊͦ͜·Ͱ৽͍͠ͷͰͳ ͍ɻ • خ͍͠ͷଟ͍ɻΑΓྑ͘͢ΔͨΊͷεςοϓόΠεςοϓͷ ਐԽ͕خ͍͠ɻ • ֵ৽తͳਐԽͰͳ͘ɺਐతͳਐԽ