Adding Path Alias Support in fastify-cli
- Dominant language
- JavaScript
- Stars
- 733
- Forks
- 177
- Avg merge
- 1d 20h
- Merged PRs (30d)
- 3
Description
### Prerequisites
- [x] I have written a descriptive issue title
- [x] I have searched existing issues to ensure the feature has not already been requested
### 🚀 Feature Proposal
I'm working on a Fastify application created with the Fastify CLI, and I would like to add support for path aliases.
Currently, I have to use long relative paths like this:
```ts
import { hello } from '../../../hello.js';
```
It would be much more convenient to use a path alias, allowing me to write:
```ts
import { hello } from '@/hello.js';
```
I've configured my tsconfig.json as follows to set the path alias:
```json
{
"extends": "fastify-tsconfig",
"compilerOptions": {
"outDir": "dist",
"strict": true,
"strictNullChecks": true,
"skipLibCheck": true,
"sourceMap": true,
"moduleResolution": "NodeNext",
"module": "NodeNext",
"target": "ES2022",
"esModuleInterop": true,
"baseUrl": "src",
"paths": {
"@/*": ["./*"]
}
},
"include": ["src/**/*.ts"]
}
```
However, I'm unsure how to pass options to node itself when using the Fastify CLI to start my app.
For reference, here is a related discussion on Stack Overflow: [ESM does not resolve module-alias](https://stackoverflow.com/questions/53200528/esm-does-not-resolve-module-alias).
### Motivation
_No response_
### Example
_No response_
Contributor guide
Assessment
This issue has not been assessed yet.