{"id":16330867,"url":"https://github.com/amarcruz/rollup-plugin-cleanup","last_synced_at":"2025-04-06T21:16:36.667Z","repository":{"id":45024719,"uuid":"67404482","full_name":"aMarCruz/rollup-plugin-cleanup","owner":"aMarCruz","description":"Rollup plugin to remove comments, trim trailing spaces, compact empty lines, and normalize line endings","archived":false,"fork":false,"pushed_at":"2022-01-13T17:22:17.000Z","size":449,"stargazers_count":99,"open_issues_count":12,"forks_count":5,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-03-30T19:11:04.726Z","etag":null,"topics":["cleanup","es2015","filter","javascript","modules","rollup","rollup-plugin"],"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/aMarCruz.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","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":"2016-09-05T08:53:00.000Z","updated_at":"2024-09-19T20:33:03.000Z","dependencies_parsed_at":"2022-09-02T13:10:45.749Z","dependency_job_id":null,"html_url":"https://github.com/aMarCruz/rollup-plugin-cleanup","commit_stats":null,"previous_names":[],"tags_count":13,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/aMarCruz%2Frollup-plugin-cleanup","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/aMarCruz%2Frollup-plugin-cleanup/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/aMarCruz%2Frollup-plugin-cleanup/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/aMarCruz%2Frollup-plugin-cleanup/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/aMarCruz","download_url":"https://codeload.github.com/aMarCruz/rollup-plugin-cleanup/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247550693,"owners_count":20956987,"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":["cleanup","es2015","filter","javascript","modules","rollup","rollup-plugin"],"created_at":"2024-10-10T23:24:46.225Z","updated_at":"2025-04-06T21:16:36.649Z","avatar_url":"https://github.com/aMarCruz.png","language":"JavaScript","funding_links":["https://ko-fi.com/C0C7LF7I"],"categories":[],"sub_categories":[],"readme":"# rollup-plugin-cleanup\n\n[![npm Version][npm-badge]][npm-url]\n[![License][license-badge]][license-url]\n[![AppVeyor Status][appveyor-badge]][appveyor-url]\n[![Travis Status][travis-badge]][travis-url]\n[![Maintainability][climate-badge]][climate-url]\n[![Coverage][coverage-badge]][coverage-url]\n\n[Rollup](http://rollupjs.org/) plugin to remove comments, trim trailing spaces, compact empty lines, and normalize line endings in JavaScript files.\n\nWith the rollup-plugin-cleanup you have:\n\n- Compaction of empty lines within multiline comments and/or out of them.\n- Normalization of line endings to Unix, Mac, or Windows.\n- Removal of JavaScript comments through powerful, configurable filters.\n- Removal of trailing whitespace of each line.\n- TypeScript definitions.\n- Sourcemap support.\n\nFrom v3.1, this plugin no longer uses acorn. See more in the [Whats New](#whats-new) section.\n\nrollup-plugin-cleanup requires node v10.13 or above, but **avoid the buggy v11.x**\n\n**Important:**\n\nrollup-plugin-cleanup is based on [js-cleanup](https://github.com/aMarCruz/js-cleanup) and can handle any JS-like file: TypeScript, Flow, React, ES9, etc, but it is mainly a _postprocessor_, so it should be runned in a later stage of your toolchain, after any preprocessor or transpiler.\n\n**Why not Uglify?**\n\nUglify is a excelent _minifier_ but you have little control over the results, while with js-cleanup your coding style remains intact and the removal of comments is strictly under your control.\n\n## Support my Work\n\nI'm a full-stack developer with more than 20 year of experience and I try to share most of my work for free and help others, but this takes a significant amount of time and effort so, if you like my work, please consider...\n\n[\u003cimg src=\"https://amarcruz.github.io/images/kofi_blue.png\" height=\"36\" title=\"Support Me on Ko-fi\" /\u003e][kofi-url]\n\nOf course, feedback, PRs, and stars are also welcome 🙃\n\nThanks!\n\n## Install\n\n```bash\nnpm install rollup-plugin-cleanup --save-dev\n# or with yarn\nyarn add rollup-plugin-cleanup -D\n```\n\n## Usage\n\n```js\nimport { rollup } from 'rollup';\nimport awesome from 'rollup-plugin-awesome';\nimport cleanup from 'rollup-plugin-cleanup';\n\nrollup({\n  input: 'src/main.js',\n  plugins: [\n    awesome(),        // other plugins\n    cleanup()         // cleanup here\n  ]\n}).then(...)\n```\n\nThat's it.\n\nBy default, only the .js, .jsx, and .tag files are processed, but you can expand or restrict the set of accepted files using the options `include`, `exclude`, and `extensions` (see below).\n\n## Options\n\nFrom v3.1.0 `normalizeEols` is deprecated in favor of `lineEndings` and the properties `ecmaVersion`, `sourceType`, and `acornOptions` are ignored. See more in [Whats New](#whats-new) section.\n\n| Name            | Default  | Description |\n|-----------------|----------|-------------|\n| comments        | `'some'` | Filter or array of filters that determinates which comments should be preserved.\u003cbr\u003eUse \"all\" to keep all, or \"none\" to remove all the comments. |\n| compactComments | `true`   | Should js-cleanup also compact whitespace and blank lines in the preserved multiline comments?\u003cbr\u003eLine-ending normalization is always done. |\n| lineEndings     | `unix`   | Type of Line-ending for normalization: \"unix\", \"mac\", \"win\". |\n| maxEmptyLines   | `0`      | Maximum successive empty lines to preserve in the output.\u003cbr\u003eUse a positive value, or `-1` to keep all the lines. |\n| sourcemap       | `true`   | Should a sourcemap be generated? |\n| extensions      | `['js', 'jsx', 'mjs']` | String or array of strings with extensions of files to process. |\n| exclude         | (none)   | [picomatch](https://github.com/micromatch/picomatch#globbing-features) or array of picomatch patterns for paths to exclude of the process. |\n| include         | (none)   | [picomatch](https://github.com/micromatch/picomatch#globbing-features) or array of picomatch patterns for paths to include in the process. |\n\n## Predefined Comment Filters\n\nInstead the special 'all' or 'none' keywords, you can use any combination of custom filters along with any of these predefined ones:\n\nName     | Will preserve...\n-------- | -----------------\nsome     | Comments containing \"@license\", \"@preserve\", or starting with \"!\".\nlicense  | Comments containing \"@license\".\neslint   | [ESLint](http://eslint.org/docs/user-guide/configuring) directives.\nflow     | Facebook [Flow](https://flow.org/en/docs) directives, [comment types](https://flow.org/en/docs/types/comments/), and [flowlint](https://flow.org/en/docs/linting/flowlint-comments/) comments.\nistanbul | [istanbul](https://github.com/gotwarlost/istanbul/blob/master/ignoring-code-for-coverage.md) ignore comments.\njsdoc    | [JSDoc](http://usejsdoc.org/) comments.\njshint   | [JSHint](http://jshint.com/docs/#inline-configuration) directives.\njslint   | [JSLint](http://www.jslint.com/help.html) directives.\nsources  | Sourcemap directives [sourceURL](https://www.html5rocks.com/en/tutorials/developertools/sourcemaps/#toc-sourceurl) and [sourceMappingURL](https://docs.google.com/document/d/1U1RGAehQwRypUTovF1KRlpiOFze0b-_2gc6fAH0KY0k/edit#heading=h.9ppdoan5f016).\nts       | MS [TypeScript](http://www.typescriptlang.org/) Triple-Slash and @ts-* directives, plus the @jsx pragma.\nts3s     | TypeScript [Triple-Slash](http://www.typescriptlang.org/docs/handbook/triple-slash-directives.html) directives.\n\nFrom v3.1.0, `some` does not includes '@cc_on' and the `jscs` filter was deprecated. See more in [Whats New](#whats-new) section.\n\n'srcmaps' will be preserved as an alias to the 'sources' filter.\n\nSee the regexes in the js-cleanup [src/predef-filters.ts](https://github.com/aMarCruz/js-cleanup/blob/master/src/predef-filters.ts) file.\n\n### Custom Filters\n\nYou can set custom filters through regexes that matches the content of the comments that you want to preserve.\n\nThe string to which the regex is applied does not includes the first slash, nor the `*/` terminator of the multiline comments, so the multiline comments begins with an asterisk (`*`) and single-line comments begins with a slash (`/`).\n\nFor example, the following filters will preserve ESLint directives and multiline comments starting with a dash:\n\n```js\nconst cleanedCode = jsCleanup(code, null, { comments: ['eslint', /^\\*-/] })\n```\n\n## What's New\n\nChanges in v3.2.1\n\n- Fixed #16 ? Thanks to @Aqours, @gevalo1 \u0026 @xania for repoting this issue\n- Using js-cleanup v1.2.0 and Rollup v2.0+\n- Requires NodeJS v10.14.2 or v12.0 and above\n- Updated dependencies\n\n## License\n\nThe [MIT License][license-url] (MIT)\n\n\u0026copy; 2018-2020 Alberto Martínez\n\n[npm-badge]:      https://badgen.net/npm/v/rollup-plugin-cleanup\n[npm-url]:        https://www.npmjs.com/package/rollup-plugin-cleanup\n[license-badge]:  https://img.shields.io/badge/license-MIT-blue.svg?style=flat\n[license-url]:    https://github.com/aMarCruz/rollup-plugin-cleanup/blob/master/LICENSE\n[appveyor-badge]: https://ci.appveyor.com/api/projects/status/vuy62d6cbo1uo0be?svg=true\n[appveyor-url]:   https://ci.appveyor.com/project/aMarCruz/rollup-plugin-cleanup\n[travis-badge]:   https://travis-ci.org/aMarCruz/rollup-plugin-cleanup.svg?branch=master\n[travis-url]:     https://travis-ci.org/aMarCruz/rollup-plugin-cleanup\n[climate-badge]:  https://api.codeclimate.com/v1/badges/a63cdadb2dce668d3e8b/maintainability\n[climate-url]:    https://codeclimate.com/github/aMarCruz/rollup-plugin-cleanup/maintainability\n[coverage-badge]: https://codecov.io/gh/aMarCruz/rollup-plugin-cleanup/branch/master/graph/badge.svg\n[coverage-url]:   https://codecov.io/gh/aMarCruz/rollup-plugin-cleanup\n[kofi-url]:       https://ko-fi.com/C0C7LF7I\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Famarcruz%2Frollup-plugin-cleanup","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Famarcruz%2Frollup-plugin-cleanup","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Famarcruz%2Frollup-plugin-cleanup/lists"}