{"id":22354019,"url":"https://github.com/movableink/rollup-split-index","last_synced_at":"2026-03-14T18:05:28.242Z","repository":{"id":33732302,"uuid":"110298705","full_name":"movableink/rollup-split-index","owner":"movableink","description":"Given an es6 input file, output its dependencies in a separate bundle","archived":false,"fork":false,"pushed_at":"2022-02-12T02:47:57.000Z","size":140,"stargazers_count":2,"open_issues_count":5,"forks_count":0,"subscribers_count":4,"default_branch":"master","last_synced_at":"2025-06-04T03:23:31.416Z","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/movableink.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}},"created_at":"2017-11-10T22:30:49.000Z","updated_at":"2020-02-14T02:52:46.000Z","dependencies_parsed_at":"2022-08-07T23:00:38.562Z","dependency_job_id":null,"html_url":"https://github.com/movableink/rollup-split-index","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"purl":"pkg:github/movableink/rollup-split-index","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/movableink%2Frollup-split-index","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/movableink%2Frollup-split-index/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/movableink%2Frollup-split-index/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/movableink%2Frollup-split-index/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/movableink","download_url":"https://codeload.github.com/movableink/rollup-split-index/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/movableink%2Frollup-split-index/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":267845472,"owners_count":24153717,"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-07-30T02:00:09.044Z","response_time":70,"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-12-04T13:10:52.538Z","updated_at":"2026-03-14T18:05:23.200Z","avatar_url":"https://github.com/movableink.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# rollup-split-index\n\n\u003e Splits dependency tree into the entrypoint file and all the rest.\n\nThe purpose of this module is to use rollup to bundle all dependencies into a single file while leaving the `index.js` file human-readable (and human-editable). It does this with two plugins; `dependenciesOnly` can be used while generating `dist/vendor.js` and `importExportToGlobal` can be used while generating `dist/index.js`.\n\n## Install\n\n```sh\n$ yarn add rollup-split-index\n# or:\n$ npm install --save rollup-split-index\n```\n\n## Usage\n\nYour rollup.config.js file can look like this:\n```javascript\nconst config = require(\"./package.json\");\nconst rollup = require(\"rollup\");\n\nconst resolve = require(\"rollup-plugin-node-resolve\");\nconst commonjs = require(\"rollup-plugin-commonjs\");\n\nconst {\n  importExportToGlobal,\n  dependenciesOnly\n} = require(\"rollup-split-index\");\n\nconst inputFile = config.main; // likely index.js\n\nmodule.exports = [\n  {\n    input: inputFile,\n    plugins: [resolve(), commonjs(), dependenciesOnly()],\n    output: {\n      name: importExportToGlobal.referenceName,\n      file: \"dist/vendor.js\",\n      format: \"iife\"\n    }\n  },\n  {\n    input: inputFile,\n    plugins: [resolve(), commonjs(), importExportToGlobal()],\n    output: {\n      file: \"dist/index.js\",\n      format: \"es\"\n    }\n  }\n];\n\n```\n\nYou can then run rollup as usual with:\n```sh\n$ node_modules/.bin/rollup -c rollup.config.js\n```\n\nThis will load `index.js`, trace its dependency tree including `node_modules`, and bundle all dependencies into `dist/vendor.js`. The `vendor.js` file will export a `__rollup_vendor` object referencing all of the imports.\n\nIn addition, this will transform `index.js` by rewriting es6 imports and exports to global declarations. For example:\n\n```javascript\nimport jQuery from 'jquery';\n...\nexport default MyApp\n```\n\nbecomes:\n\n```javascript\nconst jQuery = __rollup_vendor['jquery']\n...\nwindow.MyApp = MyApp;\n```\n\nYou should then be able to load both files in script tags and then reference the default exported variable:\n\n```html\n\u003cscript src=\"./dist/vendor.js\"\u003e\u003c/script\u003e\n\u003cscript src=\"./dist/index.js\"\u003e\u003c/script\u003e\n\u003cscript\u003e\n  console.log(window.MyApp);\n\u003c/script\u003e\n```\n\n## License\n\nMIT\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmovableink%2Frollup-split-index","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmovableink%2Frollup-split-index","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmovableink%2Frollup-split-index/lists"}