Using Serverless Typescript plugin changes output structure when importing shared files

441 Views Asked by At

I have the following folder structure for a project running serverless-plugin-typescript:

<root>
  - services
    - common
    - sample-service

sample-service houses the serverless.yml and all endpoints. common hosts a few entities/services/utilities/etc. When I import a file from common into sample-service and then run the offline or package command, the output folder structure changes from this (which is what I want):

<build root>
  - endpoints
    - ...files

To this (which is what I don't want):

<build root>
  - common
    - ...files
  - sample-service
    - endpoints
      - ...files

If I try to hit the API endpoint, I get an error saying it can't find my handler file (since it is in the sample-service/endpoints directory instead of the root endpoints directory). I can work around this in the case of serverless-offline by passing the --location param and specifying the sample-service folder. But when I deploy this to AWS, I have the same issue of it not finding the endpoint since it is a folder deeper than it should be.

I have tried using Typescript project references, but have not had much luck. I have also tried using serverless-webpack, but unfortunately there is a pretty large memory leak in it which is why I have moved on to trying a different build system.

Does anyone have any insight into how I could change the configuration of either Typescript or the serverless plugin to mimic the build structure I am looking for (the first one)? Or maybe I didn't implement project references the right way?

0

There are 0 best solutions below