{"id":14155912,"url":"https://github.com/putoutjs/bundler","last_synced_at":"2026-01-03T23:13:33.603Z","repository":{"id":223315540,"uuid":"759938866","full_name":"putoutjs/bundler","owner":"putoutjs","description":"Simplest possible bundler","archived":false,"fork":false,"pushed_at":"2025-12-04T16:33:20.000Z","size":55,"stargazers_count":3,"open_issues_count":0,"forks_count":1,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-12-08T00:47:21.180Z","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/putoutjs.png","metadata":{"files":{"readme":"README.md","changelog":"ChangeLog","contributing":null,"funding":".github/FUNDING.yml","license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null},"funding":{"github":"coderaiser","patreon":"coderaiser","open_collective":"cloudcmd","ko_fi":"coderaiser"}},"created_at":"2024-02-19T16:15:22.000Z","updated_at":"2025-12-04T16:33:23.000Z","dependencies_parsed_at":"2025-06-18T02:02:08.688Z","dependency_job_id":"c60bec68-af9f-4427-bc6a-3fa3c2940e4e","html_url":"https://github.com/putoutjs/bundler","commit_stats":null,"previous_names":["putoutjs/bundler"],"tags_count":8,"template":false,"template_full_name":null,"purl":"pkg:github/putoutjs/bundler","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/putoutjs%2Fbundler","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/putoutjs%2Fbundler/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/putoutjs%2Fbundler/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/putoutjs%2Fbundler/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/putoutjs","download_url":"https://codeload.github.com/putoutjs/bundler/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/putoutjs%2Fbundler/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28194511,"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":"2026-01-03T02:00:06.471Z","response_time":75,"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-08-17T08:05:05.428Z","updated_at":"2026-01-03T23:13:33.587Z","avatar_url":"https://github.com/putoutjs.png","language":"JavaScript","funding_links":["https://github.com/sponsors/coderaiser","https://patreon.com/coderaiser","https://opencollective.com/cloudcmd","https://ko-fi.com/coderaiser"],"categories":["others"],"sub_categories":[],"readme":"# Bundler [![License][LicenseIMGURL]][LicenseURL] [![NPM version][NPMIMGURL]][NPMURL] [![Build Status][BuildStatusIMGURL]][BuildStatusURL] [![Coverage Status][CoverageIMGURL]][CoverageURL]\n\n[NPMURL]: https://npmjs.org/package/@putout/bundler \"npm\"\n[NPMIMGURL]: https://img.shields.io/npm/v/@putout/bundler.svg?style=flat\u0026longCache=true\n[BuildStatusURL]: https://github.com/putoutjs/printer/actions/workflows/nodejs.yml \"Build Status\"\n[BuildStatusIMGURL]: https://github.com/putoutjs/printer/actions/workflows/nodejs.yml/badge.svg\n[LicenseURL]: https://tldrlegal.com/license/mit-license \"MIT License\"\n[LicenseIMGURL]: https://img.shields.io/badge/license-MIT-317BF9.svg?style=flat\n[CoverageURL]: https://coveralls.io/github/putoutjs/printer?branch=master\n[CoverageIMGURL]: https://coveralls.io/repos/putoutjs/printer/badge.svg?branch=master\u0026service=github\n\n## Install\n\n```\nnpm i @putout/bundle\n```\n\n## API\n\n```js\nimport {bundle} from '@putout/bundler';\n\nconsole.log(bundle(CWD, entry, filesystem));\n```\n\n## Internals\n\n### Convert ESM to CommonJS\n\nTo Simplify things up all files converted to CommonJS first.\nLet's suppose none of them use top-level await to get things simpler.\n\n### Parse filenames\n\nTraverse all files starting from `entry` and get all filenames.\n\n- [`parse-require`](https://putout.cloudcmd.io/#/gist/d973366be6b07ab705b5c9d793369904/ca8b6b15fa953d95f57b42e07136c65791f38ca1);\n- [`parse-filenames`](https://putout.cloudcmd.io/#/gist/d973366be6b07ab705b5c9d793369904/3067150ad161029e75b95e9bfff290e03953ef41);\n- [`resolve-filenames`](https://putout.cloudcmd.io/#/gist/8ca1ac9b5fb4d1a47d185836c3f0b393/edf99b8064fe0faf4545aa0cc66138a7fa34c557);\n- [`resolve-require`](https://putout.cloudcmd.io/#/gist/833539f66cb238fcc3b6ca6cee61ef9e/79a068c96b686bb0eacdf3f570d532981499b114);\n- [`bundle-files`](https://putout.cloudcmd.io/#/gist/7dd3bffa8e88f7542c84065f622b63d7/3b1e68e0babc3a72af947076ed9801c0034a096e);\n\n### Bundle all files to object\n\nTraverse filesystem and create object that contains filename and file content:\n\n```js\nconst __filesystem = {\n    '/entry.js': () =\u003e {\n        const client = require('/client.js');\n        console.log(client);\n    },\n    '/client.js': (exports, require, module) =\u003e {\n        module.exports = 'hello';\n    },\n};\n```\n\n### IIFE\n\nMost likely we need IIFE so couple bundles can be loaded on page simultaneously.\n\n### Result Example\n\n```js\nconst __modules = {};\nconst __filesystem = {\n    '/entry.js': () =\u003e {\n        const client = require('/client.js');\n        console.log(client);\n    },\n    '/client.js': (exports, require, module) =\u003e {\n        module.exports = 'hello';\n    },\n};\n\nconst require = (name) =\u003e {\n    const exports = {};\n    const module = {\n        exports,\n    };\n    \n    if (__modules[name])\n        return __modules[name];\n    \n    __filesystem[name](exports, require, module);\n    __modules[name] = module.exports;\n    \n    return module.exports;\n};\n\nrequire('/entry.js');\n```\n\n## License\n\nMIT\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fputoutjs%2Fbundler","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fputoutjs%2Fbundler","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fputoutjs%2Fbundler/lists"}