How to Seamlessly Migrate a Large Codebase to Vue 3

Rate this content
Bookmark

Migrating to Vue 3 can be an important task (depending on your project's size). At Crisp, we recently migrated our app (250K lines of code) from Vue 2.6 to Vue 3.2 in about 2 weeks.

In this talk, we will share our learnings so you can benefit from our experience. 

Baptiste Jamin
Baptiste Jamin
20 min
21 Oct, 2021

Comments

Sign in or register to post your comment.

Video Summary and Transcription

Hello, I am Baptiste from CRISP, and in this conference I'm going to show you how to migrate a large project from View 2 to View 3. Vue 3 migration is a simple process with many improvements, such as better performance and modularity. The migration strategy involves maintaining the existing Vue 2 app while gradually moving to Vue 3. Updating core libraries and replacing Vue 2 APIs with Vue 3 APIs are necessary steps. The impact of Vue 3's new reactivity system has optimized the codebase at CRISP, and the company is hiring full-stack developers and supporting the Vue.js Foundation.

1. Introduction to Vue 3 migration and its benefits

Short description:

Hello, I am Baptiste from CRISP, and in this conference I'm going to show you how to migrate a large project from View 2 to View 3. Recently, at CRISP we've been moving our messaging app from View 2.6 to View 3.2, and so far I can tell you that the migration process has been really smooth. Moving from Vue 2 to Vue 3 is a different situation than moving from Angular 1 to Angular 2. Vue.3 is a simple migration. It comes with many different improvements, such as better performance, modularity, and new API changes. However, there are some trade-offs, like dropping support for IE11 and duplicated APIs.

Hello, I am Baptiste from CRISP, and in this conference I'm going to show you how to migrate a large project from View 2 to View 3. Recently, at CRISP we've been moving our messaging app from View 2.6 to View 3.2, and so far I can tell you that the migration process has been really smooth. However, there are many mistakes that can be avoided when moving to View 3, and it's exactly what we are going to talk about in this conference.

So I'm the CEO of CRISP, and at CRISP we are doing a messaging app allowing companies to unify all their customer relationships using one app. So basically, it's a shared inbox allowing companies to unify messages from the live chat on the website, to emails, direct messages on Twitter or on WhatsApp messenger, and you can even reply to your GitHub issues right from CRISP. And all of that is made using Vue.js. We have around 300,000 companies using CRISP and at the end it's around 200 million people using CRISP every month. So it's been a big challenge for us moving from Vue 2 to Vue 3 because we wanted to avoid any impact for our customers.

Moving from Vue 2 to Vue 3 is a different situation than moving from Angular 1 to Angular 2. In fact, many developers, when Angular 2 was released, choose to use another framework such as Vue.js instead because the migration cost was too important. The learning curve to Angular 2 was too important. For this reason, if you look at the Google Trends, Vue.js went more and more popular and even replaced Angular.js. So moving to Vue.3 is not this kind of situation because Vue.3 is a simple migration. A reason for that is the Vue.compat package. The Vue.compat package allows you to use Vue.2 code along with Vue.3 codebase. Also Vue.3 allows you to use the same tooling. So you can use the same Vue.cli with the same webpack. Also, Vue.3 has a similar documentation. And finally you just don't need to relearn everything because Vue.3 is really similar to Vue.2. But Vue.3 comes with many different improvements. And the first is performances. Vue.3 comes with many improvements in terms of performances thanks to the new reactivity system. Also Vue.3 is more modular thanks to the composition API. And also there are many good API changes and one of them is the new vmodel system allowing you to have two vmodels for the same component. But obviously Vue.3 comes with some trade-offs. The main one is dropping IE11. But to be honest nowadays it's not a big deal. For instance for an app like Crisp, we had around 0.1% of companies using IE11. So it's not a big deal to drop IE11. Also some APIs have been duplicated such as the global vue API.

2. Vue 3 Migration Strategy and Steps

Short description:

In Vue 3, you don't need to use vue.set or vue.delete anymore, thanks to the new reactivity system. Filters have been duplicated, which was a challenge for us as we were used to using them in our Angular app. Our migration strategy involved maintaining the existing Vue 2 app while gradually moving to Vue 3, reducing the impact on customers. We created a dedicated branch for Vue 3 and merged the projects without conflicts. We kept the same tooling and avoided implementing the new composition API to minimize bugs. The next steps involve updating packages.json, vue configuration, and main.js file.

You won't be able to do vue.set or vue.delete. But in fact it's not a big deal. Because using vue 3 you don't need to do that anymore thanks to the new reactivity system. And also filters have been duplicated and for us it was important because as we came from the angular world we've been Crisp used to be an Angular app before and we've been using filters and we've been using filters a lot.

So it's been a challenge for us moving all our filters to a new Vue 3 compatible syntax. So let's talk about migration strategy. So we wanted to maintain our existing Vue 2 app while moving the codebase to Vue 3 and also we wanted to reduce the impact for customers. So once we released the Vue 3 version they don't notice anything and as we are a small team at Crisp we are only 4 developers we wanted to reduce the migration time.

So the strategy was to create a dedicated branch for Vue 3. So what we did is we used our existing master branch to deploy features and fixes on the existing production app. And at the end we have been able to port all the fixes from the master on the Vue 2 version to the Vue 3 version because Vue 2 and Vue 3 are really similar. So we've been able to merge the two projects without any conflicts. And also we wanted to use the same tooling so we keep Vue-CLI and we are not using Vids. Also we didn't implement the new composition API because we wanted to avoid risk of creating new bugs and regression. No composition API. We wanted to migrate only what is necessary. And likely we're going to use the composition API later but just not now.

So it's been 5 minutes I'm talking and now let's code. This is the crisp existing app using V2. The first step would be to update your packages.json so we can update vue to vue 3. So we're going to have to update vue 2 to vue 3 and also include the vue-compat package. Finally we're going to have to update vue-loader to the vue 16 version. So we're going to have to update the vue-cli services and it's very important. So we can do the next step. The next step would be to update the vue configuration. So we're going to have to update webpack for the vue-loader so we can enable the vue 3 and with the vue 2 compact. So we're going to resolve the vue-compat package instead of vue and it's very important to do that. Next step would be to open your main.js file and we're going to rework this file this way. So first you're going to have to import vue using a new way. So you're going to have to import create-app and configure-compat.

Check out more articles and videos

We constantly think of articles and videos that might spark Git people interest / skill us up or help building a stellar career

One Year Into Vue 3
Vue.js London Live 2021Vue.js London Live 2021
20 min
One Year Into Vue 3
Top Content
Vue 3 may still sound new to many users, but it's actually been released for over a year already. How did Vue 3 evolve during this period? Why did it take so long for the ecosystem to catch up? What did we learn from this process? What's coming next? We will discuss these questions in this talk!
Vue: Feature Updates
Vue.js London 2023Vue.js London 2023
44 min
Vue: Feature Updates
Top Content
The creator of Vue js gives an update on the new features of the technology.
Stop Writing Your Routes
Vue.js London 2023Vue.js London 2023
30 min
Stop Writing Your Routes
The more you keep working on an application, the more complicated its routing becomes, and the easier it is to make a mistake. ""Was the route named users or was it user?"", ""Did it have an id param or was it userId?"". If only TypeScript could tell you what are the possible names and params. If only you didn't have to write a single route anymore and let a plugin do it for you. In this talk we will go through what it took to bring automatically typed routes for Vue Router.
Nuxt on the Edge
Vue.js London 2023Vue.js London 2023
30 min
Nuxt on the Edge
Learn how to build a Vue application deployed to the edge to bring a blazing fast experience to your end users.
TresJS, a declarative way of creating 3D scenes from Vue components
Vue.js London 2023Vue.js London 2023
27 min
TresJS, a declarative way of creating 3D scenes from Vue components
Meet TresJS ▲ ■ ●, a declarative way of bringing the magic of ThreeJS using everyday Vue Components and composables. Think of it as React-three-fiber or Lunchbox but without the need of a custom renderer. It just works.Are you ready to add a new dimension to your Vue Apps?
10 Years of Vue: the Past and the Future
Vue.js Live 2024Vue.js Live 2024
29 min
10 Years of Vue: the Past and the Future
Vue was first publicly announced in 2014 and is 10 years old this year! In this talk, we will take a look back together at how it changed and evolved from its humble beginnings, discuss some of the challenges and learnings, and how we think about its future.

Workshops on related topic

Vue3: Modern Frontend App Development
Vue.js London Live 2021Vue.js London Live 2021
169 min
Vue3: Modern Frontend App Development
Top Content
Featured WorkshopFree
Mikhail Kuznetcov
Mikhail Kuznetcov
The Vue3 has been released in mid-2020. Besides many improvements and optimizations, the main feature of Vue3 brings is the Composition API – a new way to write and reuse reactive code. Let's learn more about how to use Composition API efficiently.

Besides core Vue3 features we'll explain examples of how to use popular libraries with Vue3.

Table of contents:
- Introduction to Vue3
- Composition API
- Core libraries
- Vue3 ecosystem

Prerequisites:
IDE of choice (Inellij or VSC) installed
Nodejs + NPM
Going on an adventure with Nuxt 3, Motion UI and Azure
JSNation 2022JSNation 2022
141 min
Going on an adventure with Nuxt 3, Motion UI and Azure
WorkshopFree
Melanie de Leeuw
Melanie de Leeuw
We love easily created and deployed web applications! So, let’s see what a very current tech stack like Nuxt 3, Motion UI and Azure Static Web Apps can do for us. It could very well be a golden trio in modern day web development. Or it could be a fire pit of bugs and errors. Either way it will be a learning adventure for us all. Nuxt 3 has been released just a few months ago, and we cannot wait any longer to explore its new features like its acceptance of Vue 3 and the Nitro Engine. We add a bit of pizzazz to our application with the Sass library Motion UI, because static design is out, and animations are in again.Our driving power of the stack will be Azure. Azure static web apps are new, close to production and a nifty and quick way for developers to deploy their websites. So of course, we must try this out.With some sprinkled Azure Functions on top, we will explore what web development in 2022 can do.
Building full-stack GraphQL applications with Hasura and Vue 3
Vue.js London Live 2021Vue.js London Live 2021
115 min
Building full-stack GraphQL applications with Hasura and Vue 3
WorkshopFree
Gavin Ray
Gavin Ray
The frontend ecosystem moves at a breakneck pace. This workshop is intended to equip participants with an understanding of the state of the Vue 3 + GraphQL ecosystem, exploring that ecosystem – hands on, and through the lens of full-stack application development.

Table of contents
- Participants will use Hasura to build out a realtime GraphQL API backed Postgres. Together we'll walk through consuming it from a frontend and making the front-end reactive, subscribed to data changes.
- Additionally, we will look at commonly-used tools in the Vue GraphQL stack (such as Apollo Client and Urql), discuss some lesser-known alternatives, and touch on problems frequently encountered when starting out.
- Multiple patterns for managing stateful data and their tradeoffs will be outlined during the workshop, and a basic implementation for each pattern discussed will be shown.
Workshop level

NOTE: No prior experience with GraphQL is necessary, but may be helpful to aid understanding. The fundamentals will be covered.