wip-Emit import call expression for commonjs

This commit is contained in:
Yui T
2017-03-14 10:31:30 -07:00
parent 369af08e27
commit ffbb445148
6 changed files with 66 additions and 9 deletions

View File

@@ -0,0 +1,11 @@
// @module: commonjs
// @target: esnext
// @filename: 0.ts
export function foo() { return "foo"; }
// @filename: 1.ts
import("./0");
var p1 = import("./0");
p1.then(zero => {
return zero.foo();
});

View File

@@ -0,0 +1,19 @@
// @module: commonjs
// @target: esnext
// @filename: 0.ts
export function foo() { return "foo"; }
// @filename: 1.ts
export function backup() { return "backup"; }
// @filename: 2.ts
async function compute(promise: Promise<any>) {
let j = await promise;
if (!j) {
j = await import("./1");
return j.backup();
}
return j.foo();
}
compute(import("./0"));