ng-conf 2014

AngularJS y Browserify

Ben Clinkinbeard  · 

Presentación

HTML (pincha para descargar)

Vídeo

Transcripción

Extracto de la transcripción automática del vídeo realizada por YouTube.

this angularjs with browserify hair he gave me a little introduction when I've got my slides posted up at that bitly link we're just going to dive right in because I'm already down to 14 minutes so we're gonna cover very quickly what browserify

is what it does why using it is a good thing and how your angular code can benefit from it so what the heck is that so quickly how many people have at least heard of browser if I have some sort of idea what it is okay aces so browserify in a bullet point is

require modules for the browser so it's an alternative to something like AMD and requirejs so browserify allows you to use the commonjs module format which is an alternative format to AMD that you would use with requirejs the thing about it is commonjs

is synchronous and so they use it a node because synchronous is okay a node usually synchronous you know dependency loading in the browser is not okay that's where browserify comes in so in case you're not familiar with commonjs syntax we've got

two common J's modules here the top one event J s just exports a string as its value you know that's what it provides to the rest of the world welcome J s imports event and then I vote so the fact that it starts with the dot means that it's like

a relative file path include the underscore is just a named you know external so welcome J s then exports welcome to ng-conf by using the value that it got from event j s you can also export multiple values from a module if you need to by using the exports

object directly so in a bulleted list overly simplified what browserify does you give it an entry file and say start here and read all of my require files and my require statements and walk those those calls to build up my dependency graph so your entry file

maybe requires two other files those two require three more and on and on and on bundles it all into a single file but it doesn't just you know concatenate it into one big blob it actually wraps the contents of each file that it finds in a closure and

that's essentially how it makes the synchronous loading work and so it of course supports source Maps so that you don't have to debug you know the giant output you debug your single files so the closure that I mentioned looks like this and so our initial

module our events module would end up looking like this after browserify parses it and those function arguments should look familiar right it's the require method that you use to load other dependencies and then the module and exports objects that you

[ ... ]

Nota: se han omitido las otras 1.262 palabras de la transcripción completa para cumplir con las normas de «uso razonable» de YouTube.