fynjs API
    Preparing search index...

    Function makeOptionalImport

    • Make an optional import function bound to the caller's import.meta.

      Type Parameters

      • T = any

      Parameters

      • meta: ImportMetaLike

        import.meta from the caller's context

      • log: LogFunction = defaultLog

        function to log if the module is not found

      Returns OptionalImportFunction<T>

      the optional import function

      const optionalImport = makeOptionalImport(import.meta);

      // undefined only if chalk is NOT INSTALLED -- if chalk is installed but throws or has a
      // missing dependency of its own, that error propagates
      const chalk = await optionalImport("chalk");