It would be great to have a generated (in build process perhaps) json file with all available amp components and their dependencies to other components for further usage.
To make it easy for our frontend developers we provide a function to load the script snippet of a given amp component when they want to use it. With this we prevent double includes and include of only those components that are needed on every given sub-page.
BUT: To validate those components we manually checked https://www.ampproject.org/docs/reference/components once and put all of the components in a (now static) list of elements. Components dependent on other elements are taken care of by a definition of their dependency.
This looks like this right now:
[
'amp-list' => [
'amp-list' => [
'type' => 'custom-element',
'srcUrl' => 'https://cdn.ampproject.org/v0/amp-list-0.1.js',
],
'amp-mustache' => [
'type' => 'custom-template',
'srcUrl' => 'https://cdn.ampproject.org/v0/amp-mustache-0.1.js',
],
],
'amp-user-notification' => [
'amp-user-notification' => [
'type' => 'custom-element',
'srcUrl' => 'https://cdn.ampproject.org/v0/amp-user-notification-0.1.js',
],
'amp-analytics' => [
'type' => 'custom-element',
'srcUrl' => 'https://cdn.ampproject.org/v0/amp-analytics-0.1.js',
],
],
]
@sebastianbenz suggested to use https://api.github.com/repos/ampproject/amphtml/contents/extensions and the validator and the protoascii of the components each to generate the list. But this falls apart with components/templates like amp-mustache, which are handled as a custom-templates instead and are not mentioned in requires in the protoasciis.
So perhaps it's possible to add a generated json file similar to the example above to be used to automatically validate and add components via third party tools/libraries.
It could even be added to the mentioned extensions json above.
This issue seems to be in Pending Triage for awhile. @erwinmombay Please triage this to an appropriate milestone.
A lot of this information is exported by the validator-generated.js file created by amphtml/validator. I've wrapped this up into module and published it under amphtml-validator-rules.
This issue seems to be in Pending Triage for awhile. @erwinmombay Please triage this to an appropriate milestone.
This issue seems to be in Pending Triage for awhile. @erwinmombay Please triage this to an appropriate milestone.
This issue seems to be in Pending Triage for awhile. @erwinmombay Please triage this to an appropriate milestone.
Triage: This is still worth doing.
That's awesome! Thanks @fstanis! Will we be publishing the generated JSON file somewhere?