Migrate new VueRouter() to createRouter()

Proprietary

Vue Router 4 is no longer a class. Rewrites new VueRouter({mode, base, routes}) to createRouter({history: createWebHistory(base), routes}), mapping mode 'history', 'hash' and 'abstract' to createWebHistory, createWebHashHistory and createMemoryHistory (no mode was the default 'hash') and passing base to it, and removes the Vue.use(VueRouter) call that Vue Router 4 replaces with app.use(router). Only a file that imports VueRouter with an ES import is rewritten, and a new VueRouter with options other than mode, base, routes, scrollBehavior, linkActiveClass, linkExactActiveClass, strict and sensitive is left as it is. The fallback option, which Vue Router 4 removed, is dropped. Other uses of VueRouter such as VueRouter.prototype.push are marked.

org.openrewrite.nodejs.migrate.vue.MigrateVueRouterConstructor
mod run . --recipe=org.openrewrite.nodejs.migrate.vue.MigrateVueRouterConstructor

Install it once, then run it on every repository under the current directory. New to the Moderne CLI? Set it up.