Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Should I use Browserify or Webpack for lazy loading of dependencies in angular 1.x [closed]

I would like to have async loading of angular dependencies in a large application and I'm trying to decide between Browserify or Webpack for this. I know angular 2.0 will support this natively but for now I'm looking for a well supported and popular solution.

Can anyone give advice on which ones works best in an angular team and the most optimal way to structure the project.

like image 613
Nikos Avatar asked May 12 '14 09:05

Nikos


People also ask

Does angular use Browserify?

Now that angular-material plays well with Browserify, we can take advantage of that in our app. Check out the demo to see it all in action. Browserify is a command line tool that you use when building your project.

Is webpack best?

Loved by many, hated by some, known to all. And still the most popular bundler in 2021. With more than 15 million weekly downloads (at the time of writing this post), there's no doubt that Webpack is still the bundler par excellence in 2021.

Should I use webpack?

Should I Use Webpack? If you're building a complex Front End™ application with many non-code static assets such as CSS, images, fonts, etc, then yes, Webpack will give you great benefits.

What is webpack used for?

This is why webpack exists. It's a tool that lets you bundle your JavaScript applications (supporting both ESM and CommonJS), and it can be extended to support many different assets such as images, fonts and stylesheets.


1 Answers

At my company, we've switched over from browserify to webpack for a multitude of reasons, lazy loading being one of them.

Putting things in multiple bundles in browserify took some configuration changes as well as special code. Here is a great guide for that http://esa-matti.suuronen.org/blog/2013/04/15/asynchronous-module-loading-with-browserify/

With webpack, adding a new bundle just means an extra entry file line in the configuration's entry file line. Here is a quick guide to that: https://github.com/petehunt/webpack-howto#7-multiple-entrypoints. In the case of lazy-loading, you don't even need to change anything in the configuration file, which is awesome - just use the asynchronous require syntax detailed here: https://github.com/petehunt/webpack-howto#9-async-loading

Here is a template for a setup very similar to what we use at https://bench.co in production. https://github.com/jeffling/angular-webpack-example/

like image 181
Jeff Ling Avatar answered Oct 24 '22 12:10

Jeff Ling