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. 

This talk has been presented at Vue.js London Live 2021, check out the latest edition of this JavaScript Conference.

FAQ

Crisp used Trello to manage and track all migration tasks, ensuring they did not miss any bugs or library updates.

The migration to Vue 3 resulted in significant performance improvements, including reduced JavaScript heap usage, making the app faster and more responsive, especially for users with low-end computers.

Baptiste's conference focuses on migrating a large project from Vue 2 to Vue 3, specifically sharing the experience of migrating Crisp's messaging app from Vue 2.6 to Vue 3.2.

Crisp is a messaging app that allows companies to unify all their customer relationships using one app. It provides a shared inbox for messages from various platforms like live chat, email, Twitter, WhatsApp, and even GitHub.

Around 300,000 companies use Crisp, and it serves approximately 200 million people every month.

The Vue.compat package allows developers to use Vue 2 code alongside a Vue 3 codebase, making the migration from Vue 2 to Vue 3 simpler and smoother.

Vue 3 offers performance enhancements due to a new reactivity system, increased modularity with the Composition API, and various API changes, including a new vmodel system that allows for two vmodels for the same component.

The main trade-off of migrating to Vue 3 is dropping support for IE11. Additionally, some APIs like vue.set and vue.delete have been deprecated, and VIF with V4 is no longer supported.

Crisp's migration strategy involved creating a dedicated branch for Vue 3 while maintaining their existing Vue 2 app. They used the same tooling, avoided implementing the new Composition API initially, and aimed to reduce the migration time and impact on customers.

Crisp updated and, in some cases, forked third-party libraries to ensure compatibility with Vue 3. They focused on replacing the Vue Global API and constructor for these libraries.

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.