{"id":15365952,"url":"https://github.com/andywer/bundle-decomposition-research","last_synced_at":"2025-10-14T18:02:46.266Z","repository":{"id":66057850,"uuid":"143388938","full_name":"andywer/bundle-decomposition-research","owner":"andywer","description":null,"archived":false,"fork":false,"pushed_at":"2018-08-03T06:46:38.000Z","size":68,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-02-27T16:55:55.035Z","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/andywer.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"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}},"created_at":"2018-08-03T06:45:49.000Z","updated_at":"2023-08-14T15:23:05.000Z","dependencies_parsed_at":null,"dependency_job_id":"ae59db04-124e-475a-8795-a31de20eff6d","html_url":"https://github.com/andywer/bundle-decomposition-research","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/andywer%2Fbundle-decomposition-research","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/andywer%2Fbundle-decomposition-research/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/andywer%2Fbundle-decomposition-research/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/andywer%2Fbundle-decomposition-research/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/andywer","download_url":"https://codeload.github.com/andywer/bundle-decomposition-research/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":250497011,"owners_count":21440239,"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-10-01T13:16:47.858Z","updated_at":"2025-10-14T18:02:46.184Z","avatar_url":"https://github.com/andywer.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Research - Decompose bundles\n\n## Goal\n\nInstead of processing one huge bundle as is, it might be less memory and CPU intensive to first decompose the bundle into its chunks, process them separately and then put everything back together.\n\n\n## How to use this repo\n\n```\n$ git clone ...\n$ npm install\n```\n\nThen run one of the scripts to create a tiny test bundle:\n```\n# Run one of them:\n$ npm run browserify\n$ npm run parcel\n$ npm run webpack\n```\n\nNow check the created bundle in `dist/` and copy its code into \u003chttps://astexplorer.net/\u003e to inspect the parsed AST.\n\n\n## Preliminary result\n\n### Decomposition\n\nShould be possible to do in a more or less bundler-agnostic way by this algorithm:\n\n- Parse AST of bundle (already quite an intensive task, though!)\n- Find top-most `CallExpression`\n- Check its `arguments` for `ObjectExpression`/`ObjectLiteral` nodes\n- Take object with the most properties\n  - If this object node contains a lot (\u003e 20 ?) of properties, assume each property is a chunk\n  - Those properties' value might be a function (webpack) or an array containing a function (browserify, parcel)\n\n### Re-composition\n\nShould be easy. Simplest approach:\n\n- During decomposition, replace every chunk's code by a placeholder\n- Keep the input bundle with the replaced chunks while chunks are processed\n- Process bundle skeleton (with chunk placeholders)\n- After processing a chunk, replace the chunk placeholder with the processed chunk\n\n### Evaluation\n\nTODO:\n- Time to transpile/minify the *whole bundle at once* vs *decomposition, separate processing \u0026 re-composition*\n- Size of resulting bundles for both approaches\n- Test with bundles of different size and different bundlers\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fandywer%2Fbundle-decomposition-research","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fandywer%2Fbundle-decomposition-research","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fandywer%2Fbundle-decomposition-research/lists"}