{"action":"created","issue":{"url":"https://api.github.com/repos/mattlewis92/angular-bluebird-promises/issues/12","labels_url":"https://api.github.com/repos/mattlewis92/angular-bluebird-promises/issues/12/labels{/name}","comments_url":"https://api.github.com/repos/mattlewis92/angular-bluebird-promises/issues/12/comments","events_url":"https://api.github.com/repos/mattlewis92/angular-bluebird-promises/issues/12/events","html_url":"https://github.com/mattlewis92/angular-bluebird-promises/pull/12","id":110120046,"number":12,"title":"Support for browserify","user":{"login":"CJNE","id":1050971,"avatar_url":"https://avatars.githubusercontent.com/u/1050971?v=3","gravatar_id":"","url":"https://api.github.com/users/CJNE","html_url":"https://github.com/CJNE","followers_url":"https://api.github.com/users/CJNE/followers","following_url":"https://api.github.com/users/CJNE/following{/other_user}","gists_url":"https://api.github.com/users/CJNE/gists{/gist_id}","starred_url":"https://api.github.com/users/CJNE/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/CJNE/subscriptions","organizations_url":"https://api.github.com/users/CJNE/orgs","repos_url":"https://api.github.com/users/CJNE/repos","events_url":"https://api.github.com/users/CJNE/events{/privacy}","received_events_url":"https://api.github.com/users/CJNE/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"milestone":null,"comments":4,"created_at":"2015-10-06T23:06:00Z","updated_at":"2015-10-14T08:55:57Z","closed_at":"2015-10-07T11:42:19Z","pull_request":{"url":"https://api.github.com/repos/mattlewis92/angular-bluebird-promises/pulls/12","html_url":"https://github.com/mattlewis92/angular-bluebird-promises/pull/12","diff_url":"https://github.com/mattlewis92/angular-bluebird-promises/pull/12.diff","patch_url":"https://github.com/mattlewis92/angular-bluebird-promises/pull/12.patch"},"body":"Browserify looks for a main property, use the src file to avoid webpack problems.\r\nNice module :)"},"comment":{"url":"https://api.github.com/repos/mattlewis92/angular-bluebird-promises/issues/comments/147981380","html_url":"https://github.com/mattlewis92/angular-bluebird-promises/pull/12#issuecomment-147981380","issue_url":"https://api.github.com/repos/mattlewis92/angular-bluebird-promises/issues/12","id":147981380,"user":{"login":"CJNE","id":1050971,"avatar_url":"https://avatars.githubusercontent.com/u/1050971?v=3","gravatar_id":"","url":"https://api.github.com/users/CJNE","html_url":"https://github.com/CJNE","followers_url":"https://api.github.com/users/CJNE/followers","following_url":"https://api.github.com/users/CJNE/following{/other_user}","gists_url":"https://api.github.com/users/CJNE/gists{/gist_id}","starred_url":"https://api.github.com/users/CJNE/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/CJNE/subscriptions","organizations_url":"https://api.github.com/users/CJNE/orgs","repos_url":"https://api.github.com/users/CJNE/repos","events_url":"https://api.github.com/users/CJNE/events{/privacy}","received_events_url":"https://api.github.com/users/CJNE/received_events","type":"User","site_admin":false},"created_at":"2015-10-14T08:55:57Z","updated_at":"2015-10-14T08:55:57Z","body":"I should explain better :)\r\nI'm using gulp to generate my browserify bundles, splitting them up into a vendor bundle for third-party code and a separate bundle for my app.\r\n```javascript\r\nfunction buildVendor() {\r\n  // this task will go through ./bower.json and\r\n  // uses bower-resolve to resolve its full path.\r\n  // the full path will then be added to the bundle using require()\r\n\r\n  var b = browserify({\r\n    // generate source maps in non-production environment\r\n    debug: false //!production\r\n  });\r\n  gutil.log(\"Build vendor\");\r\n  b.on('log', function(msg) { gutil.log(\"Bundling vendor done \"+msg)});\r\n  b.on('bundle', function(ids) {\r\n    gutil.log(\"Vendor bundle\");\r\n  });\r\n\r\n  // get all bower components ids and use 'bower-resolve' to resolve\r\n  // the ids to their full path, which we need for require()\r\n  getBowerPackageIds().forEach(function (id) {\r\n\r\n    var resolvedPath = bowerResolve.fastReadSync(id);\r\n\r\n    b.require(resolvedPath, {\r\n\r\n      // exposes the package id, so that we can require() from our code.\r\n      // for eg:\r\n      // require('./vendor/angular/angular.js', {expose: 'angular'}) enables require('angular');\r\n      // for more information: https://github.com/substack/node-browserify#brequirefile-opts\r\n      expose: id\r\n\r\n    });\r\n  });\r\n\r\n  // do the similar thing, but for npm-managed modules.\r\n  // resolve path using 'resolve' module\r\n  \r\n  getNPMPackageIds().forEach(function (id) {\r\n    if(id == 'simsfiles') {\r\n      //b.require('simsfiles', { expose: id });\r\n      //Skip simsfiles\r\n    }\r\n    else b.require(nodeResolve.sync(id), { expose: id });\r\n  });\r\n  \r\n\r\n  var stream = b.bundle().pipe(source('vendor.js'));\r\n\r\n  // pipe additional tasks here (for eg: minifying / uglifying, etc)\r\n  // remember to turn off name-mangling if needed when uglifying\r\n\r\n  stream.pipe(gulp.dest('./app/public/dist'));\r\n\r\n  return stream;\r\n}\r\n\r\nfunction getBowerPackageIds() {\r\n  // read bower.json and get dependencies' package ids\r\n  var bowerManifest = {};\r\n  try {\r\n    bowerManifest = require('./bower.json');\r\n  } catch (e) {\r\n    // does not have a bower.json manifest\r\n  }\r\n  return _.keys(bowerManifest.buildDependencies) || [];\r\n}\r\n\r\n\r\nfunction getNPMPackageIds() {\r\n  // read package.json and get dependencies' package ids\r\n  var packageManifest = {};\r\n  try {\r\n    packageManifest = require('./package.json');\r\n  } catch (e) {\r\n    // does not have a package.json manifest\r\n  }\r\n  return _.keys(packageManifest.browserDependencies) || [];\r\n}\r\n```\r\nFor this to work the `main` property needs to be set otherwise node-resolve will not find the file.\r\n\r\nWhy the annoted dist file doesn't work for me might be a separate issue, but there is no need for the annotation when using browserify."}}