4

I use Serverless framework to deploy my backend. My lambdas are written in Typescript and I deploy them using serverless-webpack plugin. Serverless allows to reference variables in javascript files using syntax:

# serverless.yml
service: new-service
provider: aws

custom: ${file(../config.js)}

But it works for javascript. How can I do the same with Typescript code? My goal is to have all project code written in Typescript.

Niv-Mizzet
  • 361
  • 3
  • 6
  • It's not about server nor lambda code. I want to have some parts of config to be generated using typescript, same as it can be done with JS (please, see the example I posted) – Niv-Mizzet Oct 23 '18 at 13:24
  • You can try making a JavaScript file that calls `require('ts-node').register();` and then loads your TypeScript file and copies the TypeScript file's exports to its own exports. I wonder if loading ts-node into the Serverless CLI process will break anything. – Matt McCutchen Oct 24 '18 at 02:12

0 Answers0