serverless-esbuild icon indicating copy to clipboard operation
serverless-esbuild copied to clipboard

serverless-esbuild should expose lifecycle events to be hookable

Open gabsn opened this issue 3 years ago • 2 comments

After looking for lifecycleEvents in the source code, I didn't find any hookable events I could use to customize the serverless-esbuild plugin behavior.

However it is common best practice to expose such events when you write a plugin (See here).

For example, serverless-offline exposes init, ready and end event that serverless-esbuild actually uses to build the module before launching serverless-offline (See here).

I would need this hook to copy some static assets before bundling the package with esbuild.

Let me know if you want me to open the PR.

gabsn avatar Jul 03 '21 18:07 gabsn

Hi @gabsn, I have in mind to implement this similar way like serverless-webpack does, but cannot currently focus on it. I would appreciate your effort if you're willing to contribute.

floydspace avatar Jul 05 '21 11:07 floydspace

Sorry finally I decided to go with serverless-scriptable-plugin and:

  scriptable:
    hooks:
      # serverless
      before:deploy:deploy: yarn build
      before:invoke:local:invoke: yarn build
      # serverless-offline
      before:offline:start: yarn dynamodb:start & yarn watch &

Then in my build command I can use esbuild with its native config.

gabsn avatar Jul 23 '21 12:07 gabsn