Skip to content

Latest commit

 

History

History
31 lines (23 loc) · 3.06 KB

File metadata and controls

31 lines (23 loc) · 3.06 KB

Adding new packages to the monorepo

Note

If you're migrating an existing package to the monorepo, please see the package migration documentation. You may be able to make use of create-package when migrating your package, but there's a lot more to it.

Manually creating a new monorepo package can be a tedious, even frustrating process. To alleviate that problem, we have created a CLI that automates most of the job for us, creatively titled create-package. To create a new monorepo package, follow these steps:

  1. Create a new package using yarn create-package.
    • You can specify the kind of package you want with the --type option. It defaults to snap:
      • --type snap creates a new Snap, whose bundle is built with mm-snap.
      • --type library (or the --type lib shorthand) creates a new non-Snap package, whose declarations are built with ts-bridge.
    • Use the --help flag for usage information.
    • Once this is done, you can find a package with your chosen name in /packages.
  2. Make sure your license is correct.
    • By default, create-package gives your package an MIT license.
    • If your desired license is not MIT, then you must update your LICENSE file and the license field of package.json.
  3. Update .github/CODEOWNERS to assign a team as the owner of the new package.
  4. Add your dependencies.
    • Do this as normal using yarn.

And that's it!

Contributing to create-package

Along with this documentation, create-package is intended to be the source of truth for the process of adding new packages to the monorepo. Consequently, to change that process, you will want to change create-package.

The create-package directory contains a template for each package type: Snaps and libraries. The CLI is not aware of the contents of the templates, only that their files have placeholder values. When a new package is created, the template files for the requested type are read from disk, the placeholder values are replaced with real ones, and the updated files are added to a new directory in /packages. To modify the templates: