From 960845c5f398f562b6c7210f06067f946cf8ddd3 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..c2006fe9 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..d05faca5 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: