rspack icon indicating copy to clipboard operation
rspack copied to clipboard

[SwcJsMinimizerRspackPlugin] Alignment with terser-webpack-plugin for format.comments

Open andrewcartwright1 opened this issue 1 year ago • 1 comments

What subject does this issue tracking?

The current implementation of the SwcJsMinimizerRspackPlugin format.comments (https://rspack.dev/plugins/rspack/swc-js-minimizer-rspack-plugin) does not allow regex to be used like https://webpack.js.org/plugins/terser-webpack-plugin/#preserve-comments

new TerserPlugin({
        terserOptions: {
          format: {
            comments: /@.* [\w|\d].*|==\/?UserScript==/i
          }
        }
      })

it instead requires either comments?: false | 'some' | 'all';, would like to propose supporting a regex so that certain comments will be left untouched when using SwcJsMinimizerRspackPlugin as a minimizer

andrewcartwright1 avatar Aug 07 '24 09:08 andrewcartwright1

This feature can be sent to swc repository as well

JSerFeng avatar Aug 08 '24 16:08 JSerFeng

Closes as https://github.com/swc-project/swc/pull/10571

CPunisher avatar Sep 04 '25 08:09 CPunisher