node-cooper - v0.2.0
    Preparing search index...

    Class ModuleRef

    The value of a !module("Name") tagged value (CASC.md ยง7.5) -- a reference to a Node module, by the name the config wrote and the target the application's modules load option maps that name to:

    client = !module("Acme.Payments.StripeClient")
    formatter = !module("${LOG_FORMATTER}")
    
    loadFileSync('config/app.casc', {
    modules: { 'Acme.Payments.StripeClient': './lib/payments/stripe.js' },
    });

    The reference implementation translates a name into an Elixir module by convention. A Node module is a location, not a name, so there is no convention to translate into here: every name comes from the mapping.

    Loading a config never imports anything. A mapping value that is a specifier string is kept in specifier (a .//../ one resolved to an absolute path against process.cwd(), since the mapping is application code, not part of the config file) and imported by load() when, and if, the application asks. Any other mapping value -- an already-imported module or a class -- is kept in value and handed back by load().

    Index
    • Parameters

      • name: string

        the name as written in the config, trimmed

      • target: unknown

        what the modules mapping holds for name: a specifier string, or the module itself

      • Optionalbase: string = ...

        directory a relative specifier is resolved against (default process.cwd())

      Returns ModuleRef

    name: string

    The name as written in the config (after trimming).

    specifier: string | undefined

    What load() imports, when the mapping held a specifier: an absolute path for a relative specifier, otherwise the specifier unchanged. undefined when the mapping held the module itself.

    value: unknown

    The module the mapping held, when it was not a specifier string; undefined otherwise.

    • Equal when the name and the target are the same: the same resolved specifier, or the very same provided value.

      Parameters

      • other: unknown

      Returns boolean

    • The module: a specifier is imported now (dynamic import()), a provided value is handed back as is.

      Returns Promise<any>

      the module namespace object, or the provided value

    • Returns why name is not an acceptable module name, or null when it is. name is taken as is: !module trims it first.

      Parameters

      • name: unknown

      Returns string | null