Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use npm workspaces for packages #65681

Merged
merged 18 commits into from
Oct 21, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
Update package managing flow
  • Loading branch information
t-hamano authored and sirreal committed Oct 21, 2024
commit c48fcbe046308fb136d8e09e573fca5b7be348c6
5 changes: 4 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -387,5 +387,8 @@
"**/tsconfig.json": [
"npm run lint:tsconfig"
]
}
},
"workspaces": [
"packages/*"
]
}
10 changes: 3 additions & 7 deletions packages/README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Managing Packages

This repository uses [monorepo] to manage WordPress modules and publish them with [lerna] as packages to [npm].
This repository uses [monorepo](https://monorepo.tools) to manage WordPress modules and publish them with [lerna](https://lerna.js.org/) as packages to [npm](https://www.npmjs.com/).

## Creating a New Package

Expand Down Expand Up @@ -70,12 +70,12 @@ Production dependencies are stored in the `dependencies` section of the package

#### Adding New Dependencies

The simplest way to add a production dependency to one of the packages is to run a very convenient [lerna add](https://github.com/lerna/lerna/tree/HEAD/commands/add#readme) command from the root of the project.
The simplest way to add a production dependency to one of the packages is to run a command like the following from the root of the project.

_Example:_

```bash
lerna add change-case packages/a11y
npm install change-case -w packages/a11y
```

This command adds the latest version of `change-case` as a dependency to the `@wordpress/a11y` package, which is located in `packages/a11y` folder.
Expand Down Expand Up @@ -239,10 +239,6 @@ For consumers to use the published type declarations, we'll set the `types` fiel

Ensure that the `build-types` directory will be included in the published package, for example if a `files` field is declared.

[lerna]: https://lerna.js.org/
[monorepo]: https://monorepo.tools
[npm]: https://www.npmjs.com/

## Optimizing for bundlers

In order for bundlers to tree-shake packages effectively, they often need to know whether a package includes side effects in its code. This is done through the `sideEffects` field in the package's `package.json`.
Expand Down