Rollup plugin to remove comments, trim trailing spaces, compact empty lines, and normalize line endings
Bye, acorn.
Although acorn is an excellent parser, its use in rollup-plugin-cleanup had caused several issues.
v3.1 removes this dependency and now is completely based on js-cleanup, which does not depend on acorn or another similar parser, with the advantage of a relative independency of the version and "dialect" of JavaScript and a little more efficiency, for being a specialized tool.
While js-cleanup is in its first version, I do not expect it to present major problems (the algorithm and the JS rules used for the replacement are fairly simple).
compactComment
option to control the compaction of multiline comments, useful to preserve the format of JSDoc blocks.flow
filter for Facebook Flow comments and directives.ts
filter for MS TypeScript directives.ecmaVersion
, sourceType
, and acornOptions
are ignored, acorn was removed in this version.normalizeEols
option is deprecated in favor of lineEndings
, which have the same behavior.some
filter no longer includes @cc_on
, but adds comments that begin with '!'
.jscs
filter is deprecated, jscs no longer exists.acornOptions
, for advanced usage.
This is an optional, plain JS object with additional settings passed to the Acorn parser. Properties of this object are merged with, and take precedence over, the existing ecmaVersion
and sourceType
options.* MagicString v0.24.x has great enhancements, but it needs testing with this plugin.
sourceMap
or sourcemap
(lowercased) options.error
method."ts3s"
to preserve TypeScript Triple-Slash Directives (See NOTE)NOTE:
TypeScript source must be already compiled to JavaScript.
ecmaVersion
from 6 to 7 to allow parsing ES2017 (See rollup#492).extensions
are changed from "*"
to ['.js', '.jsx', '.tag']
to avoid conflicts with other plugins.extensions
option is case-sensitive by consistency with rollup plugins."/"
for one-line comments, and "*"
for multiline comments.extensions
is "*"
. Because rollup is a JavaScript bundler and cleanup is a JavaScript post-processor, it should work with any file handled by rollup.