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

Generate js for other plugins

Open colinfindlay-nz opened this issue 7 years ago • 8 comments

Is it possible to generate the JavaScript into the .build folder for other plugins to use? I.e. The mocha unit testing plugin and the offline plugin?

colinfindlay-nz avatar Apr 20 '17 20:04 colinfindlay-nz

Could you describe your use case with a bit more details pls?

schickling avatar Apr 22 '17 13:04 schickling

Currently your plugin only generates the JavaScript before deployment. This means that all other serverless plugins are unable to work if they don't do a deployment. The best example is the SC5 serverless-mocha-plugin

colinfindlay-nz avatar Apr 22 '17 21:04 colinfindlay-nz

So you'd like to have a separate command to build from typescript to javascript?

schickling avatar Apr 23 '17 10:04 schickling

I think so. Or a way to configure it to trigger on a much earlier hook.

On 23/04/2017 10:36 pm, "Johannes Schickling" [email protected] wrote:

So you'd like to have a separate command to build from typescript to javascript?

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/graphcool/serverless-plugin-typescript/issues/1#issuecomment-296434007, or mute the thread https://github.com/notifications/unsubscribe-auth/AAq3huFqutb7iCJUehpV-a6o5Wc0oJ4dks5ryymdgaJpZM4NDgm3 .

colinfindlay-nz avatar Apr 23 '17 19:04 colinfindlay-nz

A separate command is certainly doable. However, combining this plugin with other plugins could be problematic with the current plugin infrastructure provided by Serverless. Maybe @pmuens can provide some feedback on when this might change?

schickling avatar Apr 24 '17 08:04 schickling

Hey @silver2k the TypeScript plugin could expose own lifecycle events which can then be used to hook into via your own custom plugin.

Here you can e.g. see the lifecycle events of the main Serverless package plugin (https://github.com/serverless/serverless/blob/e82e6265e3f9bcd62ac907f576b284f35c7863f4/lib/plugins/package/package.js#L26-L34) and here's an example how to hook into the package:createDeploymentArtifacts lifecycle event (https://github.com/serverless/serverless/blob/e82e6265e3f9bcd62ac907f576b284f35c7863f4/lib/plugins/package/package.js#L61-L62).

The only thing to note is that you'll then have a dependency to the TypeScript plugin. So you need to make sure that both plugins are installed / usable.

pmuens avatar Apr 28 '17 07:04 pmuens

having a custom lifecycle would also make it easier to test i think

kandros avatar Apr 28 '17 07:04 kandros

@kandros would you be up for creating a PR for this?

schickling avatar Apr 28 '17 08:04 schickling