@karmaniverous/get-dotenv
    Preparing search index...

    Function loadModuleDefault

    • Load a module default export from a JS/TS file with robust fallbacks.

      Behavior by extension:

      • .js/.mjs/.cjs: direct dynamic import.
      • .ts/.mts/.cts/.tsx:
        • try direct dynamic import (when a TS loader is active),
        • else compile via esbuild to a cached .mjs file and import (the module's own code is bundled; Node built-ins and installed ES module packages stay imports, which Node resolves from the source file),
        • else fallback to typescript.transpileModule for simple modules.

      When every attempt fails, the thrown error's cause is an AggregateError holding the esbuild and TypeScript failures, in that order.

      Compiled builds are cached under .tsbuild/<cacheDirName>/, keeping the newest GETDOTENV_CACHE_KEEP builds per file name (default 2, minimum 1; a value that isn't an integer falls back to 2).

      Type Parameters

      • T

        Type of the expected default export.

      Parameters

      • absPath: string

        Absolute path to the source file.

      • cacheDirName: string

        Cache subfolder under .tsbuild/.

      Returns Promise<T | undefined>

      A Promise\<T | undefined\> resolving to the default export (if any).