{"id":15369082,"url":"https://github.com/developit/rollup-plugin-postprocess","last_synced_at":"2025-07-05T15:03:24.959Z","repository":{"id":57162370,"uuid":"117445704","full_name":"developit/rollup-plugin-postprocess","owner":"developit","description":"🎞 Find \u0026 replace postprocessing for Rollup output","archived":false,"fork":false,"pushed_at":"2020-08-15T08:20:12.000Z","size":39,"stargazers_count":18,"open_issues_count":6,"forks_count":5,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-06-28T17:53:24.862Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"https://npm.im/rollup-plugin-postprocess","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/developit.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":"2018-01-14T16:14:16.000Z","updated_at":"2020-12-18T15:17:50.000Z","dependencies_parsed_at":"2022-09-10T09:30:12.594Z","dependency_job_id":null,"html_url":"https://github.com/developit/rollup-plugin-postprocess","commit_stats":null,"previous_names":[],"tags_count":3,"template":false,"template_full_name":null,"purl":"pkg:github/developit/rollup-plugin-postprocess","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/developit%2Frollup-plugin-postprocess","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/developit%2Frollup-plugin-postprocess/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/developit%2Frollup-plugin-postprocess/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/developit%2Frollup-plugin-postprocess/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/developit","download_url":"https://codeload.github.com/developit/rollup-plugin-postprocess/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/developit%2Frollup-plugin-postprocess/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":263747348,"owners_count":23505096,"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:34:03.597Z","updated_at":"2025-07-05T15:03:24.911Z","avatar_url":"https://github.com/developit.png","language":"JavaScript","readme":"# rollup-plugin-postprocess [![npm](https://img.shields.io/npm/v/rollup-plugin-postprocess.svg?style=flat)](https://www.npmjs.org/package/rollup-plugin-postprocess) [![travis](https://travis-ci.org/developit/rollup-plugin-postprocess.svg?branch=master)](https://travis-ci.org/developit/rollup-plugin-postprocess)\n\nApply regex find-and-replace postprocessing to your Rollup bundle.\n\n\n## Installation\n\n`npm i -D rollup-plugin-postprocess`\n\n\n## Usage\n\nWorks just like a [JavaScript String replace](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/replace), including the funtion callback option.\n\n`postprocess()` expects an Array of `[(RexExp) find, (String|Function) replace]` pairs. Alternatively, if a function is provided, it will be invoked for each bundle and can return said pairs.\n\n\n## Example\n\n```js\nimport postprocess from 'rollup-plugin-postprocess';\n\nexport default {\n    plugins: [\n        postprocess([\n            [/\\b(module\\.exports=|export default )([a-zA-Z])/, '$1$2']\n        ])\n    ]\n}\n```\n\n\n## Complex Example\n\nThis example is more practical. Rollup places exports at the end of your bundle, which can often create single-use variables that Uglify does not collapse.  Let's implement a find \u0026 replace that \"moves\" the export inline to save some bytes.\n\nIn this example, we'll make use of the fact that find/replacement pairs are executed in sequence. The first pair is used both to remove the existing export statement _and_ to find the export type \u0026 identifier. By the time the second find/replace pair is processed, it can make use of the values found in the first pass.\n\n```js\nimport postprocess from 'rollup-plugin-postprocess';\n\nlet name, exportPrefix;\nexport default {\n    plugins: [\n        postprocess([\n            [\n                /(module\\.exports\\s*=\\s*|export\\s*default\\s*)([a-zA-Z$_][a-zA-Z0-9$_]*)[;,]?/,\n                (str, prefix, id) =\u003e {\n                    name = id;\n                    exportPrefix = prefix;\n                    // returning nothing is the same as an empty string\n                }\n            ],\n            [\n                /^function\\s([a-zA-Z$_][a-zA-Z0-9$_]*)/,\n                (str, id) =\u003e id==name ? `${exportPrefix} function` : str\n            ]\n        ])\n    ]\n};\n```\n\n\n## License\n\n[MIT](https://oss.ninja/mit/developit)\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdevelopit%2Frollup-plugin-postprocess","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdevelopit%2Frollup-plugin-postprocess","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdevelopit%2Frollup-plugin-postprocess/lists"}