In NocoBase plugin development, dependencies are divided into two categories: plugin dependencies and global dependencies.
@nocobase/server and @nocobase/client, plugins don't need to bundle them separately.Since plugin dependencies will be bundled into the plugin artifacts (including server dependencies being bundled into dist/node_modules), during plugin development, you can declare all dependencies in devDependencies instead of dependencies. This avoids differences between development and production environments.
When a plugin needs to install the following dependencies, make sure the version number matches the global dependencies in @nocobase/server and @nocobase/client, otherwise runtime conflicts may occur.
The following dependencies are provided by NocoBase and don't need to be bundled in plugins. If needed, they should match the framework version.
Maintain Dependency Consistency
If you need to use packages that already exist in global dependencies, avoid installing different versions and use the global dependencies directly.
Minimize Bundle Size
For common UI libraries (such as antd), utility libraries (such as lodash), database drivers (such as pg, mysql2), you should rely on globally provided versions to avoid duplicate bundling.
Consistency Between Debug and Production Environments
Using devDependencies ensures consistency between development and final artifacts, avoiding environment differences caused by improper configuration of dependencies and peerDependencies.