我正在尝试使用无服务器框架将我的 Node.js 应用程序部署到 Lambda,但是,我的 Node 代码使用来自 tsconfig.json 的路径来引用导入,但无服务器部署过程失败。如何连接 serverless.yml 以确认和使用 tsconfig.json 中定义的路径?
我已经安装了 serverless-plugin-typescript,但它似乎无法识别来自 tsconfig 的路径。
无服务器.yml
service:
name: app-name
custom:
webpack:
webpackConfig: ./webpack.config.js
includeModules: true
plugins:
- serverless-webpack
- serverless-plugin-typescript
...
tsconfig.ts
{
"compileOnSave": true,
"compilerOptions": {
"lib": [
"es2017"
],
"baseUrl": "./src",
"declaration": true,
"downlevelIteration": true,
"esModuleInterop": true,
"forceConsistentCasingInFileNames": true,
"module": "commonjs",
"moduleResolution": "node",
"noUnusedLocals": true,
"noUnusedParameters": true,
"outDir": "./dist",
"paths": {
"@config/*": [
"config/*"
],
"@core/*": [
"core/*"
],
"@infra/*": [
"infra/*"
],
"@modules/*": [
"modules/*"
],
"@shared/*": [
"shared/*"
]
},
"preserveConstEnums": true,
"removeComments": true,
"rootDir": "./src",
"skipLibCheck": true,
"sourceMap": true,
"strict": true,
"strictNullChecks": false,
"target": "es2017",
"typeRoots": [
"node_modules/@types"
],
"types": [
"node"
]
},
"include": [
"./**/*.ts"
],
"exclude": [
"node_modules/**/*",
".serverless/**/*",
".webpack/**/*",
"_warmup/**/*",
".vscode/**/*"
]
}