From 1938c83565f972438cfb0fb7ab576b269a402e9f Mon Sep 17 00:00:00 2001 From: jgoux Date: Sun, 24 Sep 2023 21:39:31 +0200 Subject: [PATCH] remove the right code --- src/plugins/typescript/index.ts | 7 +++++-- tests/plugins/typescript.test.ts | 2 +- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/src/plugins/typescript/index.ts b/src/plugins/typescript/index.ts index 435a81881..feeff3ca3 100644 --- a/src/plugins/typescript/index.ts +++ b/src/plugins/typescript/index.ts @@ -1,3 +1,4 @@ +import ts from 'typescript'; import { compact } from '../../util/array.js'; import { dirname, isInternal, toAbsolute } from '../../util/path.js'; import { timerify } from '../../util/Performance.js'; @@ -33,6 +34,8 @@ const resolveExtensibleConfig = async (configFilePath: string) => { return config; }; +const jsxWithReact = [ts.JsxEmit.React, ts.JsxEmit.ReactJSX, ts.JsxEmit.ReactJSXDev, ts.JsxEmit.ReactNative]; + export const findTypeScriptDependencies: GenericPluginCallback = async configFilePath => { const compilerOptions: CompilerOptions = await loadTSConfig(configFilePath); const config: TsConfigJson = await resolveExtensibleConfig(configFilePath); // Dual loader to get external `extends` dependencies @@ -45,8 +48,8 @@ export const findTypeScriptDependencies: GenericPluginCallback = async configFil ? compilerOptions.plugins.map(plugin => (typeof plugin === 'object' && 'name' in plugin ? plugin.name : '')) : []; const importHelpers = compilerOptions?.importHelpers ? ['tslib'] : []; - - return compact([...extend, ...types, ...plugins, ...importHelpers]); + const jsx = compilerOptions?.jsxImportSource ? [compilerOptions.jsxImportSource] : []; + return compact([...extend, ...types, ...plugins, ...importHelpers, ...jsx]); }; export const findDependencies = timerify(findTypeScriptDependencies); diff --git a/tests/plugins/typescript.test.ts b/tests/plugins/typescript.test.ts index 002aa6823..1f9961a43 100644 --- a/tests/plugins/typescript.test.ts +++ b/tests/plugins/typescript.test.ts @@ -25,7 +25,7 @@ test('Find dependencies in typescript configuration (jsx-preserve)', async () => test('Find dependencies in typescript configuration (jsx)', async () => { const configFilePath = join(cwd, 'tsconfig-jsx.json'); const dependencies = await typescript.findDependencies(configFilePath); - assert.deepEqual(dependencies, ['react']); + assert.deepEqual(dependencies, []); }); test('Find dependencies in typescript configuration (jsx-import-source)', async () => {