From 93d66db07e3c52bdde7d9de00a5aef11a11bd1e0 Mon Sep 17 00:00:00 2001 From: yarastqt Date: Mon, 4 May 2020 21:44:48 +0300 Subject: [PATCH] fix: use ts-node instead node-eval with ts compiler --- src/core/import-module.ts | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/src/core/import-module.ts b/src/core/import-module.ts index af21559..2dde651 100644 --- a/src/core/import-module.ts +++ b/src/core/import-module.ts @@ -1,6 +1,6 @@ -import { transpileModule } from 'typescript' -import { readFile } from 'fs-extra' -import neval from 'node-eval' +import { register } from 'ts-node' + +register({ transpileOnly: true }) export function esModuleInterop(box?: T): T { if (box === undefined) { @@ -17,9 +17,7 @@ export function esModuleInterop(box?: T): T { */ export async function importModule(path: string): Promise { // TODO: Source possibly empty or have invalid format. - const source = await readFile(path, 'utf-8') // TODO: Add diagnostic. - const transpileResult = transpileModule(source, {}) - const result = neval(transpileResult.outputText, path) + const result = await import(path) return esModuleInterop(result) }