Paste Vue 2. Get Vue 3.

vueleap rewrites what is safe to rewrite and points at the rest, line by line, with the official guide for each change. Try it here, then run it on your whole project.

2 3
Try an example

Edit the code to run vueleap in your browser.

PriceTag.vueVue 2
PriceTag.vueVue 3
<template>
  <div class="price-tag" v-on="$listeners">
    <p>{{ price | currency }}</p>
    <currency-picker v-model:code="code" />
    <input
      v-model="price"
      @keyup.enter="save"
      @keydown.esc="cancel"
    >
  </div>
</template>

<script>
import EventBus from './event-bus'

export default {
  props: ['price'],
  filters: {
    currency: (value) => '$' + value.toFixed(2),
  },
  mounted() {
    EventBus.$on('reset', this.cancel)
  },
  beforeUnmount() {
    EventBus.$off('reset', this.cancel)
  },
}
</script>
 
4 rewritten 5 left for you 4 compat flags

4 changes rewritten for you

  • sync-modifierline 4.sync is removed: use v-model:code="code" instead.
  • keycode-modifiersline 7KeyCode modifier .13 is removed: use .enter.
  • keycode-modifiersline 8KeyCode modifier .27 is removed: use .esc.
  • destroy-hooksline 24beforeDestroy is renamed to beforeUnmount and is ignored by Vue 3.

5 changes left for you

  • Guide$listeners is removed: listeners are now included in $attrs.
  • GuideFilter "currency" used in a template expression. Call a method or use a computed property instead.
  • GuideLocal filter "currency" is removed: turn it into a method or a computed property.
  • Guide$on is removed: instances are no longer event emitters (use props and emits, provide/inject, a store, or mitt).
  • Guide$off is removed: instances are no longer event emitters (use props and emits, provide/inject, a store, or mitt).

Until those are done, @vue/compat keeps this file running withFILTERSINSTANCE_EVENT_EMITTERINSTANCE_LISTENERSCOMPILER_FILTERS

Now run it on the whole project

One command, no config, nothing uploaded. It reads .vue, script and style files plus package.json.

# run it once, nothing to install
npx vueleap

# or add it to the project
npm install --save-dev vueleap

The migration journey

Five stops from lily pad 2 to lily pad 3

The app keeps running at every stop. Scroll along with Hop.

Stop 1: Scan

Scan the whole project

One command reads templates, scripts, styles and package.json, and groups what breaks by rule, with the file, the line and the official guide. It skips node_modules, dist and anything in .gitignore.

  • Only reads files. Nothing runs, nothing is uploaded.
  • SFCs, JSX and TSX, TypeScript, script setup and class components.
Terminalbash: shop-front
~/shop-front $ npx vueleapvueleap v1.1.0  Vue 2 to Vue 3 migration reporterror  filters  Filters are removed (6)       https://v3-migration.vuejs.org/breaking-changes/filters       compat: COMPILER_FILTERS, FILTERS  src/components/ProductList.vue:5:25  Filter "capitalize" used in a template expression. Call a method or use a computed property instead.  src/components/ProductList.vue:5:64  Filter "currency" used in a template expression. Call a method or use a computed property instead.  src/components/ProductList.vue:6:69  Filter "capitalize" used in a template expression. Call a method or use a computed property instead.  src/components/ProductList.vue:30:5  Local filter "capitalize" is removed: turn it into a method or a computed property.  src/legacy/inline.js:7:55            Filter "number" used in a template expression. Call a method or use a computed property instead.  src/main.js:26:1                     Vue.filter is removed: expose a helper through app.config.globalProperties or import a function.error  destroy-hooks  beforeDestroy and destroyed are renamed (3)  [3 fixable]       https://v3-migration.vuejs.org/breaking-changes/#other-minor-changes       compat: OPTIONS_BEFORE_DESTROY, OPTIONS_DESTROYED  src/components/Modal.vue:27:3        destroyed is renamed to unmounted and is ignored by Vue 3.  src/components/ProductList.vue:50:3  beforeDestroy is renamed to beforeUnmount and is ignored by Vue 3.  src/mixins/tracking.js:5:3           beforeDestroy is renamed to beforeUnmount and is ignored by Vue 3.error  keycode-modifiers  KeyCode modifiers are removed (3)  [2 fixable]       https://v3-migration.vuejs.org/breaking-changes/keycode-modifiers       compat: V_ON_KEYCODE_MODIFIER  src/components/TheHeader.vue:5:55  KeyCode modifier .13 is removed: use .enter.  src/components/TheHeader.vue:5:74  KeyCode modifier .27 is removed: use .esc.  src/components/TheHeader.vue:5:99  KeyCode modifier .112 is removed: use the kebab-case key name instead.  ... 36 more rule groups in the full reportSummary  Files scanned     21  Files affected    19  Findings          75  (55 errors, 17 warnings, 3 info)  Auto fixable      18  (preview with --fix, apply with --fix --write)  Effort score      59  (large)~/shop-front $ 

Stop 2: Understand

Know how big the job is

This is a small Vue 2 shop: 75 findings in 19 files, with an effort score of 59 (large). Share the same report with your team.

Terminalbash
npx vueleap --html report.html
shop-front21 files scanned
Findings
75
Errors
55
Warnings
17
Auto fixable
18
  • global-api8
  • filters6
  • set-delete5
  • directive-hooks4
  • destroy-hooks3
  • keycode-modifiers3

Open the full sample report

Stop 3: Fix

Let the safe changes write themselves

Renames are rewritten in place and your formatting stays. --fix prints a diff first and writes nothing until you add --write. On the sample app it fixes 18 findings in 9 files.

Terminalbash
npx vueleap --fix           # preview
npx vueleap --fix --write   # apply
Terminalnpx vueleap --fix
--- a/src/components/ProductList.vue
+++ b/src/components/ProductList.vue
@@ -4,5 +4,5 @@
       <li v-for="product in products" v-if="product.visible" :key="product.id">
         {{ product.name | capitalize }} costs {{ product.price | currency('EUR') }}
-        <product-card :product.sync="selected" :title="product.name | capitalize" />
+        <product-card v-model:product="selected" :title="product.name | capitalize" />
       </li>
     </ul>
@@ -48,5 +48,5 @@
     this.$once('hook:beforeDestroy', () => clearInterval(this.timer))
   },
-  beforeDestroy() {
+  beforeUnmount() {
     EventBus.$off('cart:add', this.onAdd)
   },

--- a/src/directives/tooltip.js
+++ b/src/directives/tooltip.js
@@ -1,10 +1,10 @@
 export default {
-  bind(el, binding) {
+  beforeMount(el, binding) {
     el.setAttribute('title', binding.value)
   },
-  componentUpdated(el, binding) {
+  updated(el, binding) {
     el.setAttribute('title', binding.value)
   },
-  unbind(el) {
+  unmounted(el) {
     el.removeAttribute('title')
   },

Stop 4: Compat

Boot on Vue 3 before the last fix

The @vue/compat migration build runs Vue 2 style code on Vue 3, one flag per feature. vueleap prints the smallest config your code needs, everything else in Vue 3 mode. Read how the flags work.

36flags for the sample app today29 runtime, 7 compiler

COMPONENT_FUNCTIONALCOMPONENT_V_MODELCONFIG_DEVTOOLSCONFIG_IGNORED_ELEMENTSCONFIG_KEY_CODESCONFIG_PRODUCTION_TIPCUSTOM_DIRFILTERSGLOBAL_DELETEGLOBAL_MOUNTGLOBAL_PROTOTYPEGLOBAL_SETINSTANCE_ATTRS_CLASS_STYLEINSTANCE_CHILDRENINSTANCE_DELETEINSTANCE_DESTROYINSTANCE_EVENT_EMITTERINSTANCE_EVENT_HOOKSINSTANCE_LISTENERSINSTANCE_SCOPED_SLOTSINSTANCE_SETOPTIONS_BEFORE_DESTROYOPTIONS_DATA_FNOPTIONS_DESTROYEDRENDER_FUNCTIONTRANSITION_CLASSESTRANSITION_GROUP_ROOTV_ON_KEYCODE_MODIFIERWATCH_ARRAYCOMPILER_FILTERSCOMPILER_INLINE_TEMPLATECOMPILER_IS_ON_ELEMENTCOMPILER_V_BIND_OBJECT_ORDERCOMPILER_V_BIND_SYNCCOMPILER_V_IF_V_FOR_PRECEDENCECOMPILER_V_ON_NATIVE

The goal is zero. Rerun after each fix and delete the flags that disappear.

main.js
// Generated by npx vueleap --compat for the sample app.
import { configureCompat } from 'vue'

configureCompat({
  MODE: 3,
  COMPONENT_FUNCTIONAL: true,
  COMPONENT_V_MODEL: true,
  CONFIG_DEVTOOLS: true,
  CONFIG_IGNORED_ELEMENTS: true,
  CONFIG_KEY_CODES: true,
  CONFIG_PRODUCTION_TIP: true,
  CUSTOM_DIR: true,
  FILTERS: true,
  GLOBAL_DELETE: true,
  GLOBAL_MOUNT: true,
  GLOBAL_PROTOTYPE: true,
  GLOBAL_SET: true,
  INSTANCE_ATTRS_CLASS_STYLE: true,
  INSTANCE_CHILDREN: true,
  INSTANCE_DELETE: true,
  INSTANCE_DESTROY: true,
  INSTANCE_EVENT_EMITTER: true,
  INSTANCE_EVENT_HOOKS: true,
  INSTANCE_LISTENERS: true,
  INSTANCE_SCOPED_SLOTS: true,
  INSTANCE_SET: true,
  OPTIONS_BEFORE_DESTROY: true,
  OPTIONS_DATA_FN: true,
  OPTIONS_DESTROYED: true,
  RENDER_FUNCTION: true,
  TRANSITION_CLASSES: true,
  TRANSITION_GROUP_ROOT: true,
  V_ON_KEYCODE_MODIFIER: true,
  WATCH_ARRAY: true,
})

Stop 5: Ship

Land on Vue 3 and stay there

Tick the tasks as your team goes; the list is saved in this browser. When the last flag is gone, gate CI so Vue 2 only code never comes back.

vue3.yml
# .github/workflows/vue3.yml
name: Vue 3 guard
on: [push, pull_request]
jobs:
  vueleap:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
      - run: npx vueleap --fail-on error
0of 12 tasks done
0 of 12
Stop 1Scan
Stop 2Understand
Stop 3Fix
Stop 4Compat
Stop 5Ship

Saved in this browser only. Nothing is sent anywhere.

Questions

Before the leap

Something else? Open an issue on GitHub.

Is it safe to run on my code?

Yes. By default vueleap only reads files. --fix prints a diff and writes nothing unless you add --write, and it never touches files outside the project folder. The demo on this page runs in your browser and sends nothing anywhere.

What does it rewrite, and what does it leave to me?

Pure renames are rewritten: lifecycle and directive hooks, keyCode modifiers, .sync, $scopedSlots, transition classes, @hook: events and productionTip. Everything else gets a finding with the line, an explanation and the official guide. That is 8 of the 41 checks.

Does it support TypeScript, script setup and class components?

Yes. Single file components with lang="ts", TSX, Vue 2.7 <script setup> and vue-property-decorator class components are analyzed. Pug templates are skipped with a warning.

Can I use it from code?

Yes. analyze(dir) and fix(dir) work on a project, and analyzeSource(code) and fixSource(code) work on one file in memory, in Node or in the browser.