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 Tech 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.

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 has seen significant adoption and improvements in performance, bundle size, architecture, and TypeScript integration. The ecosystem around Vue 3 is catching up, with new tools and frameworks being developed. The Vue.js.org documentation is undergoing a complete overhaul. PNIA is emerging as the go-to state management solution for Vue 3. The options API and composition API are both viable options in Vue 3, with the choice depending on factors such as complexity and familiarity with TypeScript. Vue 3 continues to support CDN installation and is recommended for new projects.
Vue: Feature Updates
Vue.js London 2023Vue.js London 2023
44 min
Vue: Feature Updates
Top Content
The Talk discusses the recent feature updates in Vue 3.3, focusing on script setup and TypeScript support. It covers improvements in defining props using imported types and complex types support. The introduction of generic components and reworked signatures for defined components provides more flexibility and better type support. Other features include automatic inference of runtime props, improved define emits and defined slots, and experimental features like reactive props destructure and define model. The Talk also mentions future plans for Vue, including stabilizing suspense and enhancing computer invalidations.
Stop Writing Your Routes
Vue.js London 2023Vue.js London 2023
30 min
Stop Writing Your Routes
Designing APIs is a challenge, and it's important to consider the language used and different versions of the API. API ergonomics focus on ease of use and trade-offs. Routing is a misunderstood aspect of API design, and file-based routing can simplify it. Unplugging View Router provides typed routes and eliminates the need to pass routes when creating the router. Data loading and handling can be improved with data loaders and predictable routes. Handling protected routes and index and ID files are also discussed.
Nuxt on the Edge
Vue.js London 2023Vue.js London 2023
30 min
Nuxt on the Edge
Nuxt is a web framework with many features including server-side rendering, client-side rendering, static site generation, edge site rendering, and more. The Edge is a limited environment running on CDN nodes, such as Cloudflare network. Database options on the Edge include Postgre with Neon, Versel on Neon, Superbase, MySQL with plan scale, HyperDB, and KV with redis and Cloudflare storage. The speaker demonstrates creating a demo with a votes table, handling API requests, adding authentication, saving votes, and displaying results. The roadmap to a full stack Nuxt 3 with an edge-first experience is in progress. Copilot is a helpful tool for developers. Integrating SSO with GitHub and improving the developer experience are important considerations for Nuxt 3.
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
The speaker discovered 3D with 3GS and was inspired to create a 3D ecosystem for the Vue community using Troy.js. The process of setting up a 3D scene and objects in Tress was explained, along with creating and configuring 3D objects. The talk also covered animating objects with Tress and the 'Cientos' package, as well as the future of Tress.js and its compatibility with older versions of Three. The speaker expressed gratitude to sponsors and contributors and highlighted the potential for product customization with Tress.js.
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
Hello everyone and welcome to Vue.js Live 2024. In this Talk, Evan Yew, the creator of Vue and Vite, shares a 10-year retrospective on Vue.js, discussing its history, technical impact, and how it is being kept alive. Vue has made significant contributions to the JavaScript ecosystem and is the only mainstream framework that remains independent. The latest release, Vue 3.4, introduced performance improvements and a more efficient reactivity system. Future plans include reactivity efficiency improvements, stabilizing reactive props, and exploring vapor mode. Vue is here to stay and will continue to support the community.

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.