-
Notifications
You must be signed in to change notification settings - Fork 865
Adding a new package
The following are the steps that need to be taken in order to create a brand-new package as part of the Workbox monorepo. Note that some of the steps assume that you're creating a package that runs in the service worker and can be loaded by workbox-sw; if you're creating a node-based build tool, or a package that runs in the window context, you'll only need to follow a subset of these.
Many pieces of the build and test infrastructure will automatically pick up new packages without you having to explicitly enable anything, by virtue of a wildcard match for anything under the packages/ directory.
-
Update
packages/workbox-build/package.jsonto include a reference to the new package independencies. -
Update
MODULE_KEY_TO_NAME_MAPPINGinpackages/workbox-sw/controllers/WorkboxSW.mjsto include a mapping between theworkbox.*namespace and the underlying package name. This mapping should match theworkbox.browserNamespacemetadata found in the new package'spackage.json, e.g.:
"workbox": {
"browserNamespace": "workbox.somethingNew",
"packageType": "browser"
}-
Update various tests that check the number/names of the packages that
workbox-buildknows about to account for the new packages' files: -
If this is a package that you expect most developers will use, then include it in
infra/pr-bot/aggregate-size-plugin.jsso that it's size is aggregated into the total size of the Workbox runtime.
-
Pre-publish a
v0.0.1release tonpmin order to claim the package name, prior to committing code to GitHub! This will prevent malicious folks from grabbing our new package name before we get a chance to cut an official Workbox release. -
After publishing to
npm, ensure that other members of theworkboxjsorganization haveread-writeaccess for the new project:- Visit the WorkboxJS npm teams page.
- Grant access to the newly published package using the "+ Add Existing Package" button.