Webpack To Rspack/Handling Built In Plugins Migrations

1.0.0Last update Oct 12, 2024
by@dfordp
  • Rspack has implemented most of webpack's built-in plugins, with the same names and configuration parameters, allowing for easy replacement.
  • Replace the the include package from webpack to rspack one.
  • Replaces the webpack object in the plugins array to rspack object.
  • Handles only for supported and partially supported built-in plugins. (as of 11th Oct 2024)

Before

//replace the the include package from webpack to rspack one
// and the webpack object in the plugins array to rspack object
const webpack = require('webpack');
module.exports = {
//...
plugins: [
new webpack.DefinePlugin(),
// ...
],
};

After

const rspack = require('@rspack/core');
module.exports = {
//...
plugins: [
new rspack.DefinePlugin({
// ...
}),
],
};

Build custom codemods

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

background illustrationGet Started Now