From 1118a6e1b8b7366fefaeb6615f1939aea2a89758 Mon Sep 17 00:00:00 2001 From: Shish Date: Mon, 28 Nov 2022 17:46:20 +0000 Subject: [PATCH] Allow specifying `jsxRuntimeImport` in config, see #801 I need to have a config which isn't currently supported --- packages/core/src/config.ts | 5 +++++ packages/plugin-jsx/src/index.ts | 6 ++++++ 2 files changed, 11 insertions(+) diff --git a/packages/core/src/config.ts b/packages/core/src/config.ts index 9468ca8b..74cf7b2f 100644 --- a/packages/core/src/config.ts +++ b/packages/core/src/config.ts @@ -32,6 +32,11 @@ export interface Config { exportType?: 'named' | 'default' namedExport?: string jsxRuntime?: 'classic' | 'classic-preact' | 'automatic' + jsxRuntimeImport?: { + source: string, + namespace?: string, + specifiers?: string[] + } // CLI only index?: boolean diff --git a/packages/plugin-jsx/src/index.ts b/packages/plugin-jsx/src/index.ts index 9d198df0..71b8f8ff 100644 --- a/packages/plugin-jsx/src/index.ts +++ b/packages/plugin-jsx/src/index.ts @@ -7,6 +7,12 @@ import svgrBabelPreset, { import type { Plugin, Config } from '@svgr/core' const getJsxRuntimeOptions = (config: Config): Partial => { + if(config.jsxRuntimeImport) { + return { + importSource: config.jsxRuntimeImport.source, + jsxRuntimeImport: config.jsxRuntimeImport + } + } switch (config.jsxRuntime) { case null: case undefined: