Skip to content

Commit

Permalink
Docs: Add section about adding new dependencies to WordPress packages (
Browse files Browse the repository at this point in the history
…#16876)

* Docs: Add section about adding new dependencies to WordPress packages

* Apply suggestions from code review

Co-Authored-By: Chris Van Patten <chris@vanpattenmedia.com>
  • Loading branch information
gziolo and chrisvanpatten committed Aug 29, 2019
1 parent 747169c commit 036f8e4
Showing 1 changed file with 29 additions and 1 deletion.
30 changes: 29 additions & 1 deletion packages/README.md
@@ -1,6 +1,6 @@
## Managing Packages

This repository uses [lerna] to manage Gutenberg modules and publish them as packages to [npm].
This repository uses [lerna] to manage WordPress modules and publish them as packages to [npm].

### Creating a New Package

Expand Down Expand Up @@ -48,6 +48,34 @@ When creating a new package, you need to provide at least the following:
- Usage example
- `Code is Poetry` logo (`<br/><br/><p align="center"><img src="https://s.w.org/style/images/codeispoetry.png?1" alt="Code is Poetry." /></p>`)

### Adding New Dependencies

There are two types of dependencies that you might want to add to one of the existing WordPress packages.

#### Production Dependencies

Production dependencies are stored in the `dependencies` section of the package’s `package.json` file. The simplest way to add such a dependency to one of the packages is to run a very convenient [lerna add](https://github.com/lerna/lerna/tree/master/commands/add#readme) command from the root of the project.

_Example:_

```bash
lerna add lodash packages/a11y
```

This command adds the latest version of `lodash` as a dependency to the `@wordpress/a11y` package, which is located in `packages/a11y` folder.

#### Development Dependencies

In contrast to production dependencies, development dependencies shouldn't be stored in individual WordPress packages. Instead they should be installed in the project's `package.json` file using the usual `npm install` command. In effect, all development tools are configured to work with every package at the same time to ensure they share the same characteristics and integrate correctly with each other.

_Example:_

```bash
npm install glob --save-dev
```

This commands adds the latest version of `glob` as a development dependency to the `package.json` file. It has to be executed from the root of the project.

### Maintaining Changelogs

In maintaining dozens of npm packages, it can be tough to keep track of changes. To simplify the release process, each package includes a `CHANGELOG.md` file which details all published releases and the unreleased ("Master") changes, if any exist.
Expand Down

0 comments on commit 036f8e4

Please sign in to comment.