Webpack To Rspack/Migrate Terser Plugin

1.0.0Last update Oct 17, 2024
by@dfordp

Change import and usage of from TerserPlugin to use included rspack.SwcJsMinimizerRspackPlugin.

Before

//chnage the import statement to const rspack = require('@rspack/core');
//track the variable assigned
const TerserPlugin = require('terser-webpack-plugin');
module.exports = {
optimization: {
//change to rspack.SwcJsMinimizerRspackPlugin(options)
minimizer: [new TerserPlugin(options)],
},
};

After

const rspack = require('@rspack/core');
module.exports = {
// ...
optimization: {
minimizer: [new rspack.SwcJsMinimizerRspackPlugin(options)],
},
};

Build custom codemods

Use AI-powered codemod studio and automate undifferentiated tasks for yourself, colleagues or the community

background illustrationGet Started Now