diff --git a/packages/xarc-render-context/package.json b/packages/xarc-render-context/package.json index b79a52521..7f3170bef 100644 --- a/packages/xarc-render-context/package.json +++ b/packages/xarc-render-context/package.json @@ -59,7 +59,7 @@ ], "dependencies": { "munchy": "^1.0.9", - "optional-require": "^1.0.2", + "optional-require": "^1.1.4", "require-at": "^1.0.6", "xaa": "^1.5.0" }, diff --git a/packages/xarc-render-context/src/load-handler.ts b/packages/xarc-render-context/src/load-handler.ts index 7c37c2290..999714449 100644 --- a/packages/xarc-render-context/src/load-handler.ts +++ b/packages/xarc-render-context/src/load-handler.ts @@ -5,29 +5,26 @@ import * as Path from "path"; import * as requireAt from "require-at"; -import * as optionalRequire from "optional-require"; +import { makeOptionalRequire } from "optional-require"; const failLoadTokenModule = (msg: string, err: Error) => { console.error(`error: @xarc/render-context failed to load token process module ${msg}`, err); return () => ({ - process: () => `\n@xarc/render-context: token process module ${msg} failed to load\n` + process: () => `\n@xarc/render-context: token process module ${msg} failed to load\n`, }); }; const notFoundLoadTokenModule = (msg: string, err: Error) => { - console.error( - `error: @xarc/render-context can't find token process module ${msg}`, - err - ); + console.error(`error: @xarc/render-context can't find token process module ${msg}`, err); return () => ({ - process: () => `\n@xarc/render-context: token process module ${msg} not found\n` + process: () => `\n@xarc/render-context: token process module ${msg} not found\n`, }); }; export const loadTokenModuleHandler = (path: string, templateDir?: string, customCall?: string) => { - const tokenMod = optionalRequire(requireAt(Path.resolve(templateDir || "")))(path, { + const tokenMod: any = makeOptionalRequire(requireAt(Path.resolve(templateDir || "")))(path, { fail: (e: Error) => failLoadTokenModule(path, e), - notFound: (e: Error) => notFoundLoadTokenModule(path, e) + notFound: (e: Error) => notFoundLoadTokenModule(path, e), }); if (typeof tokenMod === "function") { return tokenMod;