1 line
15 KiB
Plaintext
1 line
15 KiB
Plaintext
|
{"version":3,"names":["isClassDeclaration","isExportDefaultSpecifier","isExportNamespaceSpecifier","isImportDefaultSpecifier","isImportNamespaceSpecifier","isStatement","ImportSpecifier","node","importKind","word","space","print","imported","local","name","ImportDefaultSpecifier","ExportDefaultSpecifier","exported","ExportSpecifier","exportKind","ExportNamespaceSpecifier","token","_printAssertions","printList","assertions","ExportAllDeclaration","length","source","semicolon","ExportNamedDeclaration","format","decoratorsBeforeExport","declaration","printJoin","decorators","declar","specifiers","slice","hasSpecial","first","shift","ExportDefaultDeclaration","noIndentInnerCommentsHere","ImportDeclaration","isTypeKind","module","hasSpecifiers","attributes","ImportAttribute","key","value","ImportNamespaceSpecifier"],"sources":["../../src/generators/modules.ts"],"sourcesContent":["import type Printer from \"../printer\";\nimport {\n isClassDeclaration,\n isExportDefaultSpecifier,\n isExportNamespaceSpecifier,\n isImportDefaultSpecifier,\n isImportNamespaceSpecifier,\n isStatement,\n} from \"@babel/types\";\nimport type * as t from \"@babel/types\";\n\nexport function ImportSpecifier(this: Printer, node: t.ImportSpecifier) {\n if (node.importKind === \"type\" || node.importKind === \"typeof\") {\n this.word(node.importKind);\n this.space();\n }\n\n this.print(node.imported, node);\n // @ts-expect-error todo(flow-ts) maybe check node type instead of relying on name to be undefined on t.StringLiteral\n if (node.local && node.local.name !== node.imported.name) {\n this.space();\n this.word(\"as\");\n this.space();\n this.print(node.local, node);\n }\n}\n\nexport function ImportDefaultSpecifier(\n this: Printer,\n node: t.ImportDefaultSpecifier,\n) {\n this.print(node.local, node);\n}\n\nexport function ExportDefaultSpecifier(\n this: Printer,\n node: t.ExportDefaultSpecifier,\n) {\n this.print(node.exported, node);\n}\n\nexport function ExportSpecifier(this: Printer, node: t.ExportSpecifier) {\n if (node.exportKind === \"type\") {\n this.word(\"type\");\n this.space();\n }\n\n this.print(node.local, node);\n // @ts-expect-error todo(flow-ts) maybe check node type instead of relying on name to be undefined on t.StringLiteral\n if (node.exported && node.local.name !== node.exported.name) {\n this.space();\n this.word(\"as\");\n this.space();\n this.print(node.exported, node);\n }\n}\n\nexport function ExportNamespaceSpecifier(\n this: Printer,\n node: t.ExportNamespaceSpecifier,\n) {\n this.token(\"*\");\n this.space();\n this.word(\"as\");\n this.space();\n this.print(node.exported, node);\n}\n\nexport function _printAssertions(\n this: Printer,\n node: Extract<t.Node, { assertions?: t.ImportAttribute[] }>,\n) {\n this.word(\"assert\");\n this.space();\n this.token(\"{\");\n this.space();\n this.printList(node.assertions, node);\n this.space();\n this.token(\"}\");\n}\n\nexport function ExportAllDeclaration(\n this: Printer,\n node: t.ExportAllDeclaration | t.DeclareExportAllDeclaration,\n) {\n this.word(\"export\");\n this.space();\n if (node.exportKind === \"type\") {\n this.word(\"type\");\n this.space();\n }\n this.token(\"*\");\n this.space();\n this.word(\"from\");\n this.space();\n // @ts-expect-error Fixme: assertions is not defined in DeclareExportAllDeclaration\n if (node.assertions?.length) {\n this.print(node.source, node, true);\n this.space();\n // @ts-expect-error Fixme: assertions is not defined in DeclareExportAllDeclaration\n this._printAssertions(node);\n } else {\n this.print(node.source, node);\n }\n\n this.semicolon();\n}\n\nexport function ExportNamedDeclaration(\n this: Printer,\n node: t.ExportNamedDeclaration,\n) {\n if (!process.env.BABEL_8_BREAKING) {\n if (\n this.format.decoratorsBeforeExport &&\n isClassDeclaration(node.declaration)\n ) {\n this.printJoin(node.declaration.decorators, node);\n }\n }\n\n this.word(\"export\");\n this.space();\n if (node.declarat
|