docs: add a troubleshooting guide for dist imports (#9442)

This commit is contained in:
Shahed Nasser
2024-10-03 14:17:48 +03:00
committed by GitHub
parent ab5a7ca691
commit 1bb3f8b5b1
6 changed files with 55 additions and 30 deletions
@@ -0,0 +1,36 @@
export const metadata = {
title: `Importing from /dist Sub-Path`,
}
# {metadata.title}
Because of how Medusa packages are bundled and released, importing from the `/dist` sub-path of its packages is not allowed.
For example, this is not allowed:
```ts
import {
AdminGetApiKeysParams
} from "@medusajs/medusa/dist/api/admin/api-keys" // <-- Not allowed
```
## Importing from Exposed Directories
The `@medusajs/medusa` package allows you to import from the following sub-directories:
- `api`
- `subscribers`
- `jobs`
- `core-flows`
- `loaders`
- `commands`
So, you can still import `AdminGetApiKeysParams` from the example above, however, the import path shouldn't include `/dist`.
So, this is allowed:
```ts
import {
AdminGetApiKeysParams
} from "@medusajs/medusa/api/admin/api-keys" // <-- Allowed
```