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

Docs: Include the strategy for setting engines for WordPress packages #67727

Merged
merged 1 commit into from
Dec 10, 2024
Merged
Changes from all commits
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
24 changes: 17 additions & 7 deletions packages/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,19 +25,25 @@ When creating a new package, you need to provide at least the following. Package
"bugs": {
"url": "https://github.com/WordPress/gutenberg/issues"
},
"engines": {
"node": ">=18.12.0",
"npm": ">=8.19.2"
},
"main": "build/index.js",
"module": "build-module/index.js",
"react-native": "src/index",
// Include this line to include the package as a WordPress script.
"wpScript": true,
// Include this line to include the package as a WordPress script module.
"wpScriptModuleExports": "./build-module/index.js",
"types": "build-types",
"sideEffects": false,
"dependencies": {
"@babel/runtime": "7.25.7"
},
"publishConfig": {
"access": "public"
},
// Include this line to include the package as a WordPress script.
"wpScript": true,
// Include this line to include the package as a WordPress script module.
"wpScriptModuleExports": "./build-module/index.js"
}
}
```

Expand Down Expand Up @@ -84,7 +90,7 @@ When creating a new package, you need to provide at least the following. Package
Initial release.
```

To ensure your package is recognized, you should also _manually_ add your new package to the root `package.json` file and then run `npm install` to update the dependencies.
To ensure your package is recognized in npm workspaces, you should run `npm install` to update the package lock file.

## Managing Dependencies

Expand Down Expand Up @@ -255,13 +261,17 @@ For consumers to use the published type declarations, we'll set the `types` fiel
```json
{
"main": "build/index.js",
"main-module": "build-module/index.js",
"module": "build-module/index.js",
"types": "build-types"
}
```
Ensure that the `build-types` directory will be included in the published package, for example if a `files` field is declared.
## Supported Node.js and npm versions
WordPress packages adhere the [Node.js Release Schedule](https://nodejs.org/en/about/previous-releases/). Consequently, the minimum required versions of Node.js and npm are specified using the `engines` field in `package.json` for all packages. This ensures that production applications run only on Active LTS or Maintenance LTS releases on Node.js. LTS release status is "long-term support", which typically guarantees that critical bugs will be fixed for a total of 30 months.
## 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
Loading