-
Notifications
You must be signed in to change notification settings - Fork 26
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Proposal for plugin architecture #140
Comments
Awesome. 👍 |
I think that array instead of object is the simplest thing. If we use a priority index then we'll soon write a process scheduler and I am really poor at such tasks... |
Array sounds good to me. |
What about:
In this case ``plugins` has two keys – config and order – which makes it easier to specify and fiddle with the order without the need of moving large quantities of object data chunks. |
Seems good. What should we do if the Let's assume some use cases:
So, I suggest renaming "plugins": {
// temporary name
"use": ["markdown", "deploy-github"/*, "deploy-s3"*/],
"config": {
"deploy-gihub": {
"repo": "soapdog/site",
"branch": "gh-pages"
},
"deploy-s3": {
"bucket": "blablabla"
}
}
} Next, we should look into error handling. I guess we can consider how to handle errors in plugins after we have an initial proof of concept of the plugins architecture. |
Just wondering, i don't think let the config order in this layer is a good approach. So we can do something like this (runtime plugin creation): module.exports = (harmonic) => {
harmonic.use(() => console.log('my tiny plugin'))
.use('deploy-github', () => {
// implementation
});
} Already defined plugins: module.exports = (harmonic) => {
harmonic.use(deploys3);
harmonic.use(rss);
...
} Too complicated? |
@jaydson that would tie Harmonic usage to developers who know JS. We might want to opt for a simple config file and then it would be easier for a non-programmer to use. |
I agree with @soapdog. |
Also this is an issue of declarative vs programmatic ways to approach plugin configuration. Declarative approach is easier to test and check for errors. The programmatic way is easier to shoot yourself in the foot. My recommendation is to build a declarative way where plugins are configured using |
Sounds good to me. |
Ok, let's do it in a declarative way then. |
@soapdog any progress on the plugin stuff? |
I was waiting for us to agree. I will build a tiny POC and share as a branch here. |
👍 |
some news about plugin support? |
Nope. Harmonic still lacks on plugin support 😢 |
@soapdog By the way, did you manage to start a PoC? |
I did but I think I could use some help. Will post it to a branch and get back here. |
Hi Friends,
I have an idea on how to implement plugins for Harmonic that is very lightweight and requires minimal coding. If this idea is accepted then we'd be able to extend harmonic without touch harmonic itself.
All harmonic plugins would be normal node modules that would be installed with npm. These modules would follow a naming convention such as
harmonic-plugin-*
. The configuration for each plugin would reside inharmonic.json
like:In the case above there would be a node module named
harmonic-plugin-deploy-github
installed on the site. Harmonic would readharmonic.json
, find the plugin key and load all necessary modules on start. We'd use a publisher/subscriber like pattern where upon loading each plugin could subscribe to a given message. As harmonic workflow cycled it would dispatch the messages like preBuild, prePageGeneration, postPageGeneration, prePostGeneration, postPostGeneration, preCopyResources, postCopyResources, postBuild and so on.Modules could be built with ES6 or any other technology needed as long as they register their interest in some messages upon loading.
What do you folks think?
The text was updated successfully, but these errors were encountered: