bendrucker / ama

Ask me questions about building web applications
MIT License
6 stars 1 forks source link

Angular + Browserify #5

Closed demisx closed 9 years ago

demisx commented 9 years ago

Hi Ben. I like your idea of moving away from bower and sticking with npm for managing both, frontend and backend packages. In particular, I am interested in combining Angular 1.x with Browserify. I would appreciate if you could answer a few questions:

  1. What's your overall experience of running Angular and Browserify? Besides requiring modules in a CommonJS way, does it have additional impact on how the rest of the Angular code and tests will be written? I've read somewhere that directive tests get more complicated with Browserify, but not sure if it still holds true.
  2. What's your experience with being able to find the latest front-end packages on npm? Are they maintained and kept up-to-date?
  3. Can you recommend a good resource for integrating Browserify with Angular?
  4. Do you have a sample Angular/Browserify repo to share as reference? Would help with our own shift to Browserify.

Thank you very much.

bendrucker commented 9 years ago
  1. general experience

It's the least bad solution for a portion of software dev that's suffering from a serious lack of quality tooling and expertise right now. I wouldn't say directive tests get worse with it by any stretch. They get better. You can use something like partialify and require html files. Here's an example of what would normally be an enormous string stuffed in an html file that becomes nice with browserify:

https://github.com/bendrucker/angular-credit-cards/blob/master/test/expiration.js#L12

Yes, there's way to do this with Karma. And those ways are wrong. It's always better to import your dependencies from your code and using something like html2js means tightly coupling your test runner to your test files. What happens when you decide you want to use jsdom and test in Node instead? You can't.

  1. npm availability

If it's not on npm, there's a good chance that it's not good, to put it bluntly. Bower is still fine for front end asset dependencies like bootstrap which npm is certainly not made to handle. I don't use 3rd party stylesheets or massive component libraries (e.g. bootstrap) so that's irrelevant to me. There's a lot of truly awful front end code being written right now. I'm talking shipping massive libraries that are un- or under-tested, writing poor docs, and creating a case study in {insert framework here} anti patterns only to get hundreds of GH stars. Curation is poor, so you have to be vigilant about your deps.

The fact that a package is published to npm and has a proper "main" entry in its package already puts it ahead of quite a number of popular angular modules.

  1. I've yet to see a good article describing what I do. This is something I'm interested in blogging about and am in the early stages of putting together ideas and outlines for posts. Full plate this year.
  2. Stay tuned on this front. I've been thinking about ways to help people go from the duct tape approach of shipping barely functional monstrosities to breaking their code down into packages and keeping well organized. The best idea I've got at the momentum is to totally open source my startup so people can see what I consider a really good application. Figure that could happen sometime in Q2 of this year. TBD.
demisx commented 9 years ago

Thank you for complete answer as usual. Would be very interesting to read your blog about this. Hopefully, you'll find some time to write it sooner. What's the best way to be notified about your new blog posts?

bendrucker commented 9 years ago

This list has been silent for a long time, but for when I revive it:

http://druckeronlinemedia.us1.list-manage1.com/subscribe?u=198496c3af3245d3e00853796&id=a286d314b0

Also https://twitter.com/bendrucker

Lastly I'm considering doing some on-the-road teaching and trying to build a critical mass of quick workshops, meetups, conferences, etc to cover the cost of flying and staying in a few cities.

Current thoughts are:

If you know folks using any of the stuff I work on (Node REST APIs, SQL, Firebase, Angular, Browserify) feel free to spread the word. Not looking to transition to full time consulting but more a quick change of pace + and excuse/budget to travel a bit.