{"id":18458782,"url":"https://github.com/browserify/bundle-collapser","last_synced_at":"2025-04-12T22:29:25.262Z","repository":{"id":19018140,"uuid":"22241276","full_name":"browserify/bundle-collapser","owner":"browserify","description":"convert bundle paths to IDs to save bytes in browserify bundles","archived":false,"fork":false,"pushed_at":"2021-03-09T14:57:30.000Z","size":22,"stargazers_count":194,"open_issues_count":10,"forks_count":21,"subscribers_count":7,"default_branch":"master","last_synced_at":"2024-05-15T13:09:19.367Z","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":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/browserify.png","metadata":{"files":{"readme":"readme.markdown","changelog":null,"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":"2014-07-25T02:02:54.000Z","updated_at":"2023-12-14T16:51:14.000Z","dependencies_parsed_at":"2022-08-28T14:40:37.481Z","dependency_job_id":null,"html_url":"https://github.com/browserify/bundle-collapser","commit_stats":null,"previous_names":[],"tags_count":9,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/browserify%2Fbundle-collapser","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/browserify%2Fbundle-collapser/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/browserify%2Fbundle-collapser/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/browserify%2Fbundle-collapser/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/browserify","download_url":"https://codeload.github.com/browserify/bundle-collapser/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248639449,"owners_count":21137843,"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","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-06T08:20:02.741Z","updated_at":"2025-04-12T22:29:25.228Z","avatar_url":"https://github.com/browserify.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# bundle-collapser\n\nconvert bundle paths to IDs to save bytes in browserify bundles\n\n[![build status](https://secure.travis-ci.org/browserify/bundle-collapser.png)](http://travis-ci.org/browserify/bundle-collapser)\n\n# example\n\nThe easiest way to use bundle-collapser is from the plugin:\n\n```\n$ browserify -p bundle-collapser/plugin main.js\n```\n\nInstead of the usual output which would have the original `require('./foo.js')`\nstyle calls in it, the output just has `require(2)` style paths, which minifies\nmore compactly:\n\n``` js\n(function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require==\"function\"\u0026\u0026require;if(!u\u0026\u0026a)return a(o,!0);if(i)return i(o,!0);var f=new Error(\"Cannot find module '\"+o+\"'\");throw f.code=\"MODULE_NOT_FOUND\",f}var l=n[o]={exports:{}};t[o][0].call(l.exports,function(e){var n=t[o][1][e];return s(n?n:e)},l,l.exports,e,t,n,r)}return n[o].exports}var i=typeof require==\"function\"\u0026\u0026require;for(var o=0;o\u003cr.length;o++)s(r[o]);return s})({1:[function(require,module,exports){\nmodule.exports = function (n) { return n * 5 }\n\n},{}],2:[function(require,module,exports){\nvar bar = require(1);\n\nmodule.exports = function (n) { return bar(n+1) }\n\n},{}],3:[function(require,module,exports){\nvar foo = require(2);\nvar bar = require(1);\n\nconsole.log(foo(5) * bar(2));\n\n},{}]},{},[3]);\n```\n## api\n\nYou can use bundle-collapser from the api too:\n\n``` js\nvar collapse = require('bundle-collapser');\nvar fs = require('fs');\n\nvar src = fs.readFileSync(__dirname + '/bundle.js', 'utf8');\ncollapse(src).pipe(process.stdout);\n```\n\n# usage\n\nThere is also a command-line program included in this distribution:\n\n```\nusage: bundle-collapser {FILE | -} {OPTIONS}\n\n  Collapse a browser-pack/browserify bundle from STDIN or a FILE.\n\nOPTIONS:\n\n  -h --help  Show this message.\n\n```\n\n# methods\n\n``` js\nvar collapse = require('bundle-collapser')\n```\n\n## var stream = collapse(src)\n\nReturn a readable `stream` of output from\n[browser-pack](https://npmjs.org/package/browser-pack) with the input source\nstring `src` converted to have its `require()` calls collapsed down to the\ndependency targets in the \"deps\" fields from the unpacking.\n\n# install\n\nWith [npm](https://npmjs.org), to get the library do:\n\n```\nnpm install bundle-collapser\n```\n\nand to get the command-line program do:\n\n```\nnpm install -g bundle-collapser\n```\n\n# license\n\nMIT\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbrowserify%2Fbundle-collapser","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbrowserify%2Fbundle-collapser","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbrowserify%2Fbundle-collapser/lists"}