{"id":19560674,"url":"https://github.com/zoubin/gulp-watchify-factor-bundle","last_synced_at":"2025-09-05T10:32:58.036Z","repository":{"id":34179252,"uuid":"38029168","full_name":"zoubin/gulp-watchify-factor-bundle","owner":"zoubin","description":"Use watchify and factor-bundle in gulp","archived":false,"fork":false,"pushed_at":"2016-04-11T09:04:29.000Z","size":24,"stargazers_count":6,"open_issues_count":1,"forks_count":4,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-08-09T07:35:59.465Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/zoubin.png","metadata":{"files":{"readme":"README.md","changelog":"changelog.md","contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2015-06-25T05:09:47.000Z","updated_at":"2018-06-03T02:23:44.000Z","dependencies_parsed_at":"2022-07-13T21:34:00.201Z","dependency_job_id":null,"html_url":"https://github.com/zoubin/gulp-watchify-factor-bundle","commit_stats":null,"previous_names":[],"tags_count":6,"template":false,"template_full_name":null,"purl":"pkg:github/zoubin/gulp-watchify-factor-bundle","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zoubin%2Fgulp-watchify-factor-bundle","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zoubin%2Fgulp-watchify-factor-bundle/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zoubin%2Fgulp-watchify-factor-bundle/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zoubin%2Fgulp-watchify-factor-bundle/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/zoubin","download_url":"https://codeload.github.com/zoubin/gulp-watchify-factor-bundle/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zoubin%2Fgulp-watchify-factor-bundle/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":273746611,"owners_count":25160646,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-09-05T02:00:09.113Z","response_time":402,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-11-11T05:08:26.511Z","updated_at":"2025-09-05T10:32:52.959Z","avatar_url":"https://github.com/zoubin.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# gulp-watchify-factor-bundle\n[![version](https://img.shields.io/npm/v/gulp-watchify-factor-bundle.svg)](https://www.npmjs.org/package/gulp-watchify-factor-bundle)\n[![status](https://travis-ci.org/zoubin/gulp-watchify-factor-bundle.svg)](https://travis-ci.org/zoubin/gulp-watchify-factor-bundle)\n[![coverage](https://img.shields.io/coveralls/zoubin/gulp-watchify-factor-bundle.svg)](https://coveralls.io/github/zoubin/gulp-watchify-factor-bundle)\n[![dependencies](https://david-dm.org/zoubin/gulp-watchify-factor-bundle.svg)](https://david-dm.org/zoubin/gulp-watchify-factor-bundle)\n[![devDependencies](https://david-dm.org/zoubin/gulp-watchify-factor-bundle/dev-status.svg)](https://david-dm.org/zoubin/gulp-watchify-factor-bundle#info=devDependencies)\n\nA sugar wrapper for [browserify], [watchify] and [factor-bundle] to work with [gulp].\n\nThe main ideas are borrowed from [reduce-js].\n\n## Usage\n\ngulpfile.js:\n\n```javascript\nvar reduce = require('gulp-watchify-factor-bundle')\nvar gulp = require('gulp')\nvar path = require('path')\nvar buffer = require('vinyl-buffer')\nvar uglify = require('gulp-uglify')\nvar del = require('del')\n\ngulp.task('clean', function () {\n  return del('build')\n})\n\ngulp.task('build', ['clean'], function () {\n  var basedir = path.join(__dirname, 'src')\n\n  // Create a browserify instance\n  // same with `browserify(opts)`\n  var b = reduce.create({ basedir: basedir })\n\n  // find entries\n  // same with gulp.src()\n  return reduce.src('page/**/index.js', { cwd: basedir })\n    // apply `factor-bundle`\n    // and call b.bundle() which produces a vinyl stream now\n    .pipe(reduce.bundle(b, { common: 'common.js' }))\n\n    // apply gulp plugins to process the vinyl stream\n    .pipe(buffer())\n    .pipe(uglify())\n\n    // same with gulp.dest\n    .pipe(reduce.dest('build'))\n})\n\ngulp.task('watch', ['clean'], function () {\n  var basedir = path.join(__dirname, 'src')\n\n  // Create a browserify instance\n  // same with `browserify(opts)`\n  var b = reduce.create({ basedir: basedir })\n\n  b.on('log', console.log.bind(console))\n\n  // find entries\n  // same with gulp.src()\n  return reduce.src('page/**/index.js', { cwd: basedir })\n    // apply `factor-bundle` and `watchify`\n    .pipe(reduce.watch(b, { common: 'common.js' }))\n    // whenever `b.bundle()` is called,\n    // event 'bundle' is fired\n    .on('bundle', function (vinylStream) {\n      // vinylStream = b.bundle()\n      vinylStream\n        // apply gulp plugins to process the vinyl stream\n        .pipe(buffer())\n        .pipe(uglify())\n        // same with gulp.dest\n        .pipe(reduce.dest('build'))\n    })\n})\n\n\n```\n\nThe source directory:\n```\nexample/src/\n├── node_modules\n│   └── color-map\n│       └── index.js\n└── page\n    ├── blue\n    │   └── index.js\n    └── red\n        └── index.js\n\n```\n\nThe build directory:\n```\n⌘ tree example/build/\nexample/build/\n├── common.js\n└── page\n    ├── blue\n    │   └── index.js\n    └── red\n        └── index.js\n\n```\n\n## Exports\n\n### create()\nSame with the [browserify] constructor.\n\n## bundle(b, bundleOptions)\nA gulp plugin to use [browserify] with [factor-bundle],\nand produces a vinyl stream.\n\n**b**\n\nThe browserify instance.\n\n**bundleOptions**\n\nOptions for [factor-bundle].\n\n`bundleOptions.common` specifies the path to the common bundle.\nAll other options are exactly the same with those consumed by [factor-bundle].\n\n**NOTE**\n\n`bundleOptions.outputs` must be an array of file paths.\nHowever, if not specified, a new bundle is created for each entry,\nwith the same path with the entry.\n\n## watch(b, bundleOptions, watchifyOptions)\nA gulp plugin to use [browserify] with [factor-bundle] and [watchify].\n\n**b**\n\nThe browserify instance.\n\n**bundleOptions**\n\nOptions for [factor-bundle].\n\n**watchOptions**\n\nOptions for [watchify].\n\n**NOTE**\nThis method creates a transform to process the entry stream,\nand emit a `bundle` event whenever `b.bundle()` called.\n\n`reduce.watch().on('bundle', vinylStream =\u003e {})`\n\n[watchify]: https://www.npmjs.com/package/watchify\n[factor-bundle]: https://www.npmjs.com/package/factor-bundle\n[browserify]: https://www.npmjs.com/package/browserify\n[gulp]: https://www.npmjs.com/package/gulp\n[reduce-js]: https://www.npmjs.com/package/reduce-js\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fzoubin%2Fgulp-watchify-factor-bundle","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fzoubin%2Fgulp-watchify-factor-bundle","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fzoubin%2Fgulp-watchify-factor-bundle/lists"}