|
1 | 1 | import * as path from "path"; |
2 | 2 | import * as ts from "typescript"; |
3 | 3 | import * as lua from "../../../LuaAST"; |
| 4 | +import { createStaticPromiseFunctionAccessor } from "../../builtins/promise"; |
4 | 5 | import { FunctionVisitor, TransformationContext } from "../../context"; |
5 | 6 | import { AnnotationKind, getSymbolAnnotations } from "../../utils/annotations"; |
6 | 7 | import { createDefaultExportStringLiteral } from "../../utils/export"; |
7 | 8 | import { createHoistableVariableDeclarationStatement } from "../../utils/lua-ast"; |
| 9 | +import { importLuaLibFeature, LuaLibFeature } from "../../utils/lualib"; |
8 | 10 | import { createSafeName } from "../../utils/safe-names"; |
9 | 11 | import { peekScope } from "../../utils/scope"; |
10 | 12 | import { transformIdentifier } from "../identifier"; |
@@ -161,3 +163,10 @@ export const transformImportEqualsDeclaration: FunctionVisitor<ts.ImportEqualsDe |
161 | 163 | const expression = context.transformExpression(node.moduleReference); |
162 | 164 | return createHoistableVariableDeclarationStatement(context, name, expression, node); |
163 | 165 | }; |
| 166 | + |
| 167 | +export const transformImportExpression: FunctionVisitor<ts.CallExpression> = (node, context) => { |
| 168 | + importLuaLibFeature(context, LuaLibFeature.Promise); |
| 169 | + |
| 170 | + const importPath = node.arguments.map(a => context.transformExpression(a)); |
| 171 | + return lua.createCallExpression(createStaticPromiseFunctionAccessor("resolve", node), importPath, node); |
| 172 | +}; |
0 commit comments