Local extensions loaded twice when included as package dependency
- Dominant language
- TypeScript
- Stars
- 37.9k
- Forks
- 4.9k
- Avg merge
- 3d 21h
- Merged PRs (30d)
- 36
Description
### Describe the Bug
When packaging extensions locally and listing them as dependency in `package.json`, Directus currently will load them twice.
_Background:_
We've "installed" our local extension packages as dependencies in the Directus app package, so that our monorepo tooling (e.g. Turborepo) picks up on the extensions as dependencies, and knows to build those first before deploying Directus (e.g. to Directus Cloud).
~~Temp fix is to configure local Directus with e.g. `EXTENSIONS_PATH="./null"` .~~
**Edit:** Pointing the extensions path to an empty directory _does_ bypass this issue, but also prevents extension auto reloading from working.
**Edit 2:** Another temp fix is to declare local dependencies as `optionalDependencies` or `devDependencies`. Repo tools like Turborepo will still pick up the dependencies for tasks, but Directus (checking only `dependencies` for extensions) will not double-load them.
### To Reproduce
`./package.json`
```jsonc
{
// ...
"dependencies": {
"my-extension": "workspace:^",
"directus": "^10.10.4",
"pg": "^8.11.3"
},
// ...
}
```
`./extensions/my-extension/package.json`
```jsonc
{
"name": "my-extension",
"icon": "extension",
// ...
}
```
Then start Directus.
**Expected:**
- Info log: `INFO: Loaded extensions: my-extension`
- Only one instance of `my-extension` in the `directus_extensions` table
- `my-extension` listed only once on `/admin/settings/extensions`
- Any hooks (e.g. `init('app.after', () => ...)` registered and fired once
**Actual:**
- Info log: `INFO: Loaded extensions: my-extension, my-extension`
- Two records of `my-extension` in the `directus_extensions` table
- `my-extension` listed twice on `/admin/settings/extensions`
- Hooks (e.g. `init('app.after', () => ...)` registered and fired twice
### Directus Version
v10.10.4
### Hosting Strategy
Self-Hosted (Docker Image)
Contributor guide
Assessment
This issue has not been assessed yet.