mirror of
https://github.com/facebook/docusaurus.git
synced 2025-06-07 13:22:26 +02:00
feat(core): give more hints when plugins have duplicate IDs (#5899)
This commit is contained in:
parent
1c024470e0
commit
eab8c7c010
2 changed files with 17 additions and 7 deletions
|
@ -1,16 +1,20 @@
|
||||||
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
||||||
|
|
||||||
exports[`ensureUniquePluginInstanceIds reject multi instance plugins with same id 1`] = `
|
exports[`ensureUniquePluginInstanceIds reject multi instance plugins with same id 1`] = `
|
||||||
"Plugin \\"plugin-docs\\" is used 2 times with id sameId.
|
"Plugin \\"plugin-docs\\" is used 2 times with ID \\"sameId\\".
|
||||||
To use the same plugin multiple times on a Docusaurus site, you need to assign a unique id to each plugin instance."
|
To use the same plugin multiple times on a Docusaurus site, you need to assign a unique ID to each plugin instance."
|
||||||
`;
|
`;
|
||||||
|
|
||||||
exports[`ensureUniquePluginInstanceIds reject multi instance plugins without id 1`] = `
|
exports[`ensureUniquePluginInstanceIds reject multi instance plugins without id 1`] = `
|
||||||
"Plugin \\"plugin-docs\\" is used 2 times with id default.
|
"Plugin \\"plugin-docs\\" is used 2 times with ID \\"default\\".
|
||||||
To use the same plugin multiple times on a Docusaurus site, you need to assign a unique id to each plugin instance."
|
To use the same plugin multiple times on a Docusaurus site, you need to assign a unique ID to each plugin instance.
|
||||||
|
|
||||||
|
The plugin ID is \\"default\\" by default. It's possible that the preset you are using already includes a plugin instance, in which case you either want to disable the plugin in the preset (to use a single instance), or assign another ID to your extra plugin instance (to use multiple instances)."
|
||||||
`;
|
`;
|
||||||
|
|
||||||
exports[`ensureUniquePluginInstanceIds reject multi instance plugins without id 2`] = `
|
exports[`ensureUniquePluginInstanceIds reject multi instance plugins without id 2`] = `
|
||||||
"Plugin \\"plugin-docs\\" is used 2 times with id default.
|
"Plugin \\"plugin-docs\\" is used 2 times with ID \\"default\\".
|
||||||
To use the same plugin multiple times on a Docusaurus site, you need to assign a unique id to each plugin instance."
|
To use the same plugin multiple times on a Docusaurus site, you need to assign a unique ID to each plugin instance.
|
||||||
|
|
||||||
|
The plugin ID is \\"default\\" by default. It's possible that the preset you are using already includes a plugin instance, in which case you either want to disable the plugin in the preset (to use a single instance), or assign another ID to your extra plugin instance (to use multiple instances)."
|
||||||
`;
|
`;
|
||||||
|
|
|
@ -24,7 +24,13 @@ export function ensureUniquePluginInstanceIds(
|
||||||
([pluginId, pluginInstancesWithId]) => {
|
([pluginId, pluginInstancesWithId]) => {
|
||||||
if (pluginInstancesWithId.length !== 1) {
|
if (pluginInstancesWithId.length !== 1) {
|
||||||
throw new Error(
|
throw new Error(
|
||||||
`Plugin "${pluginName}" is used ${pluginInstancesWithId.length} times with id ${pluginId}.\nTo use the same plugin multiple times on a Docusaurus site, you need to assign a unique id to each plugin instance.`,
|
`Plugin "${pluginName}" is used ${
|
||||||
|
pluginInstancesWithId.length
|
||||||
|
} times with ID "${pluginId}".\nTo use the same plugin multiple times on a Docusaurus site, you need to assign a unique ID to each plugin instance.${
|
||||||
|
pluginId === DEFAULT_PLUGIN_ID
|
||||||
|
? `\n\nThe plugin ID is "${DEFAULT_PLUGIN_ID}" by default. It's possible that the preset you are using already includes a plugin instance, in which case you either want to disable the plugin in the preset (to use a single instance), or assign another ID to your extra plugin instance (to use multiple instances).`
|
||||||
|
: ''
|
||||||
|
}`,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue