Typescript4.5.3を利用して、複数のAWS Lambda関数を作成しています。
その際、他のLambda関数でも共通して使いたい定数が書かれたconst.tsファイルを
以下の階層に配置しています。
root ├── LambdaFunctionA │ └── src │ └── indexA.ts └── common └── const.ts
Typescript:indexA.ts
1import {filePath} from '../../common/const' 2console.log(filePath)
Typescript:const.ts
1export const filePath:string = "/test/aaa";
この状態でLambdaFunctionAをコンパイルをすると、
dist配下に関数名のディレクトリが出来、その下層に
srcディレクトリ※が出来、その中にコンパイルされたjsが吐き出されます。
root ├── LambdaFunctionA │ ├── dist │ │ ├── LambdaFunctionA │ │ │ └──src ←※srcディレクトリ │ │ │ └──indexA.js │ │ └── common │ │ └── const.js │ └── src │ └── indexA.ts └── common └── const.ts
これを
root ├── LambdaFunctionA │ ├── dist │ │ ├── LambdaFunctionA │ │ │ └──indexA.js │ │ └── common │ │ └──const.js │ └── src │ └── indexA.ts └── common └── const.ts
の様に、srcディレクトリが出来ない構成でコンパイルすることはできないのでしょうか?
tsconfg.jsonは以下の通りです。
tsconfig.json
1{ 2 "compilerOptions": { 3 "target": "ES2020", 4 "module": "commonjs", 5 "baseUrl": "../../", 6 "outDir": "./dist" , 7 "esModuleInterop": true , 8 "forceConsistentCasingInFileNames": true , 9 "noImplicitAny": true, 10 "strictNullChecks": true, 11 "strictFunctionTypes": true, 12 "strictBindCallApply": true, 13 "strictPropertyInitialization": true, 14 "noImplicitThis": true, 15 "useUnknownInCatchVariables": true, 16 "alwaysStrict": true, 17 "noUnusedLocals": true, 18 "noUnusedParameters": true, 19 "exactOptionalPropertyTypes": true, 20 "noImplicitReturns": true, 21 "noFallthroughCasesInSwitch": true, 22 "noUncheckedIndexedAccess": true, 23 "noImplicitOverride": true, 24 "noPropertyAccessFromIndexSignature": true, 25 "skipLibCheck": true 26 }, 27 "include": ["src/**/*"] 28}
何卒宜しくお願いします。
あなたの回答
tips
プレビュー