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
Spin me a Yarn
Search
Serena Fritsch
May 02, 2017
Programming
1
59
Spin me a Yarn
DublinJS 2017
Serena Fritsch
May 02, 2017
Tweet
Share
More Decks by Serena Fritsch
See All by Serena Fritsch
Let Me Ember this for You
serenaf
0
240
Emberconf 2017 - Spin me a Yarn
serenaf
0
170
Crafting the Perfect Computed Property
serenaf
0
59
Other Decks in Programming
See All in Programming
Keeping it Ruby: Why Your Product Needs a Ruby SDK - RubyWorld 2024
envek
0
180
Итераторы в Go 1.23: зачем они нужны, как использовать, и насколько они быстрые?
lamodatech
0
730
生成AIでGitHubソースコード取得して仕様書を作成
shukob
0
340
暇に任せてProxmoxコンソール 作ってみました
karugamo
1
720
複雑な仕様に立ち向かうアーキテクチャ
myohei
0
170
CSC305 Lecture 26
javiergs
PRO
0
140
fs2-io を試してたらバグを見つけて直した話
chencmd
0
230
見えないメモリを観測する: PHP 8.4 `pg_result_memory_size()` とSQL結果のメモリ管理
kentaroutakeda
0
330
Mermaid x AST x 生成AI = コードとドキュメントの完全同期への道
shibuyamizuho
0
160
短期間での新規プロダクト開発における「コスパの良い」Goのテスト戦略」 / kamakura.go
n3xem
2
170
競技プログラミングへのお誘い@阪大BOOSTセミナー
kotamanegi
0
360
testcontainers のススメ
sgash708
1
120
Featured
See All Featured
Designing for humans not robots
tammielis
250
25k
Rails Girls Zürich Keynote
gr2m
94
13k
GraphQLとの向き合い方2022年版
quramy
44
13k
Code Review Best Practice
trishagee
65
17k
Save Time (by Creating Custom Rails Generators)
garrettdimon
PRO
28
900
Six Lessons from altMBA
skipperchong
27
3.5k
Exploring the Power of Turbo Streams & Action Cable | RailsConf2023
kevinliebholz
28
4.4k
StorybookのUI Testing Handbookを読んだ
zakiyama
27
5.3k
How To Stay Up To Date on Web Technology
chriscoyier
789
250k
Designing on Purpose - Digital PM Summit 2013
jponch
116
7k
The Language of Interfaces
destraynor
154
24k
VelocityConf: Rendering Performance Case Studies
addyosmani
326
24k
Transcript
Spin me a Yarn Serena Fritsch @serifritsch
[email protected]
DublinJS 2017
None
Once upon a time…
๏ First release in 2010
๏ First release in 2010 ๏ NPM Registry
๏ First release in 2010 ๏ NPM Registry ๏ 347184
published packages https://unpm.nodesource.com/
๏ First release in 2010 ๏ NPM Registry ๏ 347184
published packages ๏ 11,164 packages per week https://unpm.nodesource.com/
None
None
xkdc.com and reddit
๏ Non-Determinism
๏ Non-Determinism ๏ Performance
๏ Uses npm registry
๏ Uses npm registry ๏ Consistent and reliable dependency resolution
๏ Uses npm registry ๏ Consistent and reliable dependency resolution
๏ Improved performance
Dependency Resolution? Non-Determinism? Performance?
None
In the beginning…
Disclaimer ✓ You use a package manager ✓ You are
familiar with the npm eco system
What are packages?
Piece of software that can be downloaded
May depend on other packages
What are dependencies? a^1.0.0 b^1.0.0 App
Specified inside the package.json a^1.0.0 b^1.0.0 App
a^1.0.0 b^1.0.0 App Follow semantic versioning
https://xkcd.com/1172/
Multiple levels of dependencies a^1.0.0 s^1.0.0 App b^1.0.0 s^2.0.0
a^1.0.0 s^1.0.0 App b^1.0.0 s^2.0.0 No dependency conflicts
Under the hood
Project Code
Project Code Manifest +
Project Code Manifest + Dependency Code
goo.gl/LJSNmP
None
Disclaimer ✓ First-time installation ✓ Empty node_modules folder ✓ No
pre-cached packages
Install Phases 1. Dependency Resolution Make requests to the registry
and look up dependencies recursively
Install Phases 2. Fetching Packages Fetch package tarballs and place
in global cache
Install Phases 3. Linking Packages Copying files from global cache
to local node_modules folder
https://github.com/ashleygwilliams/npm-sandbox package.json
https://github.com/ashleygwilliams/npm-sandbox package.json Dependency Graph a^1.0.0 b^1.0.0 App s^1.0.0 s^2.0.0
. . node_modules folder a^1.0.0 b^1.0.0 App s^1.0.0 s^2.0.0
. node_modules folder a1 b1 App s1 s2
. . a1 s1 b1 s2 a1 b1 App s1
s2
. Dependency Resolution 1. Load the existing node_modules tree from
disc a1 b1 App s1 s2
. Dependency Resolution 2. Clone the current tree a1 b1
App s1 s2
. Dependency Resolution 3.Build the ideal tree a1 b1 App
s1 s2
. Dependency Resolution a1 b1 App s1 s2
. Dependency Resolution a1 a1 b1 App s1 s2
. Dependency Resolution a1 a1 b1 App s1 s2
a1 s1 . Dependency Resolution a1 b1 App s1 s2
a1 s1 . Dependency Resolution a1 b1 App s1 s2
a1 s1 b1 . . Dependency Resolution a1 b1 App
s1 s2
a1 s1 b1 . Dependency Resolution a1 b1 App s1
s2
. a1 s1 b1 s2 Dependency Resolution a1 b1 App
s1 s2
. Dependency Resolution 4.Generate Actions to take add
[email protected]
add
[email protected]
add
[email protected]
add
[email protected]
a1 s1 b1 s2 a1 b1 App s1 s2
. Package Fetching and Linking a1 s1 b1 a1 s1
b1 s2
. Dependency Resolution 1.Create a list of Package Requests a1
b1 App s1 s2
. Dependency Resolution 2. Find Version on Registry a1 b1
App s1 s2
. Dependency Resolution 3. Check existing dependencies a1 b1 App
s1 s2
. Dependency Resolution 4. Create a new Package Request and
repeat… a1 b1 App s1 s2 a1
. Dependency Resolution a1 b1 App s1 s2 a1
a1 s1 . Dependency Resolution a1 b1 App s1 s2
a1 s1 . Dependency Resolution a1 b1 App s1 s2
a1 s1 b1 . . Dependency Resolution a1 b1 App
s1 s2
a1 s1 b1 . . Dependency Resolution a1 b1 App
s1 s2
a1 s1 b1 . Dependency Resolution a1 b1 App s1
s2 a1 s1 b1 s2
. Package Fetching and Linking a1 s1 b1 a1 s1
b1 s2
. . Save Lockfile a1 s1 b1 a1 s1 b1
s2
“To make it more clear, your package.json states “what i
want” for the project whereas your lock file says “what I had” in terms of dependencies” -Dan Abramov . . Save Lockfile
.
Differences
None
a1 b1 App s1 s2 c1 s1 a1 b1 s2
s1 c1 https://docs.npmjs.com/how-npm-works/npm3-nondet
Upgrade of Package A a2 b1 App s2 s2 c1
s1
a1 b1 s2 s1 c1 a2 b1 App s2 s2
c1 s1
a1 b1 s2 s1 c1 a2 b1 App s2 s2
c1 s1
a2 b1 s2 s1 c1 a2 b1 App s2 s2
c1 s1
a2 b1 s2 s1 c1 a2 b1 App s2 s2
c1 s1
a2 b1 s2 s1 c1 a2 b1 App s2 s2
c1 s1 s2
a2 b1 s2 s1 c1 a2 b1 App s2 s2
c1 s1 s2
a2 b1 s2 s1 c1 a2 b1 App s2 s2
c1 s1 s2
a2 b1 s2 s1 c1 a2 b1 App s2 s2
c1 s1 s2
a2 b1 s2 s1 c1 a2 b1 App s2 s2
c1 s1 s2
a2 b1 s2 s1 c1 a2 b1 App s2 s2
c1 s1 s2
a2 b1 s2 s1 c1 a2 b1 App s2 s2
c1 s1 s2
a2 b1 s2 s1 c1 a2 b1 App s2 s2
c1 s1 s2
a2 b1 App s2 s2 c1 s1 a2 b1 s2
s1 c1 s2
a2 b1 App s2 s2 c1 s1
a2 b1 App s2 s2 c1 s1
a2 b1 App s2 s2 c1 s1 a2
a2 b1 App s2 s2 c1 s1 a2
a2 s2 a2 b1 App s2 s2 c1 s1
a2 s2 a2 b1 App s2 s2 c1 s1
a2 b1 s2 a2 b1 App s2 s2 c1 s1
a2 b1 s2 a2 b1 App s2 s2 c1 s1
a2 b1 s2 a2 b1 App s2 s2 c1 s1
a2 b1 s2 a2 b1 App s2 s2 c1 s1
a2 b1 App s2 s2 c1 s1 a2 b1 s2
c1
a2 b1 App s2 s2 c1 s1 a2 b1 s2
c1
a2 b1 App s2 s2 c1 s1 a2 b1 s2
c1 s1
a2 b1 s2 c1 s1 a2 b1 s2 s1 c1
s2
Anything I can do? When in doubt, clear node_modules out
Save Lockfile npm shrinkwrap
Save Lockfile By default turned off
Upgrade of Package A a2 b1 App s2 s2 c1
s1
a2 b1 App s2 s2 c1 s1
a2 b1 App s2 s2 c1 s1 a2
a2 b1 App s2 s2 c1 s1 a2
a2 s2 a2 b1 App s2 s2 c1 s1
a2 s2 a2 b1 App s2 s2 c1 s1
a2 b1 s2 a2 b1 App s2 s2 c1 s1
a2 b1 s2 a2 b1 App s2 s2 c1 s1
a2 b1 s2 a2 b1 App s2 s2 c1 s1
a2 b1 s2 a2 b1 App s2 s2 c1 s1
a2 b1 App s2 s2 c1 s1 a2 b1 s2
c1
a2 b1 App s2 s2 c1 s1 a2 b1 s2
c1
a2 b1 App s2 s2 c1 s1 a2 b1 s2
c1 s1
a2 b1 s2 c1 s1
a2 b1 s2 c1 s1
Project Code package.json + + Lockfile
Performance
Issue opened by Sam Saccone November 2015 https://github.com/npm/npm/issues/10380
GET a1 GET b1 GET s1 GET s1 Timeline start
1.0s 1.5s 2.0s 2.5s Multi-Stage Installation
GET a1 GET b1 GET s1 GET s2 Timeline start
1.0s 1.5s 2.0s 2.5s a1 s1 b1 s2
GET a1 GET b1 GET s1 GET s1 Timeline start
1.0s 1.5s 2.0s 2.5s a1 s1 b1 s2
GET a1 GET b1 GET s1 GET s2 Timeline start
1.0s 1.5s 2.0s 2.5s a1 s1 b1 s2
GET a1 GET b1 GET s1 GET s2 Timeline start
1.0s 1.5s 2.0s 2.5s a1 s1 b1 s2
GET a1 GET b1 GET s1 GET s2 Timeline start
1.0s 1.5s 2.0s 2.5s a1 s1 b1 s2
GET a1 GET b1 GET s1 GET s2 Timeline start
1.0s 1.5s 2.0s 2.5s a1 s1 b1 s2
GET a1 GET b1 GET s1 GET s2 Timeline start
1.0s 1.5s 2.0s 2.5s a1 s1 b1 s2
GET a1 GET b1 GET s1 GET s2 Timeline start
1.0s 1.5s 2.0s 2.5s a1 s1 b1 s2
GET a1 GET b1 GET s1 GET s2 Timeline start
1.0s 1.5s 2.0s 2.5s a1 s1 b1 s2
GET a1 GET b1 GET s1 GET s2 Timeline start
1.0s 1.5s 2.0s 2.5s a1 s1 b1 s2
GET a1 GET b1 GET s2 Timeline start 1.0s 1.5s
2.0s 2.5s Built-In Parallelism GET s1
GET a1 GET b1 GET s2 GET s1 Timeline start
1.0s 1.5s 2.0s 2.5s a1 s1 b1 s2
GET a1 GET b1 GET s2 GET s1 Timeline start
1.0s 1.5s 2.0s 2.5s a1 s1 b1 s2
GET a1 GET b1 GET s2 GET s1 Timeline start
1.0s 1.5s 2.0s 2.5s a1 s1 b1 s2
GET a1 GET b1 GET s2 GET s1 Timeline start
1.0s 1.5s 2.0s 2.5s a1 s1 b1 s2
GET a1 GET b1 GET s2 GET s1 Timeline start
1.0s 1.5s 2.0s 2.5s a1 s1 b1 s2
GET a1 GET b1 GET s2 GET s1 Timeline start
1.0s 1.5s 2.0s 2.5s a1 s1 b1 s2
None
Last Chapter
Ember CLI 2.13 onwards is “yarn aware”
Ember CLI 2.13 onwards is “yarn aware” Angular CLI 1.0.0-beta31
onwards is “yarn aware”
Ember CLI 2.13 onwards is “yarn aware” Angular CLI 1.0.0-beta31
onwards is “yarn aware” create-react-app has built-in yarn support since 1.0.2
Community project with governance model taken from Ember and Rust
Contribute https://github.com/yarnpkg/yarn
None
npm 5.0.0 Beta https://github.com/npm/npm/pull/16244
๏ New, standardised Lockfile feature https://github.com/npm/npm/pull/16244
๏ New, standardised Lockfile feature ๏ Cache rewrite https://github.com/npm/npm/pull/16244
๏ New, standardised Lockfile feature ๏ Cache rewrite ๏ Better
summary report https://github.com/npm/npm/pull/16244
http://blog.npmjs.org/
And they lived happily ever after…
Thank You! @serifritsch
[email protected]