-
Notifications
You must be signed in to change notification settings - Fork 417
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
Make serverless-webpack more extensible #254
Conversation
Use PluginManager to make serverless-webpack more extensible Following the advice from serverless blog on Advanced Plugin Development. https://serverless.com/blog/advanced-plugin-development-extending-the-core-lifecycle/
Hi @josephleehunsaker , thanks for the PR (and reading my blog post 😄 ). The idea to run a separate lifecycle that can be hooked is really beneficial. That offers a much better reusability of the internal steps like validation and does not invoke a complete command. I did such an implementation in the AWS deploy command which spawns it's internal lifecycle (aws:deploy:*) instead of executing a whole command. Commands should not be run from a plugin (using "run") because they may introduce side effects special to that command. A better solution would be to declare entrypoints webpack:validate, webpack:compile, webpack:packExternalModules and webpack:packModules and use pluginManager.spawn('....') to invoke their lifecycles. Then any plugin can hook wherever it wants to, may it be the validation, the compilation or the packaging (both levels). The public commands and hooks (webpack, before:....) will then only spawn the webpack lifecycles. So the hookable lifecycle model would be:
The webpack plugin hooks will then just spawn them like this:
A 3rd party plugin can then hook any of these, and additionally the lifecycle events themselves are extensible, so that e.g. the |
If you have "enable edits by maintainers" enabled, I will change the PR accordingly - should be straight forward (and make the unit tests test the new behavior). |
Terrific, thx. I would appreciate it if you could get it working just right :) I am still learning webpack plugins and serverless plugins.. so I did just enough to get the job done on my end. I believe "enable edits by maintainers" is enabled. Let me know if you are unable to change the PR. |
@josephleehunsaker You should now be able to hook |
Can you give it a try with |
Released with |
Thank you so much! |
What did you implement:
Use PluginManager to make serverless-webpack more extensible. I am trying to create my own plugin that works with serverless-webpack, but I am unable to extend before the validation step without this change.
Closes #XXXXX
How did you implement it:
Following the advice from serverless blog on Advanced Plugin Development. Used Plugin Manager.
https://serverless.com/blog/advanced-plugin-development-extending-the-core-lifecycle/
How can we verify it:
As stated in the blog above... this will enable better extensibility.
Try to create a new serverless plugin that runs before the serverless-webpack before:deploy:createDeploymentArtifacts hook.
Todos:
Is this ready for review?: YES
Is it a breaking change?: NO