You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
1 line
30 KiB
1 line
30 KiB
{"version":3,"names":["_assert","require","_t","_importBuilder","_isModule","identifier","importSpecifier","numericLiteral","sequenceExpression","isImportDeclaration","ImportInjector","constructor","path","importedSource","opts","_defaultOpts","importedType","importedInterop","importingInterop","ensureLiveReference","ensureNoContext","importPosition","programPath","find","p","isProgram","_programPath","_programScope","scope","_hub","hub","_applyDefaults","addDefault","importedSourceIn","addNamed","importName","assert","_generateImport","addNamespace","addSideEffect","isInit","newOpts","Object","assign","nameHint","undefined","blockHoist","isDefault","isNamed","isNamespace","name","isMod","isModule","isModuleForNode","isModuleForBabel","Error","builder","ImportBuilder","import","namespace","named","es6Default","default","var","wildcardInterop","defaultInterop","read","prop","statements","resultName","done","_insertStatements","type","_insertStatementsAfter","_insertStatementsBefore","unshiftContainer","length","isValueImport","firstImportDecl","get","node","source","value","maybeAppendImportSpecifiers","forEach","_blockHoist","targetPath","val","Number","isFinite","insertBefore","statementsSet","Set","importDeclarations","Map","statement","has","set","push","lastImportPath","bodyStmt","newImports","decl","delete","size","insertAfter","Array","from","exports","importKind","hasNamespaceImport","specifiers","hasDefaultImport","target","local","unshift","shift"],"sources":["../src/import-injector.ts"],"sourcesContent":["import assert from \"assert\";\nimport {\n identifier,\n importSpecifier,\n numericLiteral,\n sequenceExpression,\n isImportDeclaration,\n} from \"@babel/types\";\nimport type * as t from \"@babel/types\";\nimport type { NodePath, Scope, HubInterface } from \"@babel/traverse\";\n\nimport ImportBuilder from \"./import-builder.ts\";\nimport isModule from \"./is-module.ts\";\n\nexport type ImportOptions = {\n /**\n * The module being referenced.\n */\n importedSource: string | null;\n /**\n * The type of module being imported:\n *\n * * 'es6' - An ES6 module.\n * * 'commonjs' - A CommonJS module. (Default)\n */\n importedType: \"es6\" | \"commonjs\";\n /**\n * The type of interop behavior for namespace/default/named when loading\n * CommonJS modules.\n *\n * ## 'babel' (Default)\n *\n * Load using Babel's interop.\n *\n * If '.__esModule' is true, treat as 'compiled', else:\n *\n * * Namespace: A copy of the module.exports with .default\n * populated by the module.exports object.\n * * Default: The module.exports value.\n * * Named: The .named property of module.exports.\n *\n * The 'ensureLiveReference' has no effect on the liveness of these.\n *\n * ## 'compiled'\n *\n * Assume the module is ES6 compiled to CommonJS. Useful to avoid injecting\n * interop logic if you are confident that the module is a certain format.\n *\n * * Namespace: The root module.exports object.\n * * Default: The .default property of the namespace.\n * * Named: The .named property of the namespace.\n *\n * Will return erroneous results if the imported module is _not_ compiled\n * from ES6 with Babel.\n *\n * ## 'uncompiled'\n *\n * Assume the module is _not_ ES6 compiled to CommonJS. Used a simplified\n * access pattern that doesn't require additional function calls.\n *\n * Will return erroneous results if the imported module _is_ compiled\n * from ES6 with Babel.\n *\n * * Namespace: The module.exports object.\n * * Default: The module.exports object.\n * * Named: The .named property of module.exports.\n */\n importedInterop: \"babel\" | \"node\" | \"compiled\" | \"uncompiled\";\n /**\n * The type of CommonJS interop included in the environment that will be\n * loading the output code.\n *\n * * 'babel' - CommonJS modules load with Babel's interop. (Default)\n * * 'node' - CommonJS modules load with Node's interop.\n *\n * See descriptions in 'importedInterop' for more details.\n */\n importingInterop: \"babel\" | \"node\";\n /**\n * Define whether we explicitly care that the import be a live reference.\n * Only applies when importing default and named imports, not the namespace.\n *\n * * true - Force imported values to be live references.\n * * false - No particular requirements. Keeps the code simplest. (Default)\n */\n ensureLiveReference: boolean;\n /**\n * Define if we explicitly care that the result not be a property reference.\n *\n * * true - Force calls to exclude context. Useful if the value is going to\n * be used as function callee.\n * * false - No particular requirements for context of the access. (Default)\n */\n ensureNoContext: boolean;\n /**\n * Define whether the import should be loaded before or after the existing imports.\n * \"after\" is only allowed inside ECMAScript modules, since it's not possible to\n * reliably pick the location _after_ require() calls but _before_ other code in CJS.\n */\n importPosition: \"before\" | \"after\";\n\n nameHint?: string;\n blockHoist?: number;\n};\n\n/**\n * A general helper classes add imports via transforms. See README for usage.\n */\nexport default class ImportInjector {\n /**\n * The path used for manipulation.\n */\n declare _programPath: NodePath<t.Program>;\n\n /**\n * The scope used to generate unique variable names.\n */\n declare _programScope: Scope;\n\n /**\n * The file used to inject helpers and resolve paths.\n */\n declare _hub: HubInterface;\n\n /**\n * The default options to use with this instance when imports are added.\n */\n _defaultOpts: ImportOptions = {\n importedSource: null,\n importedType: \"commonjs\",\n importedInterop: \"babel\",\n importingInterop: \"babel\",\n ensureLiveReference: false,\n ensureNoContext: false,\n importPosition: \"before\",\n };\n\n constructor(\n path: NodePath,\n importedSource?: string,\n opts?: Partial<ImportOptions>,\n ) {\n const programPath = path.find(p => p.isProgram()) as NodePath<t.Program>;\n\n this._programPath = programPath;\n this._programScope = programPath.scope;\n this._hub = programPath.hub;\n\n this._defaultOpts = this._applyDefaults(importedSource, opts, true);\n }\n\n addDefault(importedSourceIn: string, opts: Partial<ImportOptions>) {\n return this.addNamed(\"default\", importedSourceIn, opts);\n }\n\n addNamed(\n importName: string,\n importedSourceIn: string,\n opts: Partial<ImportOptions>,\n ) {\n assert(typeof importName === \"string\");\n\n return this._generateImport(\n this._applyDefaults(importedSourceIn, opts),\n importName,\n );\n }\n\n addNamespace(importedSourceIn: string, opts: Partial<ImportOptions>) {\n return this._generateImport(\n this._applyDefaults(importedSourceIn, opts),\n null,\n );\n }\n\n addSideEffect(importedSourceIn: string, opts: Partial<ImportOptions>) {\n return this._generateImport(\n this._applyDefaults(importedSourceIn, opts),\n void 0,\n );\n }\n\n _applyDefaults(\n importedSource: string | Partial<ImportOptions>,\n opts: Partial<ImportOptions> | undefined,\n isInit = false,\n ) {\n let newOpts: ImportOptions;\n if (typeof importedSource === \"string\") {\n newOpts = { ...this._defaultOpts, importedSource, ...opts };\n } else {\n assert(!opts, \"Unexpected secondary arguments.\");\n newOpts = { ...this._defaultOpts, ...importedSource };\n }\n\n if (!isInit && opts) {\n if (opts.nameHint !== undefined) newOpts.nameHint = opts.nameHint;\n if (opts.blockHoist !== undefined) newOpts.blockHoist = opts.blockHoist;\n }\n return newOpts;\n }\n\n _generateImport(\n opts: Partial<ImportOptions>,\n importName: string | null | undefined,\n ) {\n const isDefault = importName === \"default\";\n const isNamed = !!importName && !isDefault;\n const isNamespace = importName === null;\n\n const {\n importedSource,\n importedType,\n importedInterop,\n importingInterop,\n ensureLiveReference,\n ensureNoContext,\n nameHint,\n importPosition,\n\n // Not meant for public usage. Allows code that absolutely must control\n // ordering to set a specific hoist value on the import nodes.\n // This is ignored when \"importPosition\" is \"after\".\n blockHoist,\n } = opts;\n\n // Provide a hint for generateUidIdentifier for the local variable name\n // to use for the import, if the code will generate a simple assignment\n // to a variable.\n let name = nameHint || importName;\n\n const isMod = isModule(this._programPath);\n const isModuleForNode = isMod && importingInterop === \"node\";\n const isModuleForBabel = isMod && importingInterop === \"babel\";\n\n if (importPosition === \"after\" && !isMod) {\n throw new Error(`\"importPosition\": \"after\" is only supported in modules`);\n }\n\n const builder = new ImportBuilder(\n importedSource,\n this._programScope,\n this._hub,\n );\n\n if (importedType === \"es6\") {\n if (!isModuleForNode && !isModuleForBabel) {\n throw new Error(\"Cannot import an ES6 module from CommonJS\");\n }\n\n // import * as namespace from ''; namespace\n // import def from ''; def\n // import { named } from ''; named\n builder.import();\n if (isNamespace) {\n builder.namespace(nameHint || importedSource);\n } else if (isDefault || isNamed) {\n builder.named(name, importName);\n }\n } else if (importedType !== \"commonjs\") {\n throw new Error(`Unexpected interopType \"${importedType}\"`);\n } else if (importedInterop === \"babel\") {\n if (isModuleForNode) {\n // import _tmp from ''; var namespace = interopRequireWildcard(_tmp); namespace\n // import _tmp from ''; var def = interopRequireDefault(_tmp).default; def\n // import _tmp from ''; _tmp.named\n name = name !== \"default\" ? name : importedSource;\n const es6Default = `${importedSource}$es6Default`;\n\n builder.import();\n if (isNamespace) {\n builder\n .default(es6Default)\n .var(name || importedSource)\n .wildcardInterop();\n } else if (isDefault) {\n if (ensureLiveReference) {\n builder\n .default(es6Default)\n .var(name || importedSource)\n .defaultInterop()\n .read(\"default\");\n } else {\n builder\n .default(es6Default)\n .var(name)\n .defaultInterop()\n .prop(importName);\n }\n } else if (isNamed) {\n builder.default(es6Default).read(importName);\n }\n } else if (isModuleForBabel) {\n // import * as namespace from ''; namespace\n // import def from ''; def\n // import { named } from ''; named\n builder.import();\n if (isNamespace) {\n builder.namespace(name || importedSource);\n } else if (isDefault || isNamed) {\n builder.named(name, importName);\n }\n } else {\n // var namespace = interopRequireWildcard(require(''));\n // var def = interopRequireDefault(require('')).default; def\n // var named = require('').named; named\n builder.require();\n if (isNamespace) {\n builder.var(name || importedSource).wildcardInterop();\n } else if ((isDefault || isNamed) && ensureLiveReference) {\n if (isDefault) {\n name = name !== \"default\" ? name : importedSource;\n builder.var(name).read(importName);\n builder.defaultInterop();\n } else {\n builder.var(importedSource).read(importName);\n }\n } else if (isDefault) {\n builder.var(name).defaultInterop().prop(importName);\n } else if (isNamed) {\n builder.var(name).prop(importName);\n }\n }\n } else if (importedInterop === \"compiled\") {\n if (isModuleForNode) {\n // import namespace from ''; namespace\n // import namespace from ''; namespace.default\n // import namespace from ''; namespace.named\n\n builder.import();\n if (isNamespace) {\n builder.default(name || importedSource);\n } else if (isDefault || isNamed) {\n builder.default(importedSource).read(name);\n }\n } else if (isModuleForBabel) {\n // import * as namespace from ''; namespace\n // import def from ''; def\n // import { named } from ''; named\n // Note: These lookups will break if the module has no __esModule set,\n // hence the warning that 'compiled' will not work on standard CommonJS.\n\n builder.import();\n if (isNamespace) {\n builder.namespace(name || importedSource);\n } else if (isDefault || isNamed) {\n builder.named(name, importName);\n }\n } else {\n // var namespace = require(''); namespace\n // var namespace = require(''); namespace.default\n // var namespace = require(''); namespace.named\n // var named = require('').named;\n builder.require();\n if (isNamespace) {\n builder.var(name || importedSource);\n } else if (isDefault || isNamed) {\n if (ensureLiveReference) {\n builder.var(importedSource).read(name);\n } else {\n builder.prop(importName).var(name);\n }\n }\n }\n } else if (importedInterop === \"uncompiled\") {\n if (isDefault && ensureLiveReference) {\n throw new Error(\"No live reference for commonjs default\");\n }\n\n if (isModuleForNode) {\n // import namespace from ''; namespace\n // import def from ''; def;\n // import namespace from ''; namespace.named\n builder.import();\n if (isNamespace) {\n builder.default(name || importedSource);\n } else if (isDefault) {\n builder.default(name);\n } else if (isNamed) {\n builder.default(importedSource).read(name);\n }\n } else if (isModuleForBabel) {\n // import namespace from '';\n // import def from '';\n // import { named } from ''; named;\n // Note: These lookups will break if the module has __esModule set,\n // hence the warning that 'uncompiled' will not work on ES6 transpiled\n // to CommonJS.\n\n builder.import();\n if (isNamespace) {\n builder.default(name || importedSource);\n } else if (isDefault) {\n builder.default(name);\n } else if (isNamed) {\n builder.named(name, importName);\n }\n } else {\n // var namespace = require(''); namespace\n // var def = require(''); def\n // var namespace = require(''); namespace.named\n // var named = require('').named;\n builder.require();\n if (isNamespace) {\n builder.var(name || importedSource);\n } else if (isDefault) {\n builder.var(name);\n } else if (isNamed) {\n if (ensureLiveReference) {\n builder.var(importedSource).read(name);\n } else {\n builder.var(name).prop(importName);\n }\n }\n }\n } else {\n throw new Error(`Unknown importedInterop \"${importedInterop}\".`);\n }\n\n const { statements, resultName } = builder.done();\n\n this._insertStatements(statements, importPosition, blockHoist);\n\n if (\n (isDefault || isNamed) &&\n ensureNoContext &&\n resultName.type !== \"Identifier\"\n ) {\n return sequenceExpression([numericLiteral(0), resultName]);\n }\n return resultName;\n }\n\n _insertStatements(\n statements: t.Statement[],\n importPosition = \"before\",\n blockHoist = 3,\n ) {\n if (importPosition === \"after\") {\n if (this._insertStatementsAfter(statements)) return;\n } else {\n if (this._insertStatementsBefore(statements, blockHoist)) return;\n }\n\n this._programPath.unshiftContainer(\"body\", statements);\n }\n\n _insertStatementsBefore(statements: t.Statement[], blockHoist: number) {\n if (\n statements.length === 1 &&\n isImportDeclaration(statements[0]) &&\n isValueImport(statements[0])\n ) {\n const firstImportDecl = this._programPath\n .get(\"body\")\n .find((p): p is NodePath<t.ImportDeclaration> => {\n return p.isImportDeclaration() && isValueImport(p.node);\n });\n\n if (\n firstImportDecl?.node.source.value === statements[0].source.value &&\n maybeAppendImportSpecifiers(firstImportDecl.node, statements[0])\n ) {\n return true;\n }\n }\n\n statements.forEach(node => {\n // @ts-expect-error handle _blockHoist\n node._blockHoist = blockHoist;\n });\n\n const targetPath = this._programPath.get(\"body\").find(p => {\n // @ts-expect-error todo(flow->ts): avoid mutations\n const val = p.node._blockHoist;\n return Number.isFinite(val) && val < 4;\n });\n\n if (targetPath) {\n targetPath.insertBefore(statements);\n return true;\n }\n\n return false;\n }\n\n _insertStatementsAfter(statements: t.Statement[]): boolean {\n const statementsSet = new Set(statements);\n const importDeclarations: Map<string, t.ImportDeclaration[]> = new Map();\n\n for (const statement of statements) {\n if (isImportDeclaration(statement) && isValueImport(statement)) {\n const source = statement.source.value;\n if (!importDeclarations.has(source)) importDeclarations.set(source, []);\n importDeclarations.get(source).push(statement);\n }\n }\n\n let lastImportPath = null;\n for (const bodyStmt of this._programPath.get(\"body\")) {\n if (bodyStmt.isImportDeclaration() && isValueImport(bodyStmt.node)) {\n lastImportPath = bodyStmt;\n\n const source = bodyStmt.node.source.value;\n const newImports = importDeclarations.get(source);\n if (!newImports) continue;\n\n for (const decl of newImports) {\n if (!statementsSet.has(decl)) continue;\n if (maybeAppendImportSpecifiers(bodyStmt.node, decl)) {\n statementsSet.delete(decl);\n }\n }\n }\n }\n\n if (statementsSet.size === 0) return true;\n\n if (lastImportPath) lastImportPath.insertAfter(Array.from(statementsSet));\n\n return !!lastImportPath;\n }\n}\n\nfunction isValueImport(node: t.ImportDeclaration) {\n return node.importKind !== \"type\" && node.importKind !== \"typeof\";\n}\n\nfunction hasNamespaceImport(node: t.ImportDeclaration) {\n return (\n (node.specifiers.length === 1 &&\n node.specifiers[0].type === \"ImportNamespaceSpecifier\") ||\n (node.specifiers.length === 2 &&\n node.specifiers[1].type === \"ImportNamespaceSpecifier\")\n );\n}\n\nfunction hasDefaultImport(node: t.ImportDeclaration) {\n return (\n node.specifiers.length > 0 &&\n node.specifiers[0].type === \"ImportDefaultSpecifier\"\n );\n}\n\nfunction maybeAppendImportSpecifiers(\n target: t.ImportDeclaration,\n source: t.ImportDeclaration,\n): boolean {\n if (!target.specifiers.length) {\n target.specifiers = source.specifiers;\n return true;\n }\n if (!source.specifiers.length) return true;\n\n if (hasNamespaceImport(target) || hasNamespaceImport(source)) return false;\n\n if (hasDefaultImport(source)) {\n if (hasDefaultImport(target)) {\n source.specifiers[0] = importSpecifier(\n source.specifiers[0].local,\n identifier(\"default\"),\n );\n } else {\n target.specifiers.unshift(source.specifiers.shift());\n }\n }\n\n target.specifiers.push(...source.specifiers);\n\n return true;\n}\n"],"mappings":";;;;;;AAAA,IAAAA,OAAA,GAAAC,OAAA;AACA,IAAAC,EAAA,GAAAD,OAAA;AAUA,IAAAE,cAAA,GAAAF,OAAA;AACA,IAAAG,SAAA,GAAAH,OAAA;AAAsC;EAVpCI,UAAU;EACVC,eAAe;EACfC,cAAc;EACdC,kBAAkB;EAClBC;AAAmB,IAAAP,EAAA;AAsGN,MAAMQ,cAAc,CAAC;EA6BlCC,WAAWA,CACTC,IAAc,EACdC,cAAuB,EACvBC,IAA6B,EAC7B;IAAA,KAdFC,YAAY,GAAkB;MAC5BF,cAAc,EAAE,IAAI;MACpBG,YAAY,EAAE,UAAU;MACxBC,eAAe,EAAE,OAAO;MACxBC,gBAAgB,EAAE,OAAO;MACzBC,mBAAmB,EAAE,KAAK;MAC1BC,eAAe,EAAE,KAAK;MACtBC,cAAc,EAAE;IAClB,CAAC;IAOC,MAAMC,WAAW,GAAGV,IAAI,CAACW,IAAI,CAACC,CAAC,IAAIA,CAAC,CAACC,SAAS,CAAC,CAAC,CAAwB;IAExE,IAAI,CAACC,YAAY,GAAGJ,WAAW;IAC/B,IAAI,CAACK,aAAa,GAAGL,WAAW,CAACM,KAAK;IACtC,IAAI,CAACC,IAAI,GAAGP,WAAW,CAACQ,GAAG;IAE3B,IAAI,CAACf,YAAY,GAAG,IAAI,CAACgB,cAAc,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