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

feat: plugin template #10150

Merged
merged 21 commits into from
Dec 27, 2024
Merged

feat: plugin template #10150

merged 21 commits into from
Dec 27, 2024

Conversation

r1tsuu
Copy link
Member

@r1tsuu r1tsuu commented Dec 23, 2024

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:
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:

{
  "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

@r1tsuu r1tsuu linked an issue Dec 23, 2024 that may be closed by this pull request
templates/plugin/src/index.ts Outdated Show resolved Hide resolved
templates/plugin/src/index.ts Show resolved Hide resolved
@r1tsuu r1tsuu requested a review from denolfe December 26, 2024 21:59
@r1tsuu r1tsuu enabled auto-merge (squash) December 27, 2024 14:23
@r1tsuu r1tsuu merged commit d8a62b7 into main Dec 27, 2024
67 checks passed
@r1tsuu r1tsuu deleted the plugin-template branch December 27, 2024 14:25
Copy link
Contributor

🚀 This is included in version v3.12.0

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Creating a plugin from the template fails
2 participants