Skip to main content

Building Libraries

FrontHub provides full support in creating and maintaining npm packages for sharing code between applications.

Motivation

Although FrontHub provides a front-end architecture distributed across micro frontends, allowing for independence and reuse of parts of the product, those independent parts still need to reuse code in common.

The biggest example is the Design System, it's a good practice to create a component library with the brand's default styles. The more modular your product, the greater the need to share code, whether between microfrontends or even between different projects.

Fortunately, the JavaScript ecosystem already offers a simple and widely used way to do this through the npm (Node.js package manager).

We believe it is the best path, among all we have tried, for the following reasons:

  • It's the native and natural way to use external code, it's already the way you use third-party libraries, including FrontHub itself.
  • Each package is versioned, facilitating evolution and gradual adoption.
  • There are tools for notification and automatic update of each version, like Dependabot for example.
  • It is possible to vary between private and public packages, sharing Open Source code with the community.
  • There are several build, bundling and publishing tools available. This tool allows you to export a library in different formats to be used on different platforms and architectures.
  • You can share code with any Node.js project, whether you use FrontHub or not.

Objective

The objective is to standardize the library development and maintenance process, in addition to providing ready-made tools that guarantee the quality and productivity of the team.

Libraries are part of the FrontHub ecosystem, but they must be built to be self-contained, which solves a unique problem.