From df48c93730712a728e56f63987ae67cc5f83be2d Mon Sep 17 00:00:00 2001 From: Mike Donnalley Date: Tue, 12 Nov 2024 09:53:43 -0700 Subject: [PATCH] fix: add env var to disable link warning --- src/config/ts-path.ts | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/config/ts-path.ts b/src/config/ts-path.ts index 368d0751..69e4b3b9 100644 --- a/src/config/ts-path.ts +++ b/src/config/ts-path.ts @@ -9,7 +9,7 @@ import {Plugin, TSConfig} from '../interfaces' import {settings} from '../settings' import {existsSync} from '../util/fs' import {readTSConfig} from '../util/read-tsconfig' -import {isProd} from '../util/util' +import {isProd, isTruthy} from '../util/util' import {makeDebug} from './util' const debug = makeDebug('ts-path') @@ -314,7 +314,12 @@ export async function tsPath( debug( `Skipping typescript path lookup for ${root} because it's an ESM module (NODE_ENV: ${process.env.NODE_ENV}, root plugin module type: ${rootPlugin?.moduleType})`, ) - if (plugin?.type === 'link') + + const warningIsDisabled = + process.env.OCLIF_DISABLE_LINKED_ESM_WARNING && isTruthy(process.env.OCLIF_DISABLE_LINKED_ESM_WARNING) + + // Only warn if the plugin is linked AND the warning is not disabled + if (plugin?.type === 'link' && !warningIsDisabled) memoizedWarn( `${plugin?.name} is a linked ESM module and cannot be auto-transpiled. Existing compiled source will be used instead.`, )