Updates the plugin template and adds it to the monorepo
Includes:
* Integration testing setup
* Adding custom client / server components via a plugin
* The same building setup that we use for our plugins in the monorepo
* `create-payload-app` dynamically configures the project based on the
name:`dev/tsconfig.json`, `src/index.ts`, `dev/payload.config.ts`
For example, from project name: `payload-plugin-cool`
`src/index.ts`:
```ts
export type PayloadPluginCoolConfig = {
/**
* List of collections to add a custom field
*/
collections?: Partial<Record<CollectionSlug, true>>
disabled?: boolean
}
export const payloadPluginCool =
(pluginOptions: PayloadPluginCoolConfig) =>
/// ...
```
`dev/tsconfig.json`:
```json
{
"extends": "../tsconfig.json",
"exclude": [],
"include": [
"**/*.ts",
"**/*.tsx",
"../src/**/*.ts",
"../src/**/*.tsx",
"next.config.mjs",
".next/types/**/*.ts"
],
"compilerOptions": {
"baseUrl": "./",
"paths": {
"@payload-config": [
"./payload.config.ts"
],
"payload-plugin-cool": [
"../src/index.ts"
],
"payload-plugin-cool/client": [
"../src/exports/client.ts"
],
"payload-plugin-cool/rsc": [
"../src/exports/rsc.ts"
]
},
"noEmit": true
}
}
```
`./dev/payload.config.ts`
```
import { payloadPluginCool } from 'payload-plugin-cool'
///
plugins: [
payloadPluginCool({
collections: {
posts: true,
},
}),
],
```
Example of published plugin
https://www.npmjs.com/package/payload-plugin-cool
86 lines
2.6 KiB
JSON
86 lines
2.6 KiB
JSON
{
|
|
"name": "plugin-package-name-placeholder",
|
|
"version": "1.0.0",
|
|
"description": "A blank template to get started with Payload 3.0",
|
|
"license": "MIT",
|
|
"type": "module",
|
|
"exports": {
|
|
".": {
|
|
"import": "./dist/index.js",
|
|
"types": "./dist/index.d.ts",
|
|
"default": "./dist/index.js"
|
|
},
|
|
"./client": {
|
|
"import": "./dist/exports/client.js",
|
|
"types": "./dist/exports/client.d.ts",
|
|
"default": "./dist/exports/client.js"
|
|
},
|
|
"./rsc": {
|
|
"import": "./dist/exports/rsc.js",
|
|
"types": "./dist/exports/rsc.d.ts",
|
|
"default": "./dist/exports/rsc.js"
|
|
}
|
|
},
|
|
"main": "./dist/index.js",
|
|
"types": "./dist/index.d.ts",
|
|
"files": [
|
|
"dist"
|
|
],
|
|
"scripts": {
|
|
"build": "pnpm copyfiles && pnpm build:types && pnpm build:swc",
|
|
"build:swc": "swc ./src -d ./dist --config-file .swcrc --strip-leading-paths",
|
|
"build:types": "tsc --outDir dist --rootDir ./src",
|
|
"clean": "rimraf {dist,*.tsbuildinfo}",
|
|
"copyfiles": "copyfiles -u 1 \"src/**/*.{html,css,scss,ttf,woff,woff2,eot,svg,jpg,png,json}\" dist/",
|
|
"dev": "payload run ./dev/server.ts",
|
|
"dev:generate-importmap": "pnpm dev:payload generate:importmap",
|
|
"dev:generate-types": "pnpm dev:payload generate:types",
|
|
"dev:payload": "PAYLOAD_CONFIG_PATH=./dev/payload.config.ts payload",
|
|
"lint": "eslint ./src",
|
|
"lint:fix": "eslint ./src --fix",
|
|
"prepublishOnly": "pnpm clean && pnpm turbo build",
|
|
"test": "jest"
|
|
},
|
|
"devDependencies": {
|
|
"@eslint/eslintrc": "^3.2.0",
|
|
"@payloadcms/db-mongodb": "3.11.0",
|
|
"@payloadcms/db-postgres": "3.11.0",
|
|
"@payloadcms/db-sqlite": "3.11.0",
|
|
"@payloadcms/eslint-config": "3.9.0",
|
|
"@payloadcms/next": "3.11.0",
|
|
"@payloadcms/richtext-lexical": "3.11.0",
|
|
"@payloadcms/ui": "3.11.0",
|
|
"@swc-node/register": "1.10.9",
|
|
"@swc/cli": "0.5.1",
|
|
"@swc/jest": "^0.2.37",
|
|
"@types/jest": "29.5.12",
|
|
"@types/node": "^22.5.4",
|
|
"@types/react": "19.0.1",
|
|
"@types/react-dom": "19.0.1",
|
|
"copyfiles": "2.4.1",
|
|
"eslint": "^9.16.0",
|
|
"eslint-config-next": "15.1.0",
|
|
"graphql": "^16.8.1",
|
|
"jest": "29.7.0",
|
|
"mongodb-memory-server": "^10.1.2",
|
|
"next": "15.1.0",
|
|
"open": "^10.1.0",
|
|
"payload": "3.11.0",
|
|
"prettier": "^3.4.2",
|
|
"qs-esm": "7.0.2",
|
|
"react": "19.0.0",
|
|
"react-dom": "19.0.0",
|
|
"rimraf": "3.0.2",
|
|
"sharp": "0.32.6",
|
|
"sort-package-json": "^2.10.0",
|
|
"typescript": "5.7.2"
|
|
},
|
|
"peerDependencies": {
|
|
"payload": "^3.11.0"
|
|
},
|
|
"engines": {
|
|
"node": "^18.20.2 || >=20.9.0"
|
|
},
|
|
"registry": "https://registry.npmjs.org/"
|
|
}
|