There have been many heated debates about how you should structure and manage your JavaScript code; specifically what module pattern to use: RequireJS or CommonJS. One's allegiance is usually determined by environment variables -- Node or the browser. As the front end world goes barreling into the future, this distinction is beginning to get blurry. Let's take an objective look at the advantages and disadvantages of each approach and have a healthy conversation as to why you would choose one over the other. Let's hug it out. Won't you join me?
2. I AM WHO I THINK I AM.
VP of Engineering at Novus.com where we do financial
analysis awesomely
Previously worked at The New York Times doing dev, dev
mgmt and dev relations
I also consider myself something of a punk
@joe_sepi on the twitter machine
6. WHAT ARE THE PROBLEMS WE ARE TRYING TO
SOLVE?
<citsc"."<srp>srp sc"."<srp>srp sc"."<srp>srp
srp r=..>/cit<cit r=..>/cit<cit r=..>/cit<cit
MApsmtigwaee.oetofr'al)
yp.oehn.htvrgn.o.a(fi';
ti ms la bfr ta btntbfr
hs ut od eoe ht u o eoe
7. So those are the problems we are trying to solve, but what are
the benefits of solving these problems?
performance, stability, sanity, reuse,
8. HOW DO WE GET THERE?
Modules
Tooling
Bonus: Repository
15. IN TERMINAL
$bosrf mi.s>bnl.s
rweiy anj
udej
INDEX.HTML
<citsc"sbnl.s>/cit
srp r=j/udej"<srp>
MAIN.JS
vrbe =rqie'ep)
a ep
eur(be';
vrbo =rqie'op)
a op
eur(bo';
be(;
ep)
bo(;
op)
BEEP.JS
vrrbt=rqie'oo';
a oo
eur(rbt)
vrsek=fnto ( {
a pa
ucin )
rbt'ep)
oo(be';
}
;
mdl.xot =sek
oueeprs
pa;
ROBOT.JS
mdl.xot =fnto (){
oueeprs
ucin s
rtr cnoelgstUprae)+'';
eun osl.o(.opeCs(
!)
}
;
16. BEEP + ROBOT?? - USING MODULE.EXPORTS OBJECT
vrrbt=rqie'oo';
a oo
eur(rbt)
vrsek=fnto ( {
a pa
ucin )
rbt'ep)
oo(be';
}
;
vrdne=fnto ( {
a ac
ucin )
$'oy)apn(<m sc"acn-edrgf>)
(bd'.ped'ig r=dnigbne.i"';
}
;
mdl.xot ={
oueeprs
sek:sek
pa
pa,
dne:dne
ac
ac
}
17. BEEP + ROBOT?? - USING EXPORTS.WHATEVS
vrrbt=rqie'oo';
a oo
eur(rbt)
eprssek=fnto ( {
xot.pa
ucin )
rbt'ep)
oo(be';
}
;
eprsdne=fnto ( {
xot.ac
ucin )
$'oy)apn(<m sc"acn-edrgf>)
(bd'.ped'ig r=dnigbne.i"';
}
;
18. BEEP + ROBOT?? - USING REQ WITH HYBRID PATTERN
dfn(ucinrqie eprs mdl){
eiefnto(eur, xot, oue
vrrbt=rqie'oo';
a oo
eur(rbt)
eprssek=fnto ( {
xot.pa
ucin )
rbt'ep)
oo(be';
}
;
eprsdne=fnto ( {
xot.ac
ucin )
$'oy)apn(<m sc"acn-edrgf>)
(bd'.ped'ig r=dnigbne.i"';
}
;
};
)