Modularize javascript using browserify

Hello guys I’ve been working with sage and so far I haven’t had any problem, congrats for an excellent solution to wordpress themes.

I’m creating a theme that use lot of javascript and I’ve thought to add browserify to modularize the code because I don’t know how to load scripts outside of main.js and this file is getting too long.

My question is, how can I create a separate js file per page and load it into the main.js? The only way I found to achieve this is creating a jquery plugin and call it on the “about_us” or any other page like this:

  'about_us': {
    init: function () {
      $('[data-component="posts-filter"]').filterPosts();
    }
  }