Join GitHub today
GitHub is home to over 31 million developers working together to host and review code, manage projects, and build software together.Sign up
Make serverless-webpack more extensible #254
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.
How did you implement it:
Following the advice from serverless blog on Advanced Plugin Development. Used Plugin Manager.
How can we verify it:
As stated in the blog above... this will enable better extensibility.
Is this ready for review?: YES
Hi @josephleehunsaker ,
thanks for the PR (and reading my blog post
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
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