Webpack/V5/Migrate Library Target To Library Object
Last update
Sep 6, 2024
This codemod migrates the output.library
and output.libraryTarget
properties in Webpack configurations to the new format required by Webpack 5. It changes output.library
to output.library.name
and output.libraryTarget
to output.library.type
.
Example
Before
module.exports = {output: {library: 'MyLibrary',libraryTarget: 'commonjs2',},};
After
module.exports = {output: {library: {name: 'MyLibrary',type: 'commonjs2',},},};
,
Before
module.exports = {output: {library: 'MyLibrary',libraryTarget: 'commonjs2',filename: 'bundle.js',},};
After
module.exports = {output: {library: {name: 'MyLibrary',type: 'commonjs2',},filename: 'bundle.js',},};
,
Before
module.exports = {output: {library: 'MyLibrary',},};
After
module.exports = {output: {library: {name: 'MyLibrary',type: undefined,},},};
,
Before
module.exports = {output: {library: 'MyLibrary',libraryTarget: 'umd',path: './dist',},};
After
module.exports = {output: {library: {name: 'MyLibrary',type: 'umd',},path: './dist',},};
Build custom codemods
Use AI-powered codemod studio and automate undifferentiated tasks for yourself, colleagues or the community