import type { PluginObj, PluginPass } from '@babel/core'; export declare const defaultRequireLikeFunctions: readonly ["require", "require.resolve", "System.import", "jest.genMockFromModule", "jest.mock", "jest.unmock", "jest.doMock", "jest.dontMock", "jest.requireActual"]; /** * The shape of the internal state of the Babel plugin itself. * * @internal */ export type State = PluginPass & { opts: Options; }; /** * A callback function provided as a value to `Options.appendExtension` or to an * entry in `Options.replaceExtensions`. */ export type Callback = (context: { /** * The import/export specifier being evaluated by Babel. */ specifier: string; /** * An array of capturing groups returned by `String.prototype.match()` or an * empty array if the matcher string was not a regular expression. */ capturingGroups: string[]; /** * The absolute path of the file containing the specifier being evaluated by * Babel. */ filepath: string; }) => ReturnType; /** * The options that can be passed to this plugin from babel. */ export type Options = { /** * This string will be appended to all relative import specifiers that do not * already have a recognized extension. Also accepts a callback function for * advanced use cases. * * Note that only relative import specifiers (that start with `./` or `../`) * will be considered for `appendExtension`. * * Also note that `replaceExtensions` is evaluated and replacements made * _before_ `appendExtension` is appended to specifiers with unrecognized or * missing extensions. This means an extensionless import specifier could be * rewritten by `replaceExtensions` to have a recognized extension, which * would then be ignored instead of having `appendExtension` appended to it. * * @default undefined */ appendExtension?: string | Callback; /** * Members of this array will be considered a "recognized extension". * * @default defaultRecognizedExtensions */ recognizedExtensions?: string[]; /** * Map of specifiers to their replacements. Specifiers can be strings or * regular expressions (i.e. strings that start with ^ and/or end with $). If * a specifier is a regular expression, capturing group notation can be used * in the replacement. Replacements can either be a string or a callback * function that returns a string. * * Note that `replaceExtensions` is evaluated and replacements made _before_ * `appendExtension` is appended to specifiers with unrecognized or missing * extensions. This means an extensionless import specifier could be rewritten * by `replaceExtensions` to have a recognized extension, which would then be * ignored instead of having `appendExtension` appended to it. * * @default {} */ replaceExtensions?: Record>; /** * Members of this array will be considered as "require-like functions," or * functions that should be treated as if they were CJS `require(...)` (or ESM * `import(...)`) functions. This is useful when, for instance, you want * Jest's `jest.mock` and `jest.requireActual` functions to have their import * specifiers transformed. * * If not overridden, `requireLikeFunctions` defaults to * {@link defaultRequireLikeFunctions}. */ requireLikeFunctions?: string[]; /** * If `'only-if-necessary'`, the dynamic rewriter function will only be * injected into the AST if necessary. If `'never'`, support for arbitrary * dynamic imports that are not statically analyzable will be disabled and no * rewriter function injection will occur. * * @default 'only-if-necessary' */ injectDynamicRewriter?: 'never' | 'only-if-necessary'; /** * If true, this plugin will generate no output. * * @default false */ silent?: boolean; /** * If true, this plugin will generate more output than usual. * * @default false */ verbose?: boolean; }; /** * The default value of `Options.recognizedExtensions`. */ export declare const defaultRecognizedExtensions: readonly [".js", ".jsx", ".mjs", ".cjs", ".json"]; /** * A babel plugin that reliably rewrites import (and export) specifiers. */ export default function transformRewriteImports(): PluginObj;