vue-codemod is an experimental utility providing a collection of codemod scripts to assist developers in updating Vue.js APIs, primarily for migrating applications from Vue 2 to Vue 3. It leverages Facebook's JSCodeshift for abstract syntax tree (AST) transformations and offers specific support for `.vue` single-file components. As of version `0.0.5`, it includes transformations like `remove-vue-set-and-delete` and outlines a roadmap for further features, including TypeScript support and broader module system compatibility. Maintained by the Vue.js team, its "experimental" status and low version number indicate a development cadence focused on feature completion rather than rapid, frequent releases, positioning it as a tool for early adopters or those undertaking significant migrations. Its key differentiators include official Vue team backing and direct support for `.vue` file transformations, which are critical for comprehensive Vue application upgrades.
npm install vue-codemodVerified import paths — ran on the pinned version, not inferred.
Demonstrates the programmatic usage of `vue-codemod` by applying a simple, custom transformation to a temporary file. This illustrates how to interface with `runTransformation` directly, though CLI usage is more common.
Upgrade your Node.js installation to version 10 or newer. Tools like `nvm` (Node Version Manager) can facilitate this.
Always use a version control system and conduct thorough testing of your application after applying codemods. Review the generated code carefully before deploying to production environments.
Adhere to the complete migration path outlined in the official Vue 3 migration guide, which includes leveraging ESLint, manual review, and the compatibility build alongside codemods.
Verify the transformation name against the list of included transformations in the `vue-codemod` documentation, or ensure the path to your custom transformation is accurate and accessible.
Double-check the provided `<path>` for typos, incorrect relative/absolute paths, or ensure that the target files/directory are accessible from where the command is executed.
For ES modules, ensure your `package.json` includes `"type": "module"` or use `.mjs` file extensions. For CommonJS, use `require()` statements and `.cjs` file extensions if explicitly needed, or configure your bundler/runtime accordingly.