Syntax for `plugins` configuration property
See original GitHub issueAt the moment the syntax for the plugins
configuration property is:
plugins:
- netlify-plugin-functions:
enabled: false
- ../../my-plugin:
enabled: true
I think representing a collection by using first an array then a single-property object is a little uncommon and adds one level of indentation. Also using file paths as object keys feels a little wrong (or is that just me?).
What do you think of the following alternative?
plugins:
- name: netlify-plugin-functions
enabled: false
- path: ../../my-plugin
enabled: true
On one hand it requires typing one more word. On the other hand, I think this is visually clearer and feels simpler to grasp for the end user.
This also allows us to separate different loading strategies into different properties. IMHO a single polymorphic property is harder to learn that several monomorphic properties. At the moment we only have two loading strategies (by name and by path) but this would make adding more easier.
Another advantage is, if we were to pass the list of plugins to the end user, we would probably normalize it to the above shape anyway. It would be then be easier for the user to get the same shape as the one they defined in netlify.yml
instead of a different one.
Finally this is easier to parse and manipulate when the netlify.yml
is loaded programmatically (which users might do). It’s also easier to validate and do static analysis on.
Issue Analytics
- State:
- Created 4 years ago
- Comments:16 (16 by maintainers)
Hold off on PRs on this for right now 😃. Need to figure out the shape
The object notation I described above works like this:
Here the plugin
plugin-xyz
is loaded twice with different params. The logical ids (aka parent keys) are different and therefore can be referenced individually like${myLogicalPluginName.outputXyz}
and${myOtherLogicalName.outputXyz}
The
name
(or it could betype
) field, is referencing the module name or the path to the import.Local plugins are an important part of the story and I’m not to crazy about
On the other side, I think it is also confusing to have multiple keys
name
,import
(orresolve
)Some design goals are:
There are some advanced configuration techniques possible but I’m not certain we want to expose those just yet.
Thanks for the write up. I’m all for simplifying.
I think having 2 different words to load a plugin
path
andname
might be confusing.In any case, I’ve been thinking about the plugin shape for a while and plugins might need to be an object rather than an array.
There are a couple reasons for this:
For example. Lets say a
mongo-db
plugin returns a connection string as an output. Then a second pluginmongo-db-crud-function
relies on thatconnection_string
value returned from the first plugin.We need a way for values to be referenced from plugins in other plugins.
Example:
It’s not really possible to reference values easily from a position in an array