UNPKG

@cloud-copilot/iam-lens

Version:

Visibility in IAM in and across AWS accounts

31 lines 1.71 kB
/** * Normalize a module namespace object so that named exports are accessible as * top-level properties regardless of whether the underlying module is ESM or * CJS. When `import()` loads a CJS module the entire `module.exports` object * is placed on the `default` property of the namespace, so this helper merges * `default` back into the top level. * * @param mod - The raw module namespace returned by `import()` or `require()`. * @returns A flat record with all named exports accessible as top-level keys. */ export declare function normalizeModule(mod: Record<string, unknown>): Record<string, unknown>; /** * Dynamically load a module by name or path, handling both ESM and CJS * runtime contexts and both ESM and CJS target modules. * * Resolution strategy: * 1. Try a bare `import()` first — this works when the module is resolvable * from the current file (e.g. it is a direct dependency) or when a bundler / * test runner (vitest, etc.) intercepts module resolution. * 2. If that fails with a "not found" error, fall back to `createRequire` * rooted at `process.cwd()`. This handles the case where the plugin package * lives in the consuming project's `node_modules` rather than iam-lens's * own. `createRequire` works in both ESM and CJS contexts and always uses * the CJS resolution algorithm, which reliably finds packages regardless of * the caller's module type. * * @param modulePath - Package name or absolute path to import. * @returns The exports object of the imported module with normalised keys. */ export declare function dynamicImport(modulePath: string): Promise<Record<string, unknown>>; //# sourceMappingURL=dynamicImport.d.ts.map