-
Notifications
You must be signed in to change notification settings - Fork 823
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.json
to include a reference to the new package independencies
. -
Update
MODULE_KEY_TO_NAME_MAPPING
inpackages/workbox-sw/controllers/WorkboxSW.mjs
to include a mapping between theworkbox.*
namespace and the underlying package name. This mapping should match theworkbox.browserNamespace
metadata 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-build
knows 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.js
so that it's size is aggregated into the total size of the Workbox runtime.
-
Pre-publish a
v0.0.1
release tonpm
in 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 theworkboxjs
organization haveread-write
access for the new project:- Visit the WorkboxJS npm teams page.
- Grant access to the newly published package using the "+ Add Existing Package" button.