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
JavaScript Package Manager 2019
Search
Yosuke Furukawa
PRO
June 27, 2019
Programming
12
5.6k
JavaScript Package Manager 2019
Node学園で発表した JavaScript Package Manager の話です。
Yosuke Furukawa
PRO
June 27, 2019
Tweet
Share
More Decks by Yosuke Furukawa
See All by Yosuke Furukawa
tc39 x jsconf.jp Panel Discussion 2024
yosuke_furukawa
PRO
0
150
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
700
Node.js v22 で変わること
yosuke_furukawa
PRO
13
5.3k
リアーキテクトと開発生産性について
yosuke_furukawa
PRO
25
9.6k
Other Decks in Programming
See All in Programming
Better Code Design in PHP
afilina
PRO
0
120
色々なIaCツールを実際に触って比較してみる
iriikeita
0
330
シールドクラスをはじめよう / Getting Started with Sealed Classes
mackey0225
4
640
ピラミッド、アイスクリームコーン、SMURF: 自動テストの最適バランスを求めて / Pyramid Ice-Cream-Cone and SMURF
twada
PRO
10
1.3k
카카오페이는 어떻게 수천만 결제를 처리할까? 우아한 결제 분산락 노하우
kakao
PRO
0
110
Kaigi on Rails 2024 〜運営の裏側〜
krpk1900
1
200
受け取る人から提供する人になるということ
little_rubyist
0
230
「今のプロジェクトいろいろ大変なんですよ、app/services とかもあって……」/After Kaigi on Rails 2024 LT Night
junk0612
5
2.1k
距離関数を極める! / SESSIONS 2024
gam0022
0
280
Jakarta EE meets AI
ivargrimstad
0
600
A Journey of Contribution and Collaboration in Open Source
ivargrimstad
0
890
Flutterを言い訳にしない!アプリの使い心地改善テクニック5選🔥
kno3a87
1
160
Featured
See All Featured
Learning to Love Humans: Emotional Interface Design
aarron
273
40k
Unsuck your backbone
ammeep
668
57k
Dealing with People You Can't Stand - Big Design 2015
cassininazir
364
24k
We Have a Design System, Now What?
morganepeng
50
7.2k
Designing the Hi-DPI Web
ddemaree
280
34k
Performance Is Good for Brains [We Love Speed 2024]
tammyeverts
6
410
The Success of Rails: Ensuring Growth for the Next 100 Years
eileencodes
44
6.8k
Templates, Plugins, & Blocks: Oh My! Creating the theme that thinks of everything
marktimemedia
26
2.1k
Helping Users Find Their Own Way: Creating Modern Search Experiences
danielanewman
29
2.3k
The Pragmatic Product Professional
lauravandoore
31
6.3k
Fashionably flexible responsive web design (full day workshop)
malarkey
405
65k
Six Lessons from altMBA
skipperchong
27
3.5k
Transcript
JavaScript Package Manager 2019 2019/06/27 @NodeֶԂ 34࣌ݶ
Twitter: @yosuke_furukawa Github: yosuke-furukawa
Berlin Tips
JavaScript Package Manager
OQNJOD ձࣾ OQN$-* OQN3FHJTUSZ ZBSO
npm cli inside
ͦͦnpmͷΈɹ 1. ϩʔΧϧґଘϑΝΠϧΛಡΉ (package.json, package- lock.json, shrinkwrap.json) 2. ଘࡏ͠ͳ͍ύοέʔδͷϝλσʔλΛfetch͢Δ 3.
ߏΛܭࢉͯ͠ɺ࣮ߦ͢Δʢnpm v3 Ҏ߱ͩͱflatten͢ Δʣ 4. ࣮ࡍʹଘࡏ͠ͳ͍ύοέʔδΛμϯϩʔυ͢Δ 5. ΠϯετʔϧεΫϦϓτΛ࣮ߦ͢Δ
ࠓͷͲ͕͜μϝͳͷ͔ • ʮ4. ύοέʔδΛμϯϩʔυ͢Δʯ͕ߴෛՙͷॲཧ • μϯϩʔυ͢Δɺͱ͍͏ߦҝ • tar ball Λ
fetch ͯ͠ɺ • ͔ͦ͜Β gunzip ͯ͠ɺ • Ͱ͖͕͋ͬͨϑΝΠϧΛnode_modulesҎԼʹίϐʔ • ͱ͍͏ϐʔΩʔͳॲཧΛ͍ͯ͠Δɻɹ
ࠓͷͲ͕͜μϝͳͷ͔ • tar ball Λ Fetch => Network IOͷෛՙ •
gunzip => CPUͷෛՙ • node_modules Λίϐʔ => File IOͷෛՙ Կ͔͠ΒͷΫϥΠΞϯτϦιʔεʹෛՙ͕ඞ͔͔ͣΔ
ࠓͷͲ͕͜μϝͳͷ͔ • tar ball Λ Fetch => Network IOͷෛՙ •
gunzip => CPUͷෛՙ • node_modules Λίϐʔ => File IOͷෛՙ ಛʹOPEF@NPEVMFTʹ࣮ମͷϑΝΠϧ͕ඞཁʹͳΔͨΊɺϑΝΠϧͷ૯༰ྔ͕ ૿͑Δɻ
None
tink: A next generation package manager
OQNJOD ձࣾ OQN$-* OQN3FHJTUSZ ZBSO UJOL
npm install ࣌ʹղܾ͢Δͷ Ͱͳ͘ɺ࣮ߦ࣌ʹղܾ͢Ε ͍͍Μͩʂʂʂ
tink sh • `tink sh <cmd>` Ͱىಈ͢Δɻ • tink sh
͕ node Λwrap ͍ͯ͠Δ • ͜ΕͰىಈ͢Δͱ node_modules ΛԾ্ ͷϑΥϧμʹ͢Δࣄ͕Ͱ͖Δɻ $ node foo.js # Ͱىಈ͢ΔͷͰͳ͘ɺ $ tink sh foo.js # Ͱىಈ͢Δɻɹ
node_modulesΛԾ্ͷϑΥ ϧμʹ͢Δ͜ͱͷϝϦοτɹ • ࣮ࡍʹϑΝΠϧΛίϐʔ͠ͳ͍ͨΊɺ File IOͷӨڹ͕ ؇͞ΕΔ • ϩʔΧϧʹ hash
Λϕʔεʹͨ͠cacheΛ࡞Γɺhash ͕Ұகͨ͠ΒcacheΛ͏ Network IOͷӨڹ؇ ͞ΕΔ • ϥϯλΠϜͰϞδϡʔϧΛղܾ͢ΔͨΊɺ npm install ͕ཁΒͳ͘ͳΔɻ
$ git clone && npm install && node app.js Ͱͳ͘
$ git clone && tink sh app.js ͜͏ͳΔ
͜ͷઓུΛ zero install ͱݺͿ
prepare && unwind • prepare ࣄલʹ module Λ fetch ͢ΔίϚ
ϯυ • unwind ࣄલʹ node_modules Λ࣮ମԽ͢ ΔίϚϯυ $ tink prepare $ tink unwind
prepare && unwind • prepare ࣄલʹ module Λ fetch ͢ΔίϚ
ϯυ • unwind ࣄલʹ node_modules Λ࣮ମԽ͢ ΔίϚϯυ $ tink prepare $ tink unwind ຊ൪ىಈ࣌ʹىಈޙͷGFUDIΛ͍ͱͳͷ Ͱɺىಈલʹࣄલॲཧ͢ΔίϚϯυ͕ఏڙ͞ΕͯΔ
loadmap • tink npm v8 Ͱ npm ຊମʹ౷߹͞ΕΔ༧ఆ •
Node ͷίΞʹintegrate༧ఆ
·ͱΊ
·ͱΊ • npm, yarn ࠓޙ zero install ࣌ʹͳ͍ͬͯ ͘ •
ҰํͰɺͲͪΒʹ༗ҙ͕ࠩ͋ΔΑ͏ʹݟ ͑ͳ͔ͬͨ • ·ͩ experimental ৭Μͳͱ͜ΖͰΛग़ ͢ϑΣʔζ
࣍ͷߦ͖·͢ʂʂʂ
JavaScript Registry ͷࠓޙ
JavaScript Registryͱ: package Λ backend Ͱཧ ͍ͯ͠ΔαʔϏε npm, githubͷ͕͋Δ
None
Package Managementͷܦࡁ
RegistryΛϏδωεతʹޭ ͤ͞Δ͜ͱ͍͠ʂʂʂʂ
npmͷϏδωεϞσϧ
npmͷϏδωεϞσϧ • public module ΛແঈͰఏڙɺίετnpm Ͱෛ୲ • private module
enterprise ͳΞΫηείϯτ ϩʔϧΛ͢ΔͳΒ༗ঈ൛Λܖ • public module cost Λ private module ͷച্ Ͱ͏Ϟσϧ
npmͰ͔͍ • 100ສϞδϡʔϧ͋Δ
npm is hard • اۀ͔ΒͷدۚͰ·͔ͳ͏ͷʁ • খ͍͞RegistryͳΒͰ͖Δ͕ɺେ͖͘ͳΔͱ NG • ࠓVenture
CapitalʹཔͬͯΔɻ • VC͔Βͷҙ͕มΘΕӡӦํมΘΔ
͡Ό͋Ͳ͏͢Δ͔
͡Ό͋Ͳ͏͢Δ͔ • தԝूݖཧ͢ΔͷͰͳ͘ɺࢄཧͯ͠ ͍͜͏ • Ұͭʹू͗͢͠Δͱίετूத͢Δ͕ɺ ࢄ͢ΕίετࢄͰ͖Δ
Entropic: a federated package registry
OQNJOD ձࣾ OQN$-* OQN3FHJTUSZ OQN3FHJTUSZ &OUSPQJD UJOL ZBSO &OUSPQJD 3FHJTUSZ
&OUSPQJD$-* ET
Entropic • npmʹܨ͕Δ৽͍͠Registry • ͨͩ͠ࢄཧͰ͖ΔΑ͏ʹ֤छͷRegistryͱ ࿈ܞͰ͖ΔΑ͏ʹͳ͍ͬͯΔ • ͜ΕΒΛ·ͱΊ͋͛ΔͨΊʹdsͱݺΕΔ৽ ͍͠CLI͍࣋ͬͯΔ
package ࢦఆํ๏ • namespace, domain, package nameͷͦΕͧ ΕΛͪΌΜͱࢦఆ͢Δ •
[email protected]
/pkg-name
• npmʹlegacyωʔϜεϖʔεͰଓͰ͖Δ
Entropicͷΰʔϧ • ʮԿ͠ͳ͍Ͱnpm͕ΕΔ͔ɺ༗ޮࡦ͕ग़Δ ·ͰͭʯҎ֎ͷબࢶΛ༻ҙ͍ͨ͠ • ʮRegistryͷӡ༻ݟʯΛΊ͍ͨ • ʮதԝूݖ͔ΒࢄཧʯʹৼΓࢠΛ͍ͨ͠
Entropicͷΰʔϧ • ʮԿ͠ͳ͍Ͱnpm͕ΕΔ͔ɺ༗ޮࡦ͕ग़Δ ·ͰͭʯҎ֎ͷબࢶΛ༻ҙ͍ͨ͠ • ʮRegistryͷӡ༻ݟʯΛΊ͍ͨ • ʮதԝूݖ͔ΒࢄཧʯʹৼΓࢠΛ͍ͨ͠ OQNΛͧ͢ʂͰͳ͘ɺΈΜͳͰӡ༻ݟΛ ߴΊͯࢄཧͰ͖ΔΑ͏ʹ͠Α͏͕ΰʔϧ
·ͱΊ
·ͱΊ • npm vs yarn ͱ͔ͷͰͳ͘ɺࠓ JavaScript Registry ༗ޮࡦ͕ग़ͳ͍ݶΓ·ͣ ͍ঢ়گ
• ࠓٻΊΒΕͯΔͷRegistryͷӡ༻ݟ • ࠓޙͲ͏ͳΔ͔ෆ໌ɺΈΜͳͰ༗ޮࡦΛߟ͑ ͍ͯ͘ϑΣʔζ