1
votes

I'm using amazon lambda aws with serverless and the serverless-plugin-typescript to build my typescript files. I have shared code in my project, e.g. a folder structure like this:

/shared: shared1.ts, shared2.ts

/microservice1: microservice1.ts, serverless.yml

/microservice2: microservice2.ts: serverless.yml

According to what I read it is not possible to pass a YAML file via command line to serverless deploy. So the current working directory has to be inside "/microservice1" or "/microservice2". This results in not being able to build with the following error: 'File '...shared1.ts' is not under 'rootDir' '...microservice1'. 'rootDir' is expected to contain all source files.' I also can not set rootDir in tsconfig.json to "../" since it is overwritten with default './'. So the only work around I see is to work with symlinks which is IMHO a little hacky.

So is there a possibility to build these shared files without using symlinks?

1

1 Answers

0
votes

I'd suggest using serverless-webpack since webpack can follow your imports and include them in your compiled file.