@openvue/migrate
v1.0.0
Published
Codemod that migrates a PrimeVue project to OpenVue by rewriting package names and import specifiers
Readme
@openvue/migrate
Codemod that migrates a PrimeVue project to OpenVue. OpenVue keeps PrimeVue's public API unchanged (usePrimeVue, PrimeVueResolver, the primevue Nuxt config key, p- CSS classes, pass-through options), so migrating is a package rename — which is exactly and only what this tool does.
Usage
One command, from the root of your project (for monorepos, run it at the workspace root):
npx @openvue/migrateRun in a terminal, it shows a plan — detected package manager, PrimeVue version, the files and references it will change, and your git status — then asks how to proceed:
- Full migration — rewrite files and run your package manager's install (detected from the lockfile) so the project builds immediately.
- Files only — rewrite files and dependencies but leave
node_modulesalone; you run the install yourself. - Dry run — show everything, write nothing.
Pass a mode flag (--mode, --dry, --no-install) or --yes to skip the prompt; any non-terminal run (CI, piped output) is non-interactive as well.
Already installed OpenVue yourself? If openvue is found in your package.json or node_modules, the tool switches to sources-only mode: dependencies and node_modules are left completely untouched, no install runs, and only source-file imports are rewritten.
| Option | Description |
| --------------- | -------------------------------------------------------- |
| [dir] | Directory to migrate (defaults to the current directory) |
| --mode <mode> | full, files-only, or dry; runs without prompting |
| --dry | Report what would change without writing any files |
| --no-install | Rewrite files but do not run the package manager install |
| --force | Do not stop on an uncommitted git working tree |
| --yes, -y | Skip prompts and use defaults (full migration) |
In interactive mode a dirty git tree only asks for confirmation. Non-interactively (a mode flag, --yes, or CI) it stops unless you pass --force, so the migration stays a single reviewable, revertible diff.
What it does
- Renames dependencies in every
package.json(monorepos supported):dependencies,devDependencies,peerDependencies,optionalDependencies,peerDependenciesMeta,resolutions,overridesandpnpm.overrides, including selector keys like**/primevueorprimevue@^4.workspace:/catalog:/npm:protocol values are preserved, andpnpm-workspace.yamlcatalogs are rewritten too. If bothprimevueandopenvueentries exist, yours wins and the leftover is removed. - Rewrites module specifiers in
.js,.mjs,.cjs,.ts,.mts,.cts,.jsx,.tsx,.vue,.astroand.mdxfiles — static imports,import type,require(), dynamicimport(), Nuxtmodulesarrays, ViteoptimizeDeps/transpileentries, and generatedcomponents.d.tsfiles. Subpath (primevue/button) and scoped (@primevue/*) specifiers are unambiguous and rewritten anywhere; a bare'primevue'string is only rewritten in import positions (or anywhere in*.config.*files), so runtime data likeprovider: 'primevue'is never touched. - Audits what's left: after rewriting, it scans sources, styles, HTML and tsconfig files for surviving PrimeVue references (interpolated
import(\primevue/${name}`), CSS@imports, CDN urls, tsconfigpaths`) and lists each one with file and line, so it never reports success while actionable references remain.
The rename mapping:
| From | To |
| ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -------------------------------------- |
| primevue, primevue/* | openvue, openvue/* |
| @primevue/core, @primevue/forms, @primevue/icons, @primevue/themes, @primevue/nuxt-module, @primevue/auto-import-resolver, @primevue/metadata, @primevue/mcp | same names under @openvue/* |
| @primeuix/themes, @primeuix/themes/* | @openvue/themes, @openvue/themes/* |
| @primeuix/* (engine: styled, utils, styles, forms, mcp) | same names under @openuxkit/* |
Left untouched on purpose: primeicons, primeflex, tailwindcss-primeui. The primevue Nuxt config key also stays, because OpenVue's Nuxt module kept it.
openvue and the @openvue/* packages are pinned to the exact version the codemod ships with, so a migration is reproducible. The @openuxkit/* engine packages get a caret range instead, because they version independently of OpenVue. Widen either range yourself afterwards if you prefer.
Try OpenVue without changing any code
If you just want to evaluate OpenVue first, add only the override yourself instead of running the codemod — no source changes needed:
// package.json — npm and bun; yarn uses "resolutions" instead of "overrides"
{
"overrides": {
"primevue": "npm:[email protected]"
}
}# pnpm-workspace.yaml — pnpm 10.5+. pnpm 11 no longer reads the `pnpm` field
# from package.json, so overrides belong here.
overrides:
primevue: 'npm:[email protected]'Once you decide to stay, run npx @openvue/migrate for the real rename.
Requirements
- Node.js 18+
- Your project must be on PrimeVue 4.x (the fork point). The tool detects the installed major (from
package.json, acatalog:/workspace:protocol,node_modules, or the lockfile) and stops without changing anything if it finds a non-4.x version. Coming from v3 or earlier, apply the PrimeVue v4 migration guide first, then run this tool.
