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
카카오페이는 어떻게 수천만 결제를 처리할까? 우아한 결제 분산락 노하우
kakao
PRO
0
110
受け取る人から提供する人になるということ
little_rubyist
0
250
Streams APIとTCPフロー制御 / Web Streams API and TCP flow control
tasshi
2
350
エンジニアとして関わる要件と仕様(公開用)
murabayashi
0
300
3 Effective Rules for Using Signals in Angular
manfredsteyer
PRO
1
100
OnlineTestConf: Test Automation Friend or Foe
maaretp
0
110
ECS Service Connectのこれまでのアップデートと今後のRoadmapを見てみる
tkikuc
2
250
みんなでプロポーザルを書いてみた
yuriko1211
0
280
.NET のための通信フレームワーク MagicOnion 入門 / Introduction to MagicOnion
mayuki
1
1.7k
Better Code Design in PHP
afilina
PRO
0
130
WebフロントエンドにおけるGraphQL(あるいはバックエンドのAPI)との向き合い方 / #241106_plk_frontend
izumin5210
4
1.4k
AWS Lambdaから始まった Serverlessの「熱」とキャリアパス / It started with AWS Lambda Serverless “fever” and career path
seike460
PRO
1
260
Featured
See All Featured
How GitHub (no longer) Works
holman
310
140k
Gamification - CAS2011
davidbonilla
80
5k
The Art of Programming - Codeland 2020
erikaheidi
52
13k
RailsConf 2023
tenderlove
29
900
Ruby is Unlike a Banana
tanoku
97
11k
Why You Should Never Use an ORM
jnunemaker
PRO
54
9.1k
The Success of Rails: Ensuring Growth for the Next 100 Years
eileencodes
44
6.8k
Fireside Chat
paigeccino
34
3k
Save Time (by Creating Custom Rails Generators)
garrettdimon
PRO
27
840
RailsConf & Balkan Ruby 2019: The Past, Present, and Future of Rails at GitHub
eileencodes
131
33k
Typedesign – Prime Four
hannesfritz
40
2.4k
Speed Design
sergeychernyshev
25
620
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ͷӡ༻ݟ • ࠓޙͲ͏ͳΔ͔ෆ໌ɺΈΜͳͰ༗ޮࡦΛߟ͑ ͍ͯ͘ϑΣʔζ