docs: documet support for type aliases (#11117)

This commit is contained in:
Shahed Nasser
2025-01-30 09:09:29 +02:00
committed by GitHub
parent e98d3c615e
commit 332ef06534
3 changed files with 59 additions and 0 deletions
@@ -0,0 +1,46 @@
export const metadata = {
title: `${pageNumber} Using TypeScript Aliases`,
}
# {metadata.title}
By default, Medusa doesn't support TypeScript aliases in production.
If you prefer using TypeScript aliases, install following development dependencies:
```bash npm2yarn
npm install --save-dev tsc-alias rimraf
```
Where `tsc-alias` is a package that resolves TypeScript aliases, and `rimraf` is a package that removes files and directories.
Then, add a new `resolve:aliases` script to your `package.json` and update the `build` script:
```json title="package.json"
{
"scripts": {
// other scripts...
"resolve:aliases": "tsc --showConfig -p tsconfig.json > tsconfig.resolved.json && tsc-alias -p tsconfig.resolved.json && rimraf tsconfig.resolved.json",
"build": "npm run resolve:aliases && medusa build"
}
}
```
You can now use TypeScript aliases in your Medusa application. For example, add the following in `tsconfig.json`:
```json title="tsconfig.json"
{
"compilerOptions": {
// ...
"paths": {
"@/*": ["./src/*"]
}
}
}
```
Now, you can import modules, for example, using TypeScript aliases:
```ts
import { BrandModuleService } from "@/modules/brand/service"
```