From c8e94bb1d195e1e69e6f632c546801990f51870f Mon Sep 17 00:00:00 2001 From: Helder Oliveira Date: Mon, 4 Nov 2024 13:10:29 +0000 Subject: [PATCH] =?UTF-8?q?fix:=20=F0=9F=90=9B=20load=20typescript=20confi?= =?UTF-8?q?guration=20file?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/utils/configuration/readConfigurationFile.ts | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/src/utils/configuration/readConfigurationFile.ts b/src/utils/configuration/readConfigurationFile.ts index ae73e3d3..005e8054 100644 --- a/src/utils/configuration/readConfigurationFile.ts +++ b/src/utils/configuration/readConfigurationFile.ts @@ -52,7 +52,19 @@ export const readConfigurationFile = async ({ } try { - const loadedConfigModule = await import(configPath); + // TODO: The `import` throws `UNKNOWN_FILE_EXTENSION` + // Tried `ts-node/register` without success + // Ideally `ts-node` should be removed + // use `bun` or the new `deno` v2 + // Obs: For past months `bun` has been impeccable + const loadedConfigModule = await (async () => { + if (fileExtension.toLowerCase() === '.ts') { + const x = await import('importx'); + const { default: loadedConfigModule } = await x.import(configPath, __filename); + return loadedConfigModule; + } + return import(configPath); + })(); if (typeof loadedConfigModule.default === 'function') { return {