{"id":19560638,"url":"https://github.com/zoubin/factor-vinylify","last_synced_at":"2025-09-05T10:33:03.167Z","repository":{"id":57232365,"uuid":"42988231","full_name":"zoubin/factor-vinylify","owner":"zoubin","description":"Provide a `bundle` function to create a vinyl stream flowing browserify outputs","archived":false,"fork":false,"pushed_at":"2016-05-18T14:43:22.000Z","size":52,"stargazers_count":4,"open_issues_count":0,"forks_count":1,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-08-03T10:53:04.075Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","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":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2015-09-23T08:27:42.000Z","updated_at":"2017-03-08T03:43:31.000Z","dependencies_parsed_at":"2022-08-31T20:51:01.096Z","dependency_job_id":null,"html_url":"https://github.com/zoubin/factor-vinylify","commit_stats":null,"previous_names":[],"tags_count":11,"template":false,"template_full_name":null,"purl":"pkg:github/zoubin/factor-vinylify","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zoubin%2Ffactor-vinylify","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zoubin%2Ffactor-vinylify/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zoubin%2Ffactor-vinylify/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zoubin%2Ffactor-vinylify/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/zoubin","download_url":"https://codeload.github.com/zoubin/factor-vinylify/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zoubin%2Ffactor-vinylify/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":273746629,"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:21.243Z","updated_at":"2025-09-05T10:32:58.134Z","avatar_url":"https://github.com/zoubin.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# factor-vinylify\nProvide a `bundle` function to create a vinyl stream flowing browserify outputs.\n\n[![version](https://img.shields.io/npm/v/factor-vinylify.svg)](https://www.npmjs.org/package/factor-vinylify)\n[![status](https://travis-ci.org/zoubin/factor-vinylify.svg?branch=master)](https://travis-ci.org/zoubin/factor-vinylify)\n[![coverage](https://img.shields.io/coveralls/zoubin/factor-vinylify.svg)](https://coveralls.io/github/zoubin/factor-vinylify)\n[![dependencies](https://david-dm.org/zoubin/factor-vinylify.svg)](https://david-dm.org/zoubin/factor-vinylify)\n[![devDependencies](https://david-dm.org/zoubin/factor-vinylify/dev-status.svg)](https://david-dm.org/zoubin/factor-vinylify#info=devDependencies)\n\n\nBased on [factor-bundle](https://www.npmjs.com/package/factor-bundle),\nthis plugin provides some sugar ways to configure factor-bundle,\nand makes `b.bundle` output a [vinyl](https://www.npmjs.com/package/vinyl) stream,\nwhich flows all output file objects\nto be transformed by [gulp](https://www.npmjs.com/package/gulp) plugins.\n\nTo use [watchify](https://www.npmjs.com/package/watchify) with factor-bundle, try [reduce-js](https://github.com/zoubin/reduce-js).\n\n## example\n\nSee the files in the `example` directory.\n\n```javascript\nvar vinylify = require('..')\nvar browserify = require('browserify')\n\nvar path = require('path')\nvar del = require('del')\nvar gutil = require('gulp-util')\nvar uglify = require('gulp-uglify')\nvar gulp = require('gulp')\n\nvar fixtures = path.resolve.bind(path, __dirname)\nvar log = gutil.log.bind(gutil)\nvar DEST = fixtures('build')\n\ngulp.task('clean', function () {\n  return del(DEST)\n})\n\ngulp.task('outputs', ['clean'], function () {\n  var opts = {\n    entries: ['blue.js', 'green.js', 'red.js'],\n    basedir: fixtures('src'),\n  }\n  return browserify(opts)\n    .plugin(vinylify, {\n      outputs: ['page/blue.js', 'page/green.js', 'page/red.js'],\n      common: 'common.js'\n    })\n    .on('log', log)\n    .on('error', log)\n    .bundle()\n    .pipe(uglify())\n    .pipe(gulp.dest(DEST))\n})\n\ngulp.task('rename', ['clean'], function () {\n  var opts = {\n    entries: ['blue.js', 'green.js', 'red.js'],\n    basedir: fixtures('src'),\n  }\n  return browserify(opts)\n    .plugin(vinylify, {\n      needFactor: true,\n      common: 'common.js'\n    })\n    .on('log', log)\n    .on('error', log)\n    .bundle()\n    .pipe(rename(function (p) {\n      if (p.basename === 'common') {\n        return p\n      }\n      p.dirname += '/page'\n      return p\n    }))\n    .pipe(uglify())\n    .pipe(gulp.dest(DEST))\n})\n\n```\n\n## options\n\n### entries\nSpecify the factor entries.\n\nType: `Function`, `Array`\n\nIf `Function`, it receives all the browserify entries (`b._options.entries`),\nand should return an array of factor entries.\n\nIf not specified, all browserify entries will be used as factor entries.\n\nBrowserify will detect a dependency graph from the inputed browserify entries.\nAnd factor-bundle will put them into several groups according to the factor entries,\nwhich are packed into bundles later.\n\nUsually, a factor entry corresponds to a page-specific bundle.\nAnd modules shared by all page-specific bundles go to a common bundle.\n\nAs browserify entries are executed when the bundles containing them loaded,\nfactor entries are also browserify entries at most times.\n\nHowever, browserify entries that are not factor entries will go to the common bundle,\nand thus executed on every page.\nSo, if you don't want to create a bundle for each browserify entry,\nbe careful to choose the factor entries.\n\nEach element can be either an absolte path or one relative to `b._options.basedir` (not necessarily `options.basedir`).\n\n**NOTE**: browserify entries metioned here are only those directly passed to the browserify constructor,\nnot including those added by `b.add`.\n\n\n### outputs\nSpecify the output file paths.\nYou can also use [gulp-rename](https://github.com/hparra/gulp-rename) to do this job instead.\n\nType: `Function`, `Array`\n\nIf `Function`, it receives the factor entries,\nand should return an array of file paths.\n\nThe outputs array should pair with the factor entries array.\n\nEach element will be used as the file path for the corresponding factor bundle.\nIt could be an absolute path,\nor one relative to `options.basedir`.\n\nEach output file path will be passed to [vinyl-source-stream](https://www.npmjs.com/package/vinyl-source-stream) as the first argument,\nwith `options.basedir` as the second,\nto create a vinyl stream.\n\n\n### basedir\n\nType: `String`\n\nPassed to [vinyl-source-stream](https://www.npmjs.com/package/vinyl-source-stream) as the second argument to create a vinyl stream.\n\nIf not specified, `b._options.basedir` will be used.\n\n### threshold\nSpecify which files go to the common bundle.\n\nType: `Array`\n\nPassed to [multimatch](https://github.com/sindresorhus/multimatch),\nand matched files are put into the common bundle.\n\nType: `RegExp`\n\nAny matched files are put into the common bundle.\n\nType: `Number`, `Function`\n\nIt serves the same purpose with [factor-bundle#threshold](https://github.com/substack/factor-bundle/#var-fr--factorfiles-opts),\nand they share the same signature.\n\n### common\n\nType: `String`\n\nThe file path for the common bundle.\n\n### needFactor\n\nType: `Boolean`\n\nDefault: `false`\n\nTo enable the factor-bundle plugin,\nspecify one of `entries`, `outputs`, and `needFactor`\nas truthy.\n\nUsually,\nif you want to use the default entries and outputs options,\nyou probably need to specify `needFactor` as `true`.\n\nAlso, if you want to suppress the common bundle:\n\n```javascript\ngulp.task('bundle-for-each-browserify-entry-with-no-common', ['clean'], function () {\n  var opts = {\n    entries: ['blue.js', 'green.js', 'red.js'],\n    basedir: fixtures('src'),\n  }\n  return browserify(opts)\n    .plugin(vinylify, {\n      needFactor: true,\n    })\n    .on('log', log)\n    .on('error', log)\n    .bundle()\n    .pipe(uglify())\n    .pipe(gulp.dest(DEST))\n})\n\n```\n\n### commonify\n\nType: `Boolean`\n\nDefault: `true`\n\nIf `true`,\n\n* entries are excluded from the common bundle\n* dedupes that are not entries go to the common bundle\n\nAs stated in [#51](https://github.com/substack/factor-bundle/issues/51),\nif a deduped module is not packed into the same bundle with the module it is deduped against,\nthe deduped module won't work.\nSo we put all dedupe into the common bundle to avoid that problem.\n\nIf you do want entries go to the common bundle,\nspecify a proper [threshold](#threshold) option.\n\n### dedupify\n\nType: `Boolean`\n\nDefault: `true`\n\nIf `true`, entries will never be deduped.\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fzoubin%2Ffactor-vinylify","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fzoubin%2Ffactor-vinylify","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fzoubin%2Ffactor-vinylify/lists"}