Skip to content
sigma.js sigma.js
v4.0.6 Docs Examples GitHub 12.2K

Creating new packages

From version 3, the source code of sigma.js is structured as a monorepo. We use Preconstruct to build the packages for development and production, and Lerna to manage versions lifecycle. Finally, on NPM, sigma is split into the core sigma package, and various @sigma/xxx feature packages.

This approach allows to maintain multiple features, that are too specialized to be included in the main repository, without the cost of creating and managing multiple Git/GitHub repositories.

As of now, the features are prefixed by their general purpose:

  • @sigma/node-xxx and @sigma/edge-xxx refer to node and edge renderers
  • @sigma/layer-xxx refers to additional layers that can be added to sigma instances
  • @sigma/layout-xxx refers to layout algorithms
  • @sigma/export-xxx refers to packages that allow exporting somehow a sigma instance
  • @sigma/utils stores various small specific helpers

To create a new package, you first need to get a clean local instance of sigma, with up-to-date versions of Git, Node.js and NPM. Then, go to the root of the repository, and run npm run createPackage. You will be prompted for the new package name (excluding the @sigma/ namespace), after which a fresh, empty package will be created and referenced wherever necessary.

Each package should have examples in the website’s packages/website/src/examples/ directory. These examples serve both as a development playground and as the public documentation showing what each package can do.

Unit tests sit next to the code as src/**/*.test.ts, and run with the package test script (vitest). The website examples are also covered by the end-to-end tests in packages/browser-tests.