Skip to content

Commit

Permalink
fix: custom component relative urls
Browse files Browse the repository at this point in the history
  • Loading branch information
shanejonas committed Aug 27, 2021
1 parent 5efd58c commit b28b205
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,11 +50,12 @@ interface IComponent {
const getComponentFromConfig = async (componentConfig: TComponentConfig): Promise<IComponent> => {
const { language, name, type} = componentConfig;
let openRPCPath: string | undefined = "src";
if(componentConfig.type === "custom"){
const compModule: IComponentModule = (await import(componentConfig.customComponent)).default;
if(compModule.hooks === undefined) throw new Error("Hooks interface not exported or defined")
openRPCPath = componentConfig.openRPCPath === null ? undefined : componentConfig.openRPCPath || "src" ;
return { hooks: compModule.hooks, staticPath: compModule.staticPath(language, componentConfig.customType), language, name, type, openRPCPath }
if (componentConfig.type === "custom"){
const componentPath = componentConfig.customComponent.startsWith("./") ? path.resolve(process.cwd(), componentConfig.customComponent) : componentConfig.customComponent
const compModule: IComponentModule = (await import(componentPath)).default;
if(compModule.hooks === undefined) throw new Error("Hooks interface not exported or defined")
openRPCPath = componentConfig.openRPCPath === null ? undefined : componentConfig.openRPCPath || "src" ;
return { hooks: compModule.hooks, staticPath: compModule.staticPath(language, componentConfig.customType), language, name, type, openRPCPath }
}
const componentModule = componentModules[type]
return { hooks: componentModule.hooks, staticPath: componentModule.staticPath(language, type), language, name, type, openRPCPath }
Expand Down

0 comments on commit b28b205

Please sign in to comment.