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
Welcome JSConf.jp 2024
yosuke_furukawa
PRO
1
3.3k
tc39 x jsconf.jp Panel Discussion 2024
yosuke_furukawa
PRO
0
170
Removing Corepack
yosuke_furukawa
PRO
9
1.3k
JavaScript Runtime とはなにか
yosuke_furukawa
PRO
15
2.5k
Strip Types と Storage
yosuke_furukawa
PRO
4
350
Module Harmony について
yosuke_furukawa
PRO
3
1.6k
LTのやり方
yosuke_furukawa
PRO
16
2.2k
AppRouter Panel Talk
yosuke_furukawa
PRO
3
720
Node.js v22 で変わること
yosuke_furukawa
PRO
13
5.5k
Other Decks in Programming
See All in Programming
開発者とQAの越境で自動テストが増える開発プロセスを実現する
92thunder
1
180
rails statsで大解剖 🔍 “B/43流” のRailsの育て方を歴史とともに振り返ります
shoheimitani
2
930
Effective Signals in Angular 19+: Rules and Helpers @ngbe2024
manfredsteyer
PRO
0
130
たのしいparse.y
ydah
3
120
StarlingMonkeyを触ってみた話 - 2024冬
syumai
3
270
CQRS+ES の力を使って効果を感じる / Feel the effects of using the power of CQRS+ES
seike460
PRO
0
120
Zoneless Testing
rainerhahnekamp
0
120
テストコード文化を0から作り、変化し続けた組織
kazatohiei
2
1.5k
Recoilを剥がしている話
kirik
5
6.6k
Fibonacci Function Gallery - Part 1
philipschwarz
PRO
0
210
Итераторы в Go 1.23: зачем они нужны, как использовать, и насколько они быстрые?
lamodatech
0
740
Symfony Mapper Component
soyuka
2
730
Featured
See All Featured
A designer walks into a library…
pauljervisheath
204
24k
Automating Front-end Workflow
addyosmani
1366
200k
Being A Developer After 40
akosma
87
590k
Easily Structure & Communicate Ideas using Wireframe
afnizarnur
191
16k
Unsuck your backbone
ammeep
669
57k
RailsConf 2023
tenderlove
29
940
Evolution of real-time – Irina Nazarova, EuRuKo, 2024
irinanazarova
5
440
I Don’t Have Time: Getting Over the Fear to Launch Your Podcast
jcasabona
29
2k
How to Create Impact in a Changing Tech Landscape [PerfNow 2023]
tammyeverts
48
2.2k
How STYLIGHT went responsive
nonsquared
95
5.2k
CSS Pre-Processors: Stylus, Less & Sass
bermonpainter
356
29k
jQuery: Nuts, Bolts and Bling
dougneiner
61
7.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ͷӡ༻ݟ • ࠓޙͲ͏ͳΔ͔ෆ໌ɺΈΜͳͰ༗ޮࡦΛߟ͑ ͍ͯ͘ϑΣʔζ