Skip to content

Commit

Permalink
Allow specifying a single specifier for custom imports, see gregberge…
Browse files Browse the repository at this point in the history
…#801

`hyperapp-jsx-pragma` uses the default export so we need to `import h from "hyperapp-jsx-pragma"`, not `import { h } from "hyperapp-jsx-pragma"`
  • Loading branch information
shish committed Nov 28, 2022
1 parent 1118a6e commit ad84b15
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 0 deletions.
1 change: 1 addition & 0 deletions packages/babel-plugin-transform-svg-component/src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ interface State {
export interface JSXRuntimeImport {
source: string
namespace?: string
specifier?: string
specifiers?: string[]
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,10 @@ const getJsxRuntimeImport = (cfg: JSXRuntimeImport) => {
const specifiers = (() => {
if (cfg.namespace)
return [t.importNamespaceSpecifier(t.identifier(cfg.namespace))]
if (cfg.specifier) {
const identifier = t.identifier(cfg.specifier)
return [t.importDefaultSpecifier(identifier)]
}
if (cfg.specifiers)
return cfg.specifiers.map((specifier) => {
const identifier = t.identifier(specifier)
Expand Down
1 change: 1 addition & 0 deletions packages/core/src/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ export interface Config {
jsxRuntimeImport?: {
source: string,
namespace?: string,
specifier?: string,
specifiers?: string[]
}

Expand Down

0 comments on commit ad84b15

Please sign in to comment.