mirror of
https://github.com/LukeHagar/redocly-cli.git
synced 2025-12-09 12:47:48 +00:00
fix: resolve config in browser throws an error (#1699)
This commit is contained in:
committed by
GitHub
parent
732cc75a16
commit
feac9d8acc
5
.changeset/curvy-rivers-itch.md
Normal file
5
.changeset/curvy-rivers-itch.md
Normal file
@@ -0,0 +1,5 @@
|
|||||||
|
---
|
||||||
|
"@redocly/openapi-core": patch
|
||||||
|
---
|
||||||
|
|
||||||
|
Fixed an issue where resolving config in the browser always threw an error.
|
||||||
@@ -117,7 +117,7 @@ function getDefaultPluginPath(configPath: string): string | undefined {
|
|||||||
return pluginPath;
|
return pluginPath;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return undefined;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function resolvePlugins(
|
export async function resolvePlugins(
|
||||||
@@ -128,12 +128,6 @@ export async function resolvePlugins(
|
|||||||
|
|
||||||
// TODO: implement or reuse Resolver approach so it will work in node and browser envs
|
// TODO: implement or reuse Resolver approach so it will work in node and browser envs
|
||||||
const requireFunc = async (plugin: string | Plugin): Promise<ImportedPlugin | undefined> => {
|
const requireFunc = async (plugin: string | Plugin): Promise<ImportedPlugin | undefined> => {
|
||||||
if (isBrowser && isString(plugin)) {
|
|
||||||
logger.error(`Cannot load ${plugin}. Plugins aren't supported in browser yet.`);
|
|
||||||
|
|
||||||
return undefined;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (isString(plugin)) {
|
if (isString(plugin)) {
|
||||||
try {
|
try {
|
||||||
const maybeAbsolutePluginPath = path.resolve(path.dirname(configPath), plugin);
|
const maybeAbsolutePluginPath = path.resolve(path.dirname(configPath), plugin);
|
||||||
@@ -372,7 +366,10 @@ async function resolveAndMergeNestedStyleguideConfig(
|
|||||||
if (parentConfigPaths.includes(configPath)) {
|
if (parentConfigPaths.includes(configPath)) {
|
||||||
throw new Error(`Circular dependency in config file: "${configPath}"`);
|
throw new Error(`Circular dependency in config file: "${configPath}"`);
|
||||||
}
|
}
|
||||||
const plugins = getUniquePlugins(
|
const plugins = isBrowser
|
||||||
|
? // In browser, we don't support plugins from config file yet
|
||||||
|
[defaultPlugin]
|
||||||
|
: getUniquePlugins(
|
||||||
await resolvePlugins([...(styleguideConfig?.plugins || []), defaultPlugin], configPath)
|
await resolvePlugins([...(styleguideConfig?.plugins || []), defaultPlugin], configPath)
|
||||||
);
|
);
|
||||||
const pluginPaths = styleguideConfig?.plugins
|
const pluginPaths = styleguideConfig?.plugins
|
||||||
|
|||||||
Reference in New Issue
Block a user