Skip to main content

插件升级摘要

🌐 Plugins upgrade summary

本页面旨在作为简要总结,供插件开发者在将插件从 Strapi v4 升级到 Strapi 5 时参考。页面快速描述了影响插件的变化,并在必要时链接到其他资源。

🌐 The present page is intended to be used as a short summary of everything to consider if you are a plugin developer upgrading your plugin from Strapi v4 to Strapi 5. The page quickly describes the changes affecting plugins and links to additional resources where necessary.

Plugin SDK

从 Strapi 5 开始,该平台包含一个 插件 SDK 来帮助开发和构建 Strapi 插件。虽然你可以自由使用其他方法进行插件开发,但我们强烈建议使用插件 SDK。作为从 v4 迁移到 Strapi 5 的一部分,我们鼓励你更新你的插件以利用插件 SDK 的优势。

🌐 Starting with Strapi 5, the platform includes a Plugin SDK to help develop and build Strapi plugins. While you are free to use other methods for plugin development, we strongly recommend using the Plugin SDK. As part of the migration process from v4 to Strapi 5, we encourage you to update your plugin to take advantage of the Plugin SDK.

🌐 Recommended steps to migrate a plugin

Prerequisites

你的 Strapi 应用已运行在最新的 v5 小版本和补丁版本。如果没有,请按照逐步指南升级到 Strapi 5。

🌐 Your Strapi application is already running on the latest v5 minor and patch version. If it's not, follow the step-by-step guide to upgrade to Strapi 5.

将 Strapi v4 插件升级到 Strapi 5 包括:

🌐 Upgrading a Strapi v4 plugin to Strapi 5 consists in:

  1. 使用 Plugin SDK 创建一个新的空插件。
  2. 将你的 Strapi v4 代码移到 Strapi 5 新创建的文件中,同时考虑本页面中总结的更改。

或者,你可以手动更新你的 Strapi v4 插件以使用插件 SDK。手动步骤包括:

🌐 Alternatively, you can manually update your Strapi v4 plugin to use the Plugin SDK. The manual steps include:

  1. 如果你的代码使用除 CommonJS 以外的格式,请更新 package.json 文件并指定适当的 exports 属性。
  2. 重新组织你的 Strapi v4 代码,以与 Strapi 5 插件结构 对齐

后端更改

🌐 Back-end changes

  • Strapi v4 的实体服务 API 已被弃用,Strapi 5 改为使用 文档服务 API。有一个 迁移指南 可帮助你过渡到文档服务 API。
  • 一般来说,Strapi v4 到 Strapi 5 的 重大更改 可能适用。
  • 你可以使用新的 插件 SDK 来生成插件,并将它们发布到 NPM 和/或提交到市场。

前端更改

🌐 Front-end changes

  • 设计系统在 Strapi 5 中升级到 v2:
  • helper-plugin 已被移除。可以使用 迁移参考 帮助你从 helper-plugin 过渡。
  • Strapi 不再对依赖进行别名处理。项目级别声明了预期所有面向客户端的代码都会使用的四个依赖(reactreact-domstyled-componentsreact-router-dom)。如果你没有声明所使用的依赖(例如 axios),用户可能会遇到使用你的插件时出现不可预见的问题。
  • 如果你正在使用 Plugin SDK,你将需要将你的前端文件转换为 .jsx.tsx 格式。

自定义提供者

🌐 Custom providers

只有在使用实体服务 API 的情况下,EmailUpload 插件的自定义提供程序才需要转换(请参阅 从实体服务 API 到文档服务 API 的迁移指南)。

🌐 Custom providers for the Email and Upload plugins need conversion only if they were using the Entity Service API (please refer to the Entity Service API to Document Service API migration guide).