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
「とりあえず動く」コードはよい、「読みやすい」コードはもっとよい / Code that 'just works' is good, but code that is 'readable' is even better.
mkmk884
3
420
Spatial Rendering for Apple Vision Pro
warrenm
0
110
Go の GC の不得意な部分を克服したい
taiyow
3
790
42 best practices for Symfony, a decade later
tucksaun
1
180
CSC305 Lecture 26
javiergs
PRO
0
140
アクターシステムに頼らずEvent Sourcingする方法について
j5ik2o
4
280
Fibonacci Function Gallery - Part 1
philipschwarz
PRO
0
220
テストケースの名前はどうつけるべきか?
orgachem
PRO
0
140
これでLambdaが不要に?!Step FunctionsのJSONata対応について
iwatatomoya
2
3.7k
今年一番支援させていただいたのは認証系サービスでした
satoshi256kbyte
1
260
暇に任せてProxmoxコンソール 作ってみました
karugamo
2
720
PHPとAPI Platformで作る本格的なWeb APIアプリケーション(入門編) / phpcon 2024 Intro to API Platform
ttskch
0
250
Featured
See All Featured
VelocityConf: Rendering Performance Case Studies
addyosmani
326
24k
10 Git Anti Patterns You Should be Aware of
lemiorhan
PRO
656
59k
個人開発の失敗を避けるイケてる考え方 / tips for indie hackers
panda_program
95
17k
It's Worth the Effort
3n
183
28k
Refactoring Trust on Your Teams (GOTO; Chicago 2020)
rmw
32
2.7k
We Have a Design System, Now What?
morganepeng
51
7.3k
Building Your Own Lightsaber
phodgson
103
6.1k
How to train your dragon (web standard)
notwaldorf
88
5.7k
The Cost Of JavaScript in 2023
addyosmani
45
7k
Building an army of robots
kneath
302
44k
Rails Girls Zürich Keynote
gr2m
94
13k
Large-scale JavaScript Application Architecture
addyosmani
510
110k
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ͷӡ༻ݟ • ࠓޙͲ͏ͳΔ͔ෆ໌ɺΈΜͳͰ༗ޮࡦΛߟ͑ ͍ͯ͘ϑΣʔζ