serverless / serverless-plugin-typescript

Serverless plugin for zero-config Typescript support
MIT License
781 stars 222 forks source link

Is it possible to include files that aren't specifically imported? #266

Closed theodorDiaconu closed 2 years ago

theodorDiaconu commented 2 years ago

I have a mechanism in which I automatically load all the graphql files from a 'graphql' folder. I don't explicitly import these files I extract them based on __dirname, however in the .build output those files are missing resulting into an error. Is there a way to bypass this or add a hook to it so it copies these files too?

theodorDiaconu commented 2 years ago

@medikoo any ideas? thank you!

medikoo commented 2 years ago

@theodorDiaconu sorry, my knowledge of this plugin internals is very limited, and unfortunately at this point, I'm unable to invest time into it

theodorDiaconu commented 2 years ago

@medikoo got it, thank you.

theodorDiaconu commented 2 years ago

After doing additional digging, it seems that behind the scenes they are using ts.createProgram (https://github.com/microsoft/TypeScript-wiki/blob/main/Using-the-Compiler-API.md#a-minimal-compiler)

This means that we have no way of including 'orphaned' modules. The only solution for me at least is to create a custom serverless plugin.