import type { Binding, NodePath, Scope } from '@babel/traverse'; import * as t from '@babel/types'; /** * Example: `__webpack_require__(id)` */ interface RequireCall { path: NodePath; moduleId: string; } /** * Example: `var foo = __webpack_require__(id);` */ interface RequireVar { binding: Binding; moduleId: string; defaultImport?: t.ImportDefaultSpecifier; namespaceImport?: t.ImportNamespaceSpecifier; namedImports: t.ImportSpecifier[]; namespaceExports: t.ExportNamespaceSpecifier[]; namedExports: t.ExportSpecifier[]; } export declare class ImportExportManager { /** * All module ids that are imported */ imports: Set; /** * Names of all exports */ exports: Set; /** * All `var foo = __webpack_require__(id);` variable declarations */ requireVars: RequireVar[]; /** * All `__webpack_require__(id)` calls */ requireCalls: RequireCall[]; webpackRequire: Binding | undefined; private ast; constructor(ast: t.File, webpackRequireBinding: Binding | undefined); insertImportsAndExports(resolve: (moduleId: string) => string): void; private sortImportSpecifiers; private collectImports; addExport(scope: Scope, exportName: string, value: t.Expression): void; /** * Find the `var = __webpack_require__();` statement that belongs to a binding node */ findRequireVar(node: t.Node): RequireVar | undefined; /** * @returns local name of the default import */ addDefaultImport(requireVar: RequireVar): string; private addNamedImport; private addNamespaceImport; /** * Example: * ```js * __webpack_require__.d(exports, { foo: () => lib.bar }); * var lib = __webpack_require__("lib"); * ``` * to * ```js * export { bar as foo } from 'lib'; * ``` */ private addExportFrom; /** * Example: * ```js * __webpack_require__.d(exports, { counter: () => foo }); * var foo = 1; * ``` * to * ```js * export var counter = 1; * ``` */ private addExportDeclaration; /** * Example: * ```js * __webpack_require__.d(exports, { default: () => foo }); * var foo = 1; * ``` * to * ```js * export default 1; * ``` */ private addExportDefault; /** * Example: * ```js * __webpack_require__.d(exports, { foo: () => lib }); * var lib = __webpack_require__("lib"); * ``` * to * ```js * export * as foo from 'lib'; * ``` */ private addExportNamespace; /** * Finds all `__webpack_require__(id)` and `var foo = __webpack_require__(id);` calls */ private collectRequireCalls; } export {}; //# sourceMappingURL=import-export-manager.d.ts.map