floydspace / serverless-esbuild

💨 A Serverless framework plugin to bundle JavaScript and TypeScript with extremely fast esbuild
MIT License
446 stars 137 forks source link

serverless-esbuild should expose lifecycle events to be hookable #158

Open gabsn opened 3 years ago

gabsn commented 3 years ago

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.

floydspace commented 3 years ago

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.

gabsn commented 3 years ago

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.