Improve plugin loading error message

Summary:
I was a dummy and ran into this. Tried to make it easier
for the next person to figure out what this means.

Reviewed By: mweststrate

Differential Revision: D28026376

fbshipit-source-id: ad3455938ef30b448b475cb990f86351e76628bf
This commit is contained in:
Pascal Hartig
2021-04-27 04:38:19 -07:00
committed by Facebook GitHub Bot
parent 1cda8883af
commit 2b6e585fd2

View File

@@ -289,8 +289,16 @@ const requirePluginInternal = (
if (plugin.default) { if (plugin.default) {
plugin = plugin.default; plugin = plugin.default;
} }
if (!(plugin.prototype instanceof FlipperBasePlugin)) { if (plugin.prototype === undefined) {
throw new Error(`Plugin ${plugin.name} is not a FlipperBasePlugin`); throw new Error(
`Plugin ${pluginDetails.name} is neither a class-based plugin nor a Sandy-based one.
Ensure that it exports either a FlipperPlugin class or has flipper-plugin declared as a peer-dependency and exports a plugin and Component.
See https://fbflipper.com/docs/extending/sandy-migration/ for more information.`,
);
} else if (!(plugin.prototype instanceof FlipperBasePlugin)) {
throw new Error(
`Plugin ${pluginDetails.name} is not a FlipperBasePlugin`,
);
} }
if (plugin.id && pluginDetails.id !== plugin.id) { if (plugin.id && pluginDetails.id !== plugin.id) {