We have a NodeJS app written in typescript. We use modules using relative paths e.g.
import foo from '@/bar';
We have following paths entry in tsconfig.json
"paths": {
"@/*": [
"./*"
]
}
As typescript does not have path transformation support, we are using ttypescript to compile and override tsconfig.json with tsconfig.build.json
{
"extends": "./tsconfig.json",
"compilerOptions": {
"plugins": [
{
"transform": "@zerollup/ts-transform-paths"
}
]
},
"exclude": ["node_modules/**", "tests/**"]
}
and use yarn to build the code
yarn clean && ttsc --project ./tsconfig.build.json
Now this build the code and converts the relative @module paths to absolute.
Next we are using Serverless framework to build and deploy this code as lambda. Serverless uses tsconfig.json to build the code and effectively ignore the custom path transformation.
Question:
- is it possible to solve the above problem without using ttypescript and plugin?
- Is it possible to configure serverless to use ttypescript and custom tsconfig
- Any other way to solve the problem?
Thanks