grafana/public
Ben Sully be71277d33
Plugins: fix loading of modules which resolve to Promises (#82299)
* Plugins: fix loading of modules which resolve to Promises

Prior to this commit we expected the default export of a plugin module
to be an object with a `plugin` field.

This is the case for the vast majority of plugins, but if a plugin uses
webpack's `asyncWebAssembly` feature then the default export will actually
be a promise which resolves to such an object.

This commit checks the result of the SystemJS import to make sure it has
a `plugin` field. If not, and if the `default` field looks like a Promise,
it recursively attempts to resolve the Promise until the object looks like
a plugin.

I think this may have broken with the SystemJS upgrade (#70068) because it used
to work without this change in Grafana 10.1, but it's difficult to say
for sure.

* Use Promise.resolve instead of await to clean up some logic

* Override systemJSPrototype.import instead of handling defaults inside importPluginModule

* Add comment to explain why we're overriding systemJS' import

Co-authored-by: Jack Westbrook <jack.westbrook@gmail.com>

---------

Co-authored-by: Jack Westbrook <jack.westbrook@gmail.com>
2024-02-21 13:25:00 +00:00
..
app Plugins: fix loading of modules which resolve to Promises (#82299) 2024-02-21 13:25:00 +00:00
dashboards Elasticsearch: Add error source for DataQuery (#77386) 2023-11-06 11:36:39 +01:00
emails Auth: Fix email verification bypass when using basic authentication (#82914) 2024-02-16 18:54:59 +01:00
fonts Chore: Update Inter font files (#82446) 2024-02-14 16:57:02 +00:00
gazetteer Geomap: Add more countries ISO 3166 Alpha-3-code to the gazetteer/countries.json (#75311) 2023-11-06 10:08:33 -08:00
img Add PagerDuty to the plugins list (#82419) 2024-02-14 14:56:18 +01:00
lib Kusto: Move loading @kusto/language-service off the main thread (#72006) 2023-07-20 12:36:39 +02:00
locales I18n: Download translations from Crowdin (#82181) 2024-02-12 10:35:01 +00:00
maps Geomap: Support geojson styling properties (#80272) 2024-01-20 02:55:17 +02:00
sass Chore: Update Inter font files (#82446) 2024-02-14 16:57:02 +00:00
test Chore: upgrade to msw v2 (#82270) 2024-02-14 13:16:44 +00:00
vendor Plugins: Allow loading panel plugins from a CDN (#59096) 2023-01-27 15:08:17 +01:00
views K8s: Improve OpenAPI behaviour (#81606) 2024-01-31 01:17:14 +02:00
api-enterprise-spec.json Password policy (#82268) 2024-02-16 04:58:05 -06:00
api-merged.json Auth: Fix email verification bypass when using basic authentication (#82914) 2024-02-16 18:54:59 +01:00
openapi3.json Auth: Fix email verification bypass when using basic authentication (#82914) 2024-02-16 18:54:59 +01:00
robots.txt