Strapi 5.6.0 | Unable to add dependencies to local plugins
<!--
Hello 👋 Thank you for submitting an issue.

Before you start, please make sure your issue is understandable and reproducible.
To make your issue readable make sure you use valid Markdown syntax.

https://guides.github.com/features/mastering-markdown/

Please ensure you have also read and understand the contributing guide.

https://github.com/strapi/strapi/blob/main/CONTRIBUTING.md#reporting-an-issue
-->

## Bug report

### Required System information

<!-- Please ensure you are using the Node LTS version (18, 20, or 22) -->
<!-- Strapi v3 is no longer supported, please update to Strapi v4 -->
<!-- If you are reporting a frontend bug please provide error logs after setting STRAPI_ENFORCE_SOURCEMAPS=true in your .env -->
<!-- This environment variable makes frontend errors easier to read and trace -->

- Node.js version: 20
- NPM version: 8 (also tested in v10)
- Strapi version: 5.6.0
- Database: PostgreSQL
- Operating system: Win 11 Pro
- Is your project Javascript or Typescript: Javascript

<!-- Did you know you can run `yarn strapi report` or `npm run strapi report` to get this information easier? -->

### Describe the bug

I'm currently using a monorepo setup (workspaces), but the same behavior will also occur with a normal setup. I have a root package.json like this: 

```json
{
  "name": "strapi-app",
  "version": "0.1.0",
  "private": true,
  "description": "A Strapi application",
  "license": "MIT",
  "author": {
    "name": "A Strapi developer"
  },
  "workspaces": [
    "src/plugins/payments",
    "src/plugins/lms"
  ],
  "scripts": {
    "build": "npm run build:plugins && npm run build:strapi",
    "build:plugins": "npm run build --workspaces",
    "build:strapi": "strapi build",
    "develop": "strapi develop",
    "start": "strapi start",
    "strapi": "strapi"
  },
  "dependencies": {
    "@_sh/strapi-plugin-ckeditor": "^5.0.0",
    "@pdfme/common": "^4.0.1",
    "@pdfme/generator": "^4.0.1",
    "@pdfme/schemas": "^4.0.1",
    "@pdfme/ui": "^4.0.1",
    "@sklinet/strapi-plugin-video-field": "^1.1.0",
    "@strapi/plugin-users-permissions": "5.6.0",
    "@strapi/provider-email-sendgrid": "5.6.0",
    "@strapi/sdk-plugin": "^5.2.8",
    "@strapi/strapi": "5.6.0",
    "csv-stringify": "^6.5.2",
    "date-fns": "^2.30.0",
    "dotenv": "^16.0.3",
    "formdata-node": "^6.0.3",
    "fs-extra": "^11.2.0",
    "pg": "8.6.0",
    "react": "^18.0.0",
    "react-dom": "^18.0.0",
    "react-router-dom": "^6.0.0",
    "slugify": "^1.6.6",
    "strapi-plugin-config-sync": "^3.1.1",
    "strapi-plugin-navigation": "^3.0.3",
    "strapi-provider-cloudflare-r2": "^0.3.0",
    "stripe": "^15.6.0",
    "styled-components": "^6.0.0"
  },
  "engines": {
    "node": "20.x"
  },
  "strapi": {
    "uuid": "--uuid--"
  }
}
```

As you can see, I have two local plugins. lms and payments. The package.json of the lms looks like this: 

```json
{
  "name": "lms",
  "version": "0.0.0",
  "description": "",
  "keywords": [],
  "license": "MIT",
  "author": "Xzandro <email>",
  "type": "commonjs",
  "exports": {
    "./package.json": "./package.json",
    "./strapi-admin": {
      "source": "./admin/src/index.js",
      "import": "./dist/admin/index.mjs",
      "require": "./dist/admin/index.js",
      "default": "./dist/admin/index.js"
    },
    "./strapi-server": {
      "source": "./server/src/index.js",
      "import": "./dist/server/index.mjs",
      "require": "./dist/server/index.js",
      "default": "./dist/server/index.js"
    }
  },
  "files": [
    "dist"
  ],
  "scripts": {
    "build": "strapi-plugin build",
    "verify": "strapi-plugin verify",
    "watch": "strapi-plugin watch",
    "watch:link": "strapi-plugin watch:link"
  },
  "dependencies": {
    "@strapi/design-system": "^2.0.0-rc.14",
    "@strapi/icons": "^2.0.0-rc.14",
    "react-intl": "^7.0.4"
  },
  "devDependencies": {
    "@strapi/sdk-plugin": "^5.2.8",
    "prettier": "^3.4.2"
  },
  "peerDependencies": {
    "@strapi/strapi": "5.6.0",
    "react": "^18.3.1",
    "react-dom": "^18.3.1",
    "react-router-dom": "^6.28.1",
    "styled-components": "^6.1.13"
  },
  "strapi": {
    "kind": "plugin",
    "name": "lms",
    "displayName": "Learning Management System",
    "description": ""
  }
}
```

Now, the dependencies I have tried are @pdfme ones and the formdata-node one. I normally only use these dependencies in the lms plugin, but I'm unable to do so and I'm forced to add them to the root package.
If i try to add these dependences directly to the local lms plugin, the plugin itself will build fine, but when I then try to do `npm run develop` Strapi will throw the following error: 

```
[ERROR]  There seems to be an unexpected error, try again with --debug for more information 

┌──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┐
│                                                                                                                                                                                                                      │
│   Error: Could not load js config file C:\Projekte -SSD\CALPG\calpg-online-cms\src\plugins\lms\dist\server\index.js: Cannot destructure property 'generate' of 'require$$0__default$9.default' as it is undefined.   │
│       at loadJsFile (C:\Projekte -SSD\CALPG\calpg-online-cms\node_modules\@strapi\core\dist\utils\load-config-file.js:18:13)                                                                                         │
│       at Module.loadConfigFile (C:\Projekte -SSD\CALPG\calpg-online-cms\node_modules\@strapi\core\dist\utils\load-config-file.js:37:14)                                                                              │
│       at loadPlugins (C:\Projekte -SSD\CALPG\calpg-online-cms\node_modules\@strapi\core\dist\loaders\plugins\index.js:117:41)                                                                                        │
│       at async Promise.all (index 3)                                                                                                                                                                                 │
│       at async Module.loadApplicationContext (C:\Projekte -SSD\CALPG\calpg-online-cms\node_modules\@strapi\core\dist\loaders\index.js:12:3)                                                                          │
│       at async Object.register (C:\Projekte -SSD\CALPG\calpg-online-cms\node_modules\@strapi\core\dist\providers\registries.js:26:5)                                                                                 │
│       at async Strapi.register (C:\Projekte -SSD\CALPG\calpg-online-cms\node_modules\@strapi\core\dist\Strapi.js:325:7)                                                                                              │
│       at async Strapi.load (C:\Projekte -SSD\CALPG\calpg-online-cms\node_modules\@strapi\core\dist\Strapi.js:317:5)                                                                                                  │
│       at async Module.develop (C:\Projekte -SSD\CALPG\calpg-online-cms\node_modules\@strapi\strapi\dist\node\develop.js:148:28)                                                                                      │
│       at async action (C:\Projekte -SSD\CALPG\calpg-online-cms\node_modules\@strapi\strapi\dist\cli\commands\develop.js:18:5)                                                                                        │
│                                                                                                                                                                                                                      │
└──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┘
```

I tried a lot of variants. I put these into the root ones AND the plugin package.json. I put it only in the plugins package.json. Always this error. However, it does (kind of) work when I put it into the root package.json ONLY. This does have negative effects though. Building takes ages, because resolving the dependencies from the root node_modules folder seems to take a long time and causes big chunks. There also are a few warnings about using "evals". I think this is far from ideal.

### Steps to reproduce the behavior

1. Create a Strapi app an create a local plugin with the plugin-sdk
2. Add one of the mentioned dependencies to the plugin (probably does not work for other dependencies as well)
3. Build the local plugin
4. Try `npm run develop`on Strapi
5. An error will appear during the building process of Strapi

### Expected behavior

I expect to use dependences on the local plugin level, so I'm not forced to add all dependencies for the root Strapi app itself, since this has negative implications.

### Screenshots

![Code_IyIHBZdgFi](https://github.com/user-attachments/assets/9c4a3825-0cf9-46ef-a5c5-23d0ef41aac1)