This repository has been archived by the owner on Aug 19, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.html
288 lines (284 loc) · 15 KB
/
index.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>AHM - Say hello to Yarn</title>
<meta name="description" content="A framework for easily creating beautiful presentations using HTML">
<meta name="author" content="Hakim El Hattab">
<meta name="apple-mobile-web-app-capable" content="yes">
<meta name="apple-mobile-web-app-status-bar-style" content="black-translucent">
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no, minimal-ui">
<link href="https://fonts.googleapis.com/css?family=Open+Sans:300,400,600,600i,700,800" rel="stylesheet">
<link rel="stylesheet" href="css/reveal.css">
<link rel="stylesheet" href="css/theme/jobrapido-venus.css" id="theme">
<link rel="stylesheet" href="lib/css/zenburn.css">
<script>
(function() {
'use strict';
var link = document.createElement('link');
link.rel = 'stylesheet';
link.type = 'text/css';
link.href = window.location.search.match(/print-pdf/gi) ? 'css/print/pdf.css' : 'css/print/paper.css';
document.getElementsByTagName('head')[0].appendChild(link);
})();
</script>
<!--[if lt IE 9]>
<script src="lib/js/html5shiv.js"></script>
<![endif]-->
</head>
<body>
<div class="reveal">
<div class="brand"></div>
<div class="slides">
<section>
<h2>Npm vs. campaign manager</h2>
<h1>Say Hello to Yarn</h1>
</section>
<section>
<section>
<h4>Use case</h4>
<img src="lib/img/screen-campaign-manager.png" alt="">
</section>
<section>
<p>
Ogni pacchetto che viene installato può dipendere da altri pacchetti.
<br> Si rischia che alla fine di un grosso progetto ci si ritrovi con centinaia o migliaia di pacchetti nell’albero delle dipendenze.
</p>
<img height="500px" src="lib/img/campaign-manager-packages.png" alt="">
</section>
</section>
<section>
<section>
<h4>Cosa sono i package manager?</h4>
<cite>
Strumenti che consentono di installare e gestire moduli esterni per fornire funzionalità aggiuntive al sistema di base.
</cite>
<div class="image-container">
<img class="fragment" data-fragment-index="1" width="75" src="lib/img/battle.jpg">
<img class="fragment" data-fragment-index="1" width="75" src="lib/img/bower.png">
<img class="fragment" data-fragment-index="1" width="75" src="lib/img/component.png">
<img class="fragment" data-fragment-index="1" width="75" src="lib/img/npm.png">
<img class="fragment" data-fragment-index="1" width="150" src="lib/img/duo.png">
<img class="fragment" data-fragment-index="1" width="75" src="lib/img/jspm.png">
<img class="fragment" data-fragment-index="1" width="75" src="lib/img/gem.ico">
<img class="fragment" data-fragment-index="1" width="75" src="lib/img/pip.png">
</div>
</section>
<section>
<div class="col-6">
<h4>PRO</h4>
<ul>
<li class="fragment" data-fragment-index="1">
Metodo uniforme per installare i pacchetti e tenerne traccia.
</li>
<li class="fragment" data-fragment-index="2">
Popolarità: vi sono migliaia di pacchetti disponibili.
</li>
<li class="fragment" data-fragment-index="3">
Si evita di riscrivere parti di codice utilizzando qualcosa di funzionante, pronto e testato.
<br>
<span class="fragment" data-fragment-index="4"><em>(in teoria)</em></span>
</li>
</ul>
</div>
<div class="col-6">
<h4>CONTRO</h4>
<ul>
<li class="fragment" data-fragment-index="5">
Rischio di trovare documentazioni incomplete o errate.
</li>
<li class="fragment" data-fragment-index="6">
Conflitti fra sottomoduli: durante l'installazione di un modulo, npm installa anche eventuali altri moduli da cui il modulo installato dipende, utilizzando una struttura gerarchica descritta in un file package.json.
</li>
</ul>
</div>
</section>
<section>
<div class="col-6">
<h4>Se siete fortunati...</h4>
<img width="90%" src="lib/img/npm-screen-short.png" alt="">
</div>
<div class="col-6 fragment">
<h4 style="text-align:left;">... vs. Real life</h4>
<img width="90%" src="lib/img/npm-screen-long.png" alt="">
</div>
</section>
</section>
<section>
<section>
<h4>Yarn</h4>
<p>
Per ovviare agli attuali problemi di npm, Facebook e Google hanno deciso di collaborare per creare un nuovo package manager.
</p>
<p>
La sua peculiarità è proprio la capacità di catalogare e installare le dipendenze secondo uno schema di versioning semantico (<em>SEMVER</em>) il quale permette di definire uno schema di controllo delle versioni che riflette i tipi di modifiche in ogni nuova versione (es. se una modifica rompe una API, aggiunge una feature o corregge un bug).
</p>
<p class="fragment">
P.S. La leggenda narra che il nome "YARN" derivi dall'onomatopea dell'urlo che ha cacciato lo sviluppatore di Facebook dopo l'ennesimo problema derivato dai problemi dalle sottodipendenze dei moduli npm.
<br>
<img height="100px" src="lib/img/monkey-pc-1.gif" alt="">
</p>
</section>
<section>
<p>
Lo scopo di Yarn non è quello di sostituire Npm, bensì di migliorarlo.
</p>
<div class="col-6">
<h4>vanilla NPM</h4>
<ul>
<li class="fragment" data-fragment-index="1">
Il client NPM installa le dipendenze in una cartella <em>(node_modules)</em> in maniera “non deterministica”: significa che l’ordine delle dipendenze installate può variare da persona a persona.
<br>Queste differenze possono causare problemi e bug che possono richiedere anche parecchio tempo per il fix.
</li>
<li class="fragment" data-fragment-index="2">
NPM prende le dipendenze solo dalla sua repository e le installa una alla volta, impiegando parecchio tempo.
</li>
<li class="fragment" data-fragment-index="3">
Non consente l’installazione offline.
</li>
</ul>
</div>
<div class="col-6">
<h4>NPM + YARN</h4>
<ul>
<li class="fragment" data-fragment-index="1">
Grazie a “lockfiles” e algoritmi, il client YARN permette di installare le dipendenze in maniera “deterministica”. I lockfiles permettono di bloccare a una specifica versione le dipendenze installate e garantisce che ogni installazione sia uguale in ogni macchina (risolve le differenze di installazione da persona a persona).
</li>
<li class="fragment" data-fragment-index="2">
YARN permette installazioni di dipendenze in parallelo, sfruttando non solo i registri di NPM, ma anche quelli di BOWER.
</li>
<li class="fragment" data-fragment-index="3">
Permette di mettere in cache eventuali pacchetti già installati, facilitando l’installazione offline.
</li>
</ul>
</div>
</section>
<section>
<h4>Come installarlo?</h4>
<pre>
<code>npm install -g yarn</code>
</pre>
<cite class="fragment">
"NPM INSTALL YARN" = getting your ex-girlfriend to move your new girlfriend's stuff into your house.
</cite>
<br>
<div class="fragment">
<h4>Come inizializzarlo?</h4>
<pre>
<code>yarn init</code>
</pre>
<img src="lib/img/yarn-init.png" alt="">
</div>
</section>
<section>
<h4>Come integrarlo in un progetto già avviato?</h4>
<pre>
<code>yarn install</code>
</pre>
<p>Come detto prima, dato che Yarn veste la maschera di "ottimizzatore", si affida principalmente allo stesso package.json di Npm</p>
<img height="300px" data-src="lib/img/yarn-install.gif" alt="">
</section>
<section>
<h4>Come funziona?</h4>
<ol>
<li>
<strong>RESOLUTION</strong>
<p>
Yarn inizia a risolvere le dipendenze facendo richieste ai registri e cercando ogni dipendenza ricorsivamente.
</p>
</li>
<li>
<strong>FETCH</strong>
<p>
Yarn controlla nella cache globale se un pacchetto è stato già installato, in caso di esito negativo scarica il pacchetto e lo salva nella cache.
</p>
</li>
<li>
<strong>LINK</strong>
<p>
Yarn copia tutti i file di cui ha bisogno dalla cache globale dentro la cartella <em>“node_modules”</em>.
</p>
</li>
</ol>
<img height="170px" src="lib/img/yarn.gif" alt="">
</section>
</section>
<section>
<section>
<h4>Conclusione</h4>
<div class="text-sm" style="text-align:justify; line-height:1.6;">
Anche se le premesse che offre Yarn sono ottime, il mondo degli utilizzatori di package manager è spaccato a metà (come sempre in presenza di novità di cui ancora non si conosce a fondo la funzionalità).
<br>
<br> La mia idea è che può essere un ottimo strumento nel caso in cui si debbano mettere le mani in progetti di rilevante entità; in caso contrario punterei ancora su NPM fino a che Yarn non avrà preso abbastanza piede da avere una sicura base di sostenitori e risolutori di bug (anche se nell’effettivo ha ottenuto più statistiche positive in 4 giorni di vita rispetto alla secolare presenza di npm).
</div>
<br>
<strong class="fragment">Polymer sta migrando a Yarn!</strong>
</section>
<section>
<div class="col-6">
<h4>Link utili</h4>
<ul>
<li><a href="https://yarnpkg.com/">Yarn website</a></li>
<li><a href="https://github.com/yarnpkg/yarn/">Yarn github</a></li>
<li><a href="https://yarnpkg.com/en/docs/migrating-from-npm">Migrating from npm</a></li>
</ul>
</div>
<div class="col-6">
<h4>Credits</h4>
<ul>
<li><a href="https://code.facebook.com/posts/1840075619545360">Yarn: A new package manager for JavaScript</a></li>
<li><a href="https://scotch.io/tutorials/yarn-package-manager-an-improvement-over-npm">Yarn Package Manager: An Improvement over npm</a></li>
<li><a href="https://dev.to/bugsnag/replacing-npm-with-yarn">Replacing npm with Yarn</a></li>
</ul>
</div>
</section>
</section>
</div>
</div>
<script src="lib/js/head.min.js"></script>
<script src="js/reveal.js"></script>
<script>
(function() {
'use strict';
Reveal.initialize({
viewDistance: 3,
previewLinks: false,
controls: true,
progress: true,
history: true,
center: true,
transition: 'convex',
slideNumber: true,
dependencies: [{
src: 'lib/js/classList.js',
condition: function() {
return !document.body.classList;
}
}, {
src: 'plugin/markdown/marked.js',
condition: function() {
return !!document.querySelector('[data-markdown]');
}
}, {
src: 'plugin/markdown/markdown.js',
condition: function() {
return !!document.querySelector('[data-markdown]');
}
}, {
src: 'plugin/highlight/highlight.js',
async: true,
callback: function() {
hljs.initHighlightingOnLoad();
}
}, {
src: 'plugin/zoom-js/zoom.js',
async: true
}, {
src: 'plugin/notes/notes.js',
async: true
}]
});
})();
</script>
</body>
</html>