serverless-plugin-typescript icon indicating copy to clipboard operation
serverless-plugin-typescript copied to clipboard

Unreferenced files are not compiled

Open revbingo opened this issue 5 years ago • 2 comments

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?

revbingo avatar Nov 13 '19 14:11 revbingo

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?

michal-simon avatar Sep 12 '21 18:09 michal-simon

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/**'

tamlyn avatar Jul 13 '22 16:07 tamlyn