docs: documet support for type aliases (#11117)
This commit is contained in:
@@ -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"
|
||||
```
|
||||
Reference in New Issue
Block a user