-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Regex support for format.comments
of minifier
#9674
Comments
I've been tracking down why our bundle size increased by 10kb and the issue is we have a babel plugin that adds pure comments and then because of this: #9255 all of those comments now stay in the minified file. I would love at least to be able to configure annotations to not be kept. |
@lukpsaxo It's supported. https://swc.rs/docs/configuration/minification#jscminifyformat |
format.comments
format.comments
format.comments
of minifier
@kdy1 I want to keep license comments and not keep pure annotations... I think that is not covered - at least the docs say only "some" and the code-change introducing the keeping of pure annotations didn't look like it was behind its own option (https://github.com/swc-project/swc/pull/9449/files#diff-1955969d1960346434767b5a39f0310edcab0f857933079e6048a50e67b65e38) |
+1 to this I don't need full regex support, but it would be great to preserve license comments and strip the PURE comments in the minifier, as they provide no value at runtime |
@lukpsaxo @abettadapur #9775 will add |
**Description:** - `jsc.output.preserveAnnotations` (`transform()`/`.swcrc`) - `format.preserve_annotations` (`minify()`) are added to support stripping out PURE comments while preserving license comments. **Related issue:** - #9674
Will this prevent the userscript headers from being removed? Reason why I requested the regex is because that regex is what stops terser removing the userscript header |
Describe the feature
The current implementation of the minimizers
format.comments
does not allow regex to be used like https://webpack.js.org/plugins/terser-webpack-plugin/#preserve-commentsit instead requires either comments?: false | 'some' | 'all';, would like to propose supporting a regex so that certain comments will be left untouched
Babel plugin or link to the feature description
https://webpack.js.org/plugins/terser-webpack-plugin/#preserve-comments
Additional context
I raised this originally in the rspack repo but was told it can be sent here as well.
The text was updated successfully, but these errors were encountered: