docusaurus-openapi-docs
docusaurus-openapi-docs copied to clipboard
npm run build fails with custom plugins
If I have a docusaurus.config.js that has:
plugins: [
tailwindPlugin,
webpackPlugin,
[
'docusaurus-plugin-openapi-docs',
....
]
...
npm run build fails with:
[ERROR] TypeError: Cannot read properties of undefined (reading 'endsWith')
at /Users/user/Work//docs/node_modules/docusaurus-plugin-openapi-docs/lib/index.js:31:21
at Array.filter (<anonymous>)
at getDocsPluginConfig (/Users/user/Work//docs/node_modules/docusaurus-plugin-openapi-docs/lib/index.js:28:43)
at Object.pluginOpenAPIDocs [as plugin] (/Users/user/Work//docs/node_modules/docusaurus-plugin-openapi-docs/lib/index.js:73:19)
at initializePlugin (/Users/user/Work//docs/node_modules/@docusaurus/core/lib/server/plugins/init.js:83:61)
at async Promise.all (index 5)
Possible solution
Here https://github.com/PaloAltoNetworks/docusaurus-openapi-docs/blob/main/packages/docusaurus-plugin-openapi-docs/src/index.ts#L33 check if data[0] && data[0].endsWith().
Hi @sradu, thanks for reporting the issue. Can you try wrapping the custom plugins in brackets for now?
[ERROR] Error: => Bad Docusaurus plugin value plugins[0].
Example valid plugin config:
{
plugins: [
["@docusaurus/plugin-content-docs",options],
"./myPlugin",
["./myPlugin",{someOption: 42}],
function myPlugin() { },
[function myPlugin() { },options]
],
};
=> Bad Docusaurus plugin value plugins[1].
Example valid plugin config:
{
plugins: [
["@docusaurus/plugin-content-docs",options],
"./myPlugin",
["./myPlugin",{someOption: 42}],
function myPlugin() { },
[function myPlugin() { },options]
],
};
Oops, yeah I see why that wouldn't work. I think we should be able to detect if the plugin is an Array and if the first index is a string before checking to see if it matches the pluginId.
Hi @sradu, just published a fix in the latest canary release: 0.0.0-496
Appreciate if you can test and report results - thanks!
Seems to be working 👍