Skip to content

Commit

Permalink
Allow specifying jsxRuntimeImport in config, see gregberge#801
Browse files Browse the repository at this point in the history
I need to have a config which isn't currently supported
  • Loading branch information
shish committed Nov 29, 2022
1 parent 14d7024 commit 960845c
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 0 deletions.
5 changes: 5 additions & 0 deletions packages/core/src/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
6 changes: 6 additions & 0 deletions packages/plugin-jsx/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,12 @@ import svgrBabelPreset, {
import type { Plugin, Config } from '@svgr/core'

const getJsxRuntimeOptions = (config: Config): Partial<SvgrPresetOptions> => {
if (config.jsxRuntimeImport) {
return {
importSource: config.jsxRuntimeImport.source,
jsxRuntimeImport: config.jsxRuntimeImport,
}
}
switch (config.jsxRuntime) {
case null:
case undefined:
Expand Down

0 comments on commit 960845c

Please sign in to comment.