1 line
33 KiB
Plaintext
1 line
33 KiB
Plaintext
{"version":3,"names":["_path","require","_helperValidatorIdentifier","_helperSplitExportDeclaration","hasExports","metadata","isSideEffectImport","source","imports","size","importsNamespace","reexports","reexportNamespace","reexportAll","validateImportInteropOption","importInterop","Error","resolveImportInterop","filename","normalizeModuleAndLoadMetadata","programPath","exportName","initializeReexports","getWrapperPayload","esNamespaceOnly","scope","generateUidIdentifier","name","stringSpecifiers","Set","nameAnonymousExports","local","sources","getModuleMetadata","removeImportExportDeclarations","nameOfnamespace","resolvedInterop","interop","exportNameListName","getExportSpecifierName","path","isIdentifier","node","isStringLiteral","stringValue","value","isIdentifierName","add","type","assertExportSpecifier","isExportSpecifier","isExportNamespaceSpecifier","buildCodeFrameError","localData","getLocalExportMetadata","importNodes","Map","sourceData","getData","sourceNode","data","get","basename","extname","loc","wrap","lazy","referenced","set","push","forEach","child","isImportDeclaration","spec","isImportDefaultSpecifier","localName","reexport","delete","names","isImportNamespaceSpecifier","isImportSpecifier","importName","isExportAllDeclaration","isExportNamedDeclaration","isExportDefaultDeclaration","values","needsDefault","needsNamed","bindingKindLookup","kind","declaration","isFunctionDeclaration","isClassDeclaration","isVariableDeclaration","Object","keys","getOuterBindingIdentifiers","localMetadata","getLocalMetadata","idPath","undefined","ids","getOuterBindingIdentifierPaths","exported","splitExportDeclaration","remove","_blockHoist","replaceWith"],"sources":["../src/normalize-and-load-metadata.ts"],"sourcesContent":["import { basename, extname } from \"path\";\nimport type * as t from \"@babel/types\";\n\nimport { isIdentifierName } from \"@babel/helper-validator-identifier\";\nimport splitExportDeclaration from \"@babel/helper-split-export-declaration\";\nimport type { NodePath } from \"@babel/traverse\";\n\nexport interface ModuleMetadata {\n exportName: string;\n // The name of the variable that will reference an object containing export names.\n exportNameListName: null | string;\n hasExports: boolean;\n // Lookup from local binding to export information.\n local: Map<string, LocalExportMetadata>;\n // Lookup of source file to source file metadata.\n source: Map<string, SourceModuleMetadata>;\n // List of names that should only be printed as string literals.\n // i.e. `import { \"any unicode\" as foo } from \"some-module\"`\n // `stringSpecifiers` is Set(1) [\"any unicode\"]\n // In most cases `stringSpecifiers` is an empty Set\n stringSpecifiers: Set<string>;\n}\n\nexport type InteropType =\n | \"default\" // Babel interop for default-only imports\n | \"namespace\" // Babel interop for namespace or default+named imports\n | \"node-default\" // Node.js interop for default-only imports\n | \"node-namespace\" // Node.js interop for namespace or default+named imports\n | \"none\"; // No interop, or named-only imports\n\nexport type ImportInterop =\n | \"none\"\n | \"babel\"\n | \"node\"\n | ((source: string, filename?: string) => \"none\" | \"babel\" | \"node\");\n\nexport interface SourceModuleMetadata {\n // A unique variable name to use for this namespace object. Centralized for simplicity.\n name: string;\n loc: t.SourceLocation | undefined | null;\n interop: InteropType;\n // Local binding to reference from this source namespace. Key: Local name, value: Import name\n imports: Map<string, string>;\n // Local names that reference namespace object.\n importsNamespace: Set<string>;\n // Reexports to create for namespace. Key: Export name, value: Import name\n reexports: Map<string, string>;\n // List of names to re-export namespace as.\n reexportNamespace: Set<string>;\n // Tracks if the source should be re-exported.\n reexportAll: null | {\n loc: t.SourceLocation | undefined | null;\n };\n wrap?: unknown;\n referenced: boolean;\n}\n\nexport interface LocalExportMetadata {\n names: Array<string>; // names of exports,\n kind: \"import\" | \"hoisted\" | \"block\" | \"var\";\n}\n\n/**\n * Check if the module has any exports that need handling.\n */\nexport function hasExports(metadata: ModuleMetadata) {\n return metadata.hasExports;\n}\n\n/**\n * Check if a given source is an anonymous import, e.g. \"import 'foo';\"\n */\nexport function isSideEffectImport(source: SourceModuleMetadata) {\n return (\n source.imports.size === 0 &&\n source.importsNamespace.size === 0 &&\n source.reexports.size === 0 &&\n source.reexportNamespace.size === 0 &&\n !source.reexportAll\n );\n}\n\nexport function validateImportInteropOption(\n importInterop: any,\n): importInterop is ImportInterop {\n if (\n typeof importInterop !== \"function\" &&\n importInterop !== \"none\" &&\n importInterop !== \"babel\" &&\n importInterop !== \"node\"\n ) {\n throw new Error(\n `.importInterop must be one of \"none\", \"babel\", \"node\", or a function returning one of those values (received ${importInterop}).`,\n );\n }\n return importInterop;\n}\n\nfunction resolveImportInterop(\n importInterop: ImportInterop,\n source: string,\n filename: string | undefined,\n) {\n if (typeof importInterop === \"function\") {\n return validateImportInteropOption(importInterop(source, filename));\n }\n return importInterop;\n}\n\n/**\n * Remove all imports and exports from the file, and return all metadata\n * needed to reconstruct the module's behavior.\n */\nexport default function normalizeModuleAndLoadMetadata(\n programPath: NodePath<t.Program>,\n exportName: string,\n {\n importInterop,\n initializeReexports = false,\n getWrapperPayload,\n esNamespaceOnly = false,\n filename,\n }: {\n importInterop: ImportInterop;\n initializeReexports: boolean | void;\n getWrapperPayload?: (\n source: string,\n metadata: SourceModuleMetadata,\n importNodes: t.Node[],\n ) => unknown;\n esNamespaceOnly: boolean;\n filename: string;\n },\n): ModuleMetadata {\n if (!exportName) {\n exportName = programPath.scope.generateUidIdentifier(\"exports\").name;\n }\n const stringSpecifiers = new Set<string>();\n\n nameAnonymousExports(programPath);\n\n const { local, sources, hasExports } = getModuleMetadata(\n programPath,\n { initializeReexports, getWrapperPayload },\n stringSpecifiers,\n );\n\n removeImportExportDeclarations(programPath);\n\n // Reuse the imported namespace name if there is one.\n for (const [source, metadata] of sources) {\n const { importsNamespace, imports } = metadata;\n // If there is at least one namespace import and other imports, it may collipse with local ident, can be seen in issue 15879.\n if (importsNamespace.size > 0 && imports.size === 0) {\n const [nameOfnamespace] = importsNamespace;\n metadata.name = nameOfnamespace;\n }\n\n const resolvedInterop = resolveImportInterop(\n importInterop,\n source,\n filename,\n );\n\n if (resolvedInterop === \"none\") {\n metadata.interop = \"none\";\n } else if (resolvedInterop === \"node\" && metadata.interop === \"namespace\") {\n metadata.interop = \"node-namespace\";\n } else if (resolvedInterop === \"node\" && metadata.interop === \"default\") {\n metadata.interop = \"node-default\";\n } else if (esNamespaceOnly && metadata.interop === \"namespace\") {\n // Both the default and namespace interops pass through __esModule\n // objects, but the namespace interop is used to enable Babel's\n // destructuring-like interop behavior for normal CommonJS.\n // Since some tooling has started to remove that behavior, we expose\n // it as the `esNamespace` option.\n metadata.interop = \"default\";\n }\n }\n\n return {\n exportName,\n exportNameListName: null,\n hasExports,\n local,\n source: sources,\n stringSpecifiers,\n };\n}\n\nfunction getExportSpecifierName(\n path: NodePath,\n stringSpecifiers: Set<string>,\n): string {\n if (path.isIdentifier()) {\n return path.node.name;\n } else if (path.isStringLiteral()) {\n const stringValue = path.node.value;\n // add specifier value to `stringSpecifiers` only when it can not be converted to an identifier name\n // i.e In `import { \"foo\" as bar }`\n // we do not consider `\"foo\"` to be a `stringSpecifier` because we can treat it as\n // `import { foo as bar }`\n // This helps minimize the size of `stringSpecifiers` and reduce overhead of checking valid identifier names\n // when building transpiled code from metadata\n if (!isIdentifierName(stringValue)) {\n stringSpecifiers.add(stringValue);\n }\n return stringValue;\n } else {\n throw new Error(\n `Expected export specifier to be either Identifier or StringLiteral, got ${path.node.type}`,\n );\n }\n}\n\nfunction assertExportSpecifier(\n path: NodePath,\n): asserts path is NodePath<t.ExportSpecifier> {\n if (path.isExportSpecifier()) {\n return;\n } else if (path.isExportNamespaceSpecifier()) {\n throw path.buildCodeFrameError(\n \"Export namespace should be first transformed by `@babel/plugin-transform-export-namespace-from`.\",\n );\n } else {\n throw path.buildCodeFrameError(\"Unexpected export specifier type\");\n }\n}\n\n/**\n * Get metadata about the imports and exports present in this module.\n */\nfunction getModuleMetadata(\n programPath: NodePath<t.Program>,\n {\n getWrapperPayload,\n initializeReexports,\n }: {\n getWrapperPayload?: (\n source: string,\n metadata: SourceModuleMetadata,\n importNodes: t.Node[],\n ) => unknown;\n initializeReexports: boolean | void;\n },\n stringSpecifiers: Set<string>,\n) {\n const localData = getLocalExportMetadata(\n programPath,\n initializeReexports,\n stringSpecifiers,\n );\n\n const importNodes = new Map<string, t.Node[]>();\n const sourceData = new Map<string, SourceModuleMetadata>();\n const getData = (sourceNode: t.StringLiteral, node: t.Node) => {\n const source = sourceNode.value;\n\n let data = sourceData.get(source);\n if (!data) {\n data = {\n name: programPath.scope.generateUidIdentifier(\n basename(source, extname(source)),\n ).name,\n\n interop: \"none\",\n\n loc: null,\n\n // Data about the requested sources and names.\n imports: new Map(),\n importsNamespace: new Set(),\n\n // Metadata about data that is passed directly from source to export.\n reexports: new Map(),\n reexportNamespace: new Set(),\n reexportAll: null,\n\n wrap: null,\n\n // @ts-expect-error lazy is not listed in the type.\n // This is needed for compatibility with older version of the commonjs\n // plusing.\n // TODO(Babel 8): Remove this\n get lazy() {\n return this.wrap === \"lazy\";\n },\n\n referenced: false,\n };\n sourceData.set(source, data);\n importNodes.set(source, [node]);\n } else {\n importNodes.get(source).push(node);\n }\n return data;\n };\n let hasExports = false;\n programPath.get(\"body\").forEach(child => {\n if (child.isImportDeclaration()) {\n const data = getData(child.node.source, child.node);\n if (!data.loc) data.loc = child.node.loc;\n\n child.get(\"specifiers\").forEach(spec => {\n if (spec.isImportDefaultSpecifier()) {\n const localName = spec.get(\"local\").node.name;\n\n data.imports.set(localName, \"default\");\n\n const reexport = localData.get(localName);\n if (reexport) {\n localData.delete(localName);\n\n reexport.names.forEach(name => {\n data.reexports.set(name, \"default\");\n });\n data.referenced = true;\n }\n } else if (spec.isImportNamespaceSpecifier()) {\n const localName = spec.get(\"local\").node.name;\n\n data.importsNamespace.add(localName);\n const reexport = localData.get(localName);\n if (reexport) {\n localData.delete(localName);\n\n reexport.names.forEach(name => {\n data.reexportNamespace.add(name);\n });\n data.referenced = true;\n }\n } else if (spec.isImportSpecifier()) {\n const importName = getExportSpecifierName(\n spec.get(\"imported\"),\n stringSpecifiers,\n );\n const localName = spec.get(\"local\").node.name;\n\n data.imports.set(localName, importName);\n\n const reexport = localData.get(localName);\n if (reexport) {\n localData.delete(localName);\n\n reexport.names.forEach(name => {\n data.reexports.set(name, importName);\n });\n data.referenced = true;\n }\n }\n });\n } else if (child.isExportAllDeclaration()) {\n hasExports = true;\n const data = getData(child.node.source, child.node);\n if (!data.loc) data.loc = child.node.loc;\n\n data.reexportAll = {\n loc: child.node.loc,\n };\n data.referenced = true;\n } else if (child.isExportNamedDeclaration() && child.node.source) {\n hasExports = true;\n const data = getData(child.node.source, child.node);\n if (!data.loc) data.loc = child.node.loc;\n\n child.get(\"specifiers\").forEach(spec => {\n assertExportSpecifier(spec);\n const importName = getExportSpecifierName(\n spec.get(\"local\"),\n stringSpecifiers,\n );\n const exportName = getExportSpecifierName(\n spec.get(\"exported\"),\n stringSpecifiers,\n );\n\n data.reexports.set(exportName, importName);\n data.referenced = true;\n\n if (exportName === \"__esModule\") {\n throw spec\n .get(\"exported\")\n .buildCodeFrameError('Illegal export \"__esModule\".');\n }\n });\n } else if (\n child.isExportNamedDeclaration() ||\n child.isExportDefaultDeclaration()\n ) {\n hasExports = true;\n }\n });\n\n for (const metadata of sourceData.values()) {\n let needsDefault = false;\n let needsNamed = false;\n\n if (metadata.importsNamespace.size > 0) {\n needsDefault = true;\n needsNamed = true;\n }\n\n if (metadata.reexportAll) {\n needsNamed = true;\n }\n\n for (const importName of metadata.imports.values()) {\n if (importName === \"default\") needsDefault = true;\n else needsNamed = true;\n }\n for (const importName of metadata.reexports.values()) {\n if (importName === \"default\") needsDefault = true;\n else needsNamed = true;\n }\n\n if (needsDefault && needsNamed) {\n // TODO(logan): Using the namespace interop here is unfortunate. Revisit.\n metadata.interop = \"namespace\";\n } else if (needsDefault) {\n metadata.interop = \"default\";\n }\n }\n\n if (getWrapperPayload) {\n for (const [source, metadata] of sourceData) {\n metadata.wrap = getWrapperPayload(\n source,\n metadata,\n importNodes.get(source),\n );\n }\n }\n\n return {\n hasExports,\n local: localData,\n sources: sourceData,\n };\n}\n\ntype ModuleBindingKind = \"import\" | \"hoisted\" | \"block\" | \"var\";\n/**\n * Get metadata about local variables that are exported.\n */\nfunction getLocalExportMetadata(\n programPath: NodePath<t.Program>,\n initializeReexports: boolean | void,\n stringSpecifiers: Set<string>,\n): Map<string, LocalExportMetadata> {\n const bindingKindLookup = new Map();\n\n programPath.get(\"body\").forEach((child: NodePath) => {\n let kind: ModuleBindingKind;\n if (child.isImportDeclaration()) {\n kind = \"import\";\n } else {\n if (child.isExportDefaultDeclaration()) {\n child = child.get(\"declaration\");\n }\n if (child.isExportNamedDeclaration()) {\n if (child.node.declaration) {\n child = child.get(\"declaration\");\n } else if (\n initializeReexports &&\n child.node.source &&\n child.get(\"source\").isStringLiteral()\n ) {\n child.get(\"specifiers\").forEach(spec => {\n assertExportSpecifier(spec);\n bindingKindLookup.set(spec.get(\"local\").node.name, \"block\");\n });\n return;\n }\n }\n\n if (child.isFunctionDeclaration()) {\n kind = \"hoisted\";\n } else if (child.isClassDeclaration()) {\n kind = \"block\";\n } else if (child.isVariableDeclaration({ kind: \"var\" })) {\n kind = \"var\";\n } else if (child.isVariableDeclaration()) {\n kind = \"block\";\n } else {\n return;\n }\n }\n\n Object.keys(child.getOuterBindingIdentifiers()).forEach(name => {\n bindingKindLookup.set(name, kind);\n });\n });\n\n const localMetadata = new Map();\n const getLocalMetadata = (idPath: NodePath<t.Identifier>) => {\n const localName = idPath.node.name;\n let metadata = localMetadata.get(localName);\n\n if (!metadata) {\n const kind = bindingKindLookup.get(localName);\n\n if (kind === undefined) {\n throw idPath.buildCodeFrameError(\n `Exporting local \"${localName}\", which is not declared.`,\n );\n }\n\n metadata = {\n names: [],\n kind,\n };\n localMetadata.set(localName, metadata);\n }\n return metadata;\n };\n\n programPath.get(\"body\").forEach(child => {\n if (\n child.isExportNamedDeclaration() &&\n (initializeReexports || !child.node.source)\n ) {\n if (child.node.declaration) {\n const declaration = child.get(\"declaration\");\n const ids = declaration.getOuterBindingIdentifierPaths();\n Object.keys(ids).forEach(name => {\n if (name === \"__esModule\") {\n throw declaration.buildCodeFrameError(\n 'Illegal export \"__esModule\".',\n );\n }\n getLocalMetadata(ids[name]).names.push(name);\n });\n } else {\n child.get(\"specifiers\").forEach(spec => {\n const local = spec.get(\"local\");\n const exported = spec.get(\"exported\");\n const localMetadata = getLocalMetadata(local);\n const exportName = getExportSpecifierName(exported, stringSpecifiers);\n\n if (exportName === \"__esModule\") {\n throw exported.buildCodeFrameError('Illegal export \"__esModule\".');\n }\n localMetadata.names.push(exportName);\n });\n }\n } else if (child.isExportDefaultDeclaration()) {\n const declaration = child.get(\"declaration\");\n if (\n declaration.isFunctionDeclaration() ||\n declaration.isClassDeclaration()\n ) {\n getLocalMetadata(declaration.get(\"id\")).names.push(\"default\");\n } else {\n // These should have been removed by the nameAnonymousExports() call.\n throw declaration.buildCodeFrameError(\n \"Unexpected default expression export.\",\n );\n }\n }\n });\n return localMetadata;\n}\n\n/**\n * Ensure that all exported values have local binding names.\n */\nfunction nameAnonymousExports(programPath: NodePath<t.Program>) {\n // Name anonymous exported locals.\n programPath.get(\"body\").forEach(child => {\n if (!child.isExportDefaultDeclaration()) return;\n splitExportDeclaration(child);\n });\n}\n\nfunction removeImportExportDeclarations(programPath: NodePath<t.Program>) {\n programPath.get(\"body\").forEach(child => {\n if (child.isImportDeclaration()) {\n child.remove();\n } else if (child.isExportNamedDeclaration()) {\n if (child.node.declaration) {\n // @ts-expect-error todo(flow->ts): avoid mutations\n child.node.declaration._blockHoist = child.node._blockHoist;\n child.replaceWith(child.node.declaration);\n } else {\n child.remove();\n }\n } else if (child.isExportDefaultDeclaration()) {\n // export default foo;\n const declaration = child.get(\"declaration\");\n if (\n declaration.isFunctionDeclaration() ||\n declaration.isClassDeclaration()\n ) {\n // @ts-expect-error todo(flow->ts): avoid mutations\n declaration._blockHoist = child.node._blockHoist;\n child.replaceWith(declaration);\n } else {\n // These should have been removed by the nameAnonymousExports() call.\n throw declaration.buildCodeFrameError(\n \"Unexpected default expression export.\",\n );\n }\n } else if (child.isExportAllDeclaration()) {\n child.remove();\n }\n });\n}\n"],"mappings":";;;;;;;;;AAAA,IAAAA,KAAA,GAAAC,OAAA;AAGA,IAAAC,0BAAA,GAAAD,OAAA;AACA,IAAAE,6BAAA,GAAAF,OAAA;AA6DO,SAASG,UAAUA,CAACC,QAAwB,EAAE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