Vue plugin-based development

ManiKanta Koppala
Vue.js Developers
Published in
3 min readFeb 9, 2020

Instead of starting with what we did and how we did, let me start with why.

Why we did this

Earlier we used to build front-end applications in a monolithic way, where everything is tightly couple for that particular application
Which is good, gave us a proper scope of individual application. Then we started to scale up things to multiple countries and various applications. Each country have a different configuration like different mobile validation, different rules, and sometimes different requirements
We thought not to handle different repositories for different countries since there be a lot of code duplication. So we decided to go with configuration based where we inject a config file specific to the country when that particular country is loading. Which have all the generic things required for that country?
This solution is right but going on we faced a few critical issues in development process like,

  1. If else ladder — we ended up have a lot of if-else conditions in the code
  2. Testing — whenever a particular country do some changes, then every country has to test it (Since it’s a single code base)
  3. Code commits — Many conflicts used to happen since many developers are working for different countries.
  4. Complete module in a different application — Some times we want a module from application A into application B (Which we used iframes)

So we thought to scale up this solution which can solve at least a few problems. During that process, we came up with this plugin-based architecture, where we learned many things along the way.

How we did

Let’s take an application (monolithic) which has modules like users, notifications, settings, newsfeed, and some business logic around them.

Monolithic application structure

To make any changes to business logic, we have to break through the modules and make the changes and stick it back with a lot of if-else conditions. So we broke every module into an individual application so that any other application can consume it.

Plugin application structure

(core is something which controls all the plugins)
Now we can work on each module separately and publish them as an individual package. Any Vue application can consume them when required.

Ideally, this is what we are talking

  1. vue create demo-app
  2. npm i @myapp/users @myapp/notifications @myapp/settings @myapp/core -save
  3. init the core module
  4. Add some configurations

That’s is all the modules injected into the application and ready to serve in the browser. It looks great and beautiful, but how to do it?
So before reaching that level, we need to understand a few problems we solved along the way. Combining all those solutions, we can get the answer to our question.

  1. Handling multiple repositories (or monorepos)
  2. Building a pluggable module
  3. Injecting plugins
  4. 3 main layers of front-end development
  5. Grand finale

--

--