From 144722208822700459fcf925b69c7d6a236d70ba Mon Sep 17 00:00:00 2001 From: killagu Date: Wed, 17 Apr 2024 16:59:41 +0800 Subject: [PATCH] fix: always get extension from Module._extensions ts-node/register may require after tegg loader --- core/loader/src/LoaderUtil.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/core/loader/src/LoaderUtil.ts b/core/loader/src/LoaderUtil.ts index c266f7a4..e6529db1 100644 --- a/core/loader/src/LoaderUtil.ts +++ b/core/loader/src/LoaderUtil.ts @@ -8,8 +8,6 @@ const Module = module.constructor.length > 1 /* istanbul ignore next */ : BuiltinModule; -const EXTENSION = Object.keys((Module as any)._extensions).find(t => t === '.ts') ? '.ts' : '.js'; - interface LoaderUtilConfig { extraFilePattern?: string[]; } @@ -20,7 +18,9 @@ export class LoaderUtil { this.config = config; } - static extension = EXTENSION; + static get extension() { + return Object.keys((Module as any)._extensions).find(t => t === '.ts') ? '.ts' : '.js'; + } static filePattern(): string[] { const extensions = Object.keys((Module as any)._extensions);