Skip to content

Commit

Permalink
fix: 🐛 load typescript configuration file
Browse files Browse the repository at this point in the history
  • Loading branch information
heldrida committed Nov 4, 2024
1 parent d554b03 commit c8e94bb
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion src/utils/configuration/readConfigurationFile.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down

0 comments on commit c8e94bb

Please sign in to comment.