serverless-plugin-typescript
serverless-plugin-typescript copied to clipboard
Unreferenced files are not compiled
I'm using ts-lambda-api as a framework for my application, which allows me to declare controllers using decorators that are discovered at runtime, rather than statically declared.
It seems like the typescript plugin only compiles files that can be resolved at compile time from the function entry points, which means the controllers are not compiled.
My workaround at the moment is to have dummy imports in my main class to import those controller classes so they can be found. Is there a better way to control this behaviour?
We are using Node Dependency Injection library and experiencing the same issue due to its dynamic imports. Are there any plans to fix this, please? Our current workaround relies on statically importing the services again in our entry point which is a little hard to maintain.
// ToDo: https://github.com/serverless/serverless-plugin-typescript/issues/188
// eslint-disable-next-line @typescript-eslint/no-unused-vars
import Configurator from './components/Configurator';
...
Does anybody have at least a better workaround, please?
It's not ideal but you can use the Package configuration to specify globs of files to include in the package.
package:
patterns:
- '!node_modules/**'
- 'node_modules/node-fetch/**'