Package Development

Learn about creating and maintaining internal (frontend) packages at NOBEARS.

Welcome to the package development guide for NOBEARS frontend packages. This documentation covers our standardized approach to developing, maintaining, and releasing frontend packages.

Overview

At NOBEARS, we maintain several types of packages:

  • UI Components: Design systems and reusable interface elements (@nobears-front-end/nuxt-ui)
  • Framework Integrations: Modules for Nuxt, Statamic, etc. (@nobears-front-end/nuxt-statamic)
  • Utility Libraries: Shared functions and tools

What You'll Learn

This guide will walk you through:

  • Creating new packages using our starter templates
  • Following our code standards and naming conventions
  • Managing package versions and releases
  • Writing and maintaining documentation
  • Ensuring code quality through testing

Whether you're building a new package or maintaining an existing one, this guide ensures you follow our best practices and workflows.


Package Types

Before we get started, let's take a look at the different types of packages we maintain.

  1. Layers
    Layers are specificly used in Nuxt projects, they are used to add extendable and overrideable code to your project. @nobears-front-end/nuxt-ui is a great example of this.
  2. Modules
    Modules are used to add framework or tool specific code to your project, e.g. @nobears-front-end/nuxt-statamic is a module for the Statamic CMS integration.
  3. Packages
    Packages are the simplest type of package, they are used to simple and extendable code that is not framework or tool specific. A ESlint config is a great example of this.
  4. Templates
    In order to keep it easy for developers to get started, we have created a set of starter templates. We have templates for starting a new package, a new project and more.

Creating a new package

Before you start creating a new package, you should first check with other developers if the package is not already created or if it's not already in the process of being created. If you can't find a package that fits your needs, you can create a new one (if you have permission to do so of course).

We use a Jira board to keep track of all the packages we maintain, if you need to create a new package, please create a new ticket in Jira in order to get the process started. From there you should start by describing the package you want to create, what it will be used for and what it will contain.

Once you have the green light from the team, you can start by creating a new package.

Naming Convention

  • Format: @nobears-front-end/<tech-stack>-<package-name>
  • Examples:
    • @nobears-front-end/nuxt-ui
    • @nobears-front-end/nuxt-statamic
    • @nobears-front-end/statamic-template

If we take a look at the nuxt-statamic package, you'll notice that it has 2 frameworks/ tech stacks in the name. This is because it's a package that is used to integrate Statamic with Nuxt, in these cases it's best to use the naming convention <tech-stack-of-the-project>-<tool-or-integration-name>.

Versioning

When using one of our starter templates, the versioning will be handled automatically by the release-it configuration.

Required Files

  • package.json: Package configuration
  • README.md: Package documentation
  • CHANGELOG.md: Version history
  • tsconfig.json: TypeScript configuration
  • types/: TypeScript types (we prefer to use .ts files instead of .d.ts files)
  • test/: Test files (if applicable)

Documentation

In our module starter template, we have a pre-configured documentation setup.

Adding documentation to your package is done by adding a docs folder to the root of your package.

This folder will be read by our frontend doc, thus automatically adding your package to the general documentation site.

  • Place documentation in docs/ directory
  • Include:
    • Getting started guide
    • API reference
    • Examples

(Git) workflow

If you want to get started with working on a new feature, the first thing you should do is create a new ticket in the Jira board. Before you start working on a new feature, it must first be approved by the team. When you have the green light, you can start by creating a new branch.

Branches

If you are working on a Jira ticket, you should create a new branch based on the preview branch, using the following naming convention: story/FE-{ticket-id}.

Commits

In order to correctly manage the changelog, we have a set of commitlint rules that are used to ensure the commit messages are correct for the changelog.

Creating a commit

To create a commit, use the following command:

pnpm commit

Or you can use the following command to commit all changes:

pnpm commit:all

This will open a prompt to help you write a commit message that adhears to the commitlint rules.

Commit types

A breaking change
A new feature
A bug fix
A security fix
General improvements to the codebase
A code change that improves performance

The following commit types will not be automatically added to the changelog in order to keep the changelog clean and readable:

A code change that neither fixes a bug nor adds a feature
Documentation only changes
Other changes that don't modify src or test files
Adding missing tests or correcting existing tests
Changes that do not affect the meaning of the code (white-space, formatting, etc)
Changes that affect the build system or external dependencies (example scopes: gulp, broccoli, npm)
Changes to the CI configuration
Work in progress

Releasing a package

We follow a structured release process to ensure quality and stability across both beta and stable releases. Specifically, we use release-it to release new versions of our packages.

It is a requirement that you use the correct commit message syntax. If you skip this step, we can't properly update the changelog.

You can use the pnpm commit command to create a commit with the correct commit message syntax.

Releasing a beta version

You will most likely never be in a situation where you need to release a beta version, since small changes are mostly released as a patch version.

Skip to 'releasing a stable version' if you don't need to release a beta version.

But since there are some cases where it is needed, we have the following process for it:

Create a new feature branch

The branch must be created from the preview branch.
In order to keep better track of the lifecycle/ back-log of a package, it is recommended to first create a ticket in the Jira board.

Creating a new branch is done by using the following naming convention: story/FE-{ticket-id}.

Be sure to create the new branch from the preview branch.

Create a commit with the correct commit message syntax

pnpm commit

For more information on how to write a commit, please refer to the commit syntax section.

Create a MR

Share the MR with the team for review. Be sure to include a short description, MR link and link to the Jira ticket if you have one.

Sharing MRs is done in the front-end-packages slack channel.

Merge to preview

Release the beta version

pnpm release-beta

This process will create a new beta version of the package and update the CHANGELOG.md file.

Releasing a stable version

Create a new merge request

Create a new merge request for merging the preview branch into the main branch. After which you can share the MR with the team for review. Be sure to include a short description, MR link and link to the Jira ticket if you have one.

Sharing MRs is done in the front-end-packages slack channel.

Merge to main

Release the stable version

pnpm release

This process will create a new stable version of the package and update the CHANGELOG.md file.