Uber has revamped their monolithic framework design with a brand new Fusion.js web framework. This plugin-based open source web framework makes it easy to develop lightweight and high-performing apps.
Why was Fusion.js required?
Uber has been in the app-development business for quite some time now. With the quickly changing web technologies, they wanted to build a high quality framework with modern features which also kept up with the dynamic nature of their web platform. Specifically, they wanted their new framework to address the following pain points:
- Complex configuration and required boilerplate of multiple tools needed for server-side rendering, code splitting, and hot module reloading
- Lack of good abstractions for implementing and sharing features that involve different aspects of server-rendered React applications
- Tight coupling of code located in different places
- Testing difficulties arising from side effects and singletons
- Lack of flexibility of a monolithic framework
Fusion.js addresses all of these problems.
What are the benefits of using Fusion.js?
On top of the benefits of a pre-configured, optimized boilerplate, Fusion.js also provides a flexible plugin-based architecture which makes it appropriate for building single-page applications and web apps that depend on complex service layers to meet quality requirements.
Fusion.js applications allow apps to have a single entry point file and it’s possible to reuse code on both the server and browser. The single entry point architecture allows plugin developers to co-locate snippets of code based on the library the code pertains to.
Plugins use dependency injection so they can expose well-defined APIs as services to other plugins, and a plugin’s dependencies can easily be mocked during tests.
For middleware management, Uber uses Koa, which provides a unit-test friendly context-based API. It has a lightweight abstraction for request lifetime management based on the concept of downstreams and upstreams.
Fusion.js provides testing tools for developers to test plugins in addition to supporting modern testing tools such as Jest, Enzyme, and Puppeter. The fusion-test-utils package allows mocking the server itself, making it possible to quickly run integration tests between plugins and mocks.
For now, over 60 repositories of Uber are using Fusion.js since its internal release. Next in the roadmap are the addition of more performance optimizations, test-oriented tooling, and better flow support.