Skip to main content
PRONeed enterprise-grade codemods tailored to your codebase?

Assess, plan, evolve.

Reusable compiler-aware skills that help coding agents understand, plan, and safely evolve your codebase.

4 packages

Sort by
webpack/v5/migration-recipe

This recipe is a set of codemods that will help migrate webpack v4 to v5. The recipe includes the following codemods: - webpack/v5/migrate-library-target-to-library-object - webpack/v5/json-imports-to-default-imports - webpack/v5/set-target-to-false-and-update-plugins

  • webpack
  • migration
  • +1
Aakash-kumar-dev
v1.0.1
448
a year ago
webpack/v5/json-imports-to-default-imports

This codemod migrates imports from JSON modules that use named exports to use default exports instead. This codemod transforms named imports from JSON files into default imports, adhering to the new ECMAScript specification and Webpack v5 compatibility. Named imports from JSON modules are no longer supported. ## Example ### Before ```ts import { version } from "./package.json"; console.log(version); ``` ### After ```ts import pkg from "./package.json"; console.log(pkg.version); ``` , ### Before ```ts import { version, name, description } from "./package.json"; console.log(version, name, description); ``` ### After ```ts import pkg from "./package.json"; console.log(pkg.version, pkg.name, pkg.description); ``` , ### Before ```ts import { data } from './config.json'; console.log(data.nested.key, data.anotherKey); ``` ### After ```ts import config from './config.json'; console.log(config.data.nested.key, config.data.anotherKey); ``` , ### Before ```ts import { key1, key2 } from './config.json'; console.log(key1, key2); ``` ### After ```ts import config from './config.json'; console.log(config.key1, config.key2); ```

  • webpack
  • migration
  • +1
Aakash-kumar-dev
v1.0.4
7,904
a year ago
webpack/v5/migrate-library-target-to-library-object

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 ```ts module.exports = { output: { library: "MyLibrary", libraryTarget: "commonjs2", }, }; ``` ### After ```ts module.exports = { output: { library: { name: "MyLibrary", type: "commonjs2", }, }, }; ``` , ### Before ```ts module.exports = { output: { library: "MyLibrary", libraryTarget: "commonjs2", filename: "bundle.js", }, }; ``` ### After ```ts module.exports = { output: { library: { name: "MyLibrary", type: "commonjs2", }, filename: "bundle.js", }, }; ``` , ### Before ```ts module.exports = { output: { library: "MyLibrary", }, }; ``` ### After ```ts module.exports = { output: { library: { name: "MyLibrary", type: undefined, }, }, }; ``` , ### Before ```ts module.exports = { output: { library: "MyLibrary", libraryTarget: "umd", path: "./dist", }, }; ``` ### After ```ts module.exports = { output: { library: { name: "MyLibrary", type: "umd", }, path: "./dist", }, }; ```

  • webpack
  • migration
  • +1
Aakash-kumar-dev
v1.0.1
8,107
a year ago
webpack/v5/set-target-to-false-and-update-plugins

This codemod migrates the `target` property in Webpack configurations from a function to `false` and moves the function to the `plugins` array. In Webpack 4, it was possible to set the `target` property to a function. However, in Webpack 5, this approach is no longer supported. Instead, the `target` should be set to `false`, and the function should be included in the `plugins` array. This codemod automates the transformation of Webpack configurations to adhere to the new specification. ## Example ### Before ```ts module.exports = { target: WebExtensionTarget(nodeConfig), }; ``` ### After ```ts module.exports = { target: false, plugins: [WebExtensionTarget(nodeConfig)], }; ``` , ### Before ```ts const WebExtensionTarget = require("webpack-extension-target"); module.exports = { target: WebExtensionTarget(nodeConfig), mode: "development", output: { filename: "bundle.js", }, }; ``` ### After ```ts const WebExtensionTarget = require("webpack-extension-target"); module.exports = { target: false, plugins: [WebExtensionTarget(nodeConfig)], mode: "development", output: { filename: "bundle.js", }, }; ``` , ### Before ```ts module.exports = { target: WebExtensionTarget(nodeConfig), optimization: { splitChunks: { chunks: "all", }, }, }; ``` ### After ```ts module.exports = { target: false, plugins: [WebExtensionTarget(nodeConfig)], optimization: { splitChunks: { chunks: "all", }, }, }; ``` , ### Before ```ts module.exports = { target: CustomTargetFunction(config), }; ``` ### After ```ts module.exports = { target: false, plugins: [CustomTargetFunction(config)], }; ```

  • webpack
  • migration
  • +1
Aakash-kumar-dev
v1.0.1
962
a year ago

Build your own codemod!

Describe the migration you need and Codemod Agent will create a codemod for you.

Ready to evolve your codebase?

Build tailored, compiler-aware skills to assess, plan, and automate complex codebase changes.