From 82237694f7596b78368ee90dc4fa4cb738d06ab7 Mon Sep 17 00:00:00 2001 From: John-Henry Lim <42513874+Interpause@users.noreply.github.com> Date: Fri, 13 Oct 2023 16:22:52 +0800 Subject: [PATCH] Allow JSX Import Source to be overwritten (#47) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * allow jsx import source to be configured * allow package to be installed via git * fix: support vite v3 (#50) * 2.3.0 (#53) * add named export to improve `"module": "nodenext"` compatibility (#48) * add named export to improve `"module": "nodenext"` compatibility * add proper types export * Update src/index.ts Co-authored-by: Jovi De Croock Co-authored-by: Jovi De Croock * Update package.json * remove "prepare" script --------- Co-authored-by: 翠 / green Co-authored-by: Jovi De Croock Co-authored-by: Volodymyr Zhdanov --- src/index.ts | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/index.ts b/src/index.ts index 8b1080e..54cc958 100644 --- a/src/index.ts +++ b/src/index.ts @@ -57,6 +57,10 @@ export interface PreactPluginOptions { * Babel configuration applied in both dev and prod. */ babel?: BabelOptions; + /** + * Import Source for jsx. Defaults to "preact". + */ + jsxImportSource?: string; } export interface PreactBabelOptions extends BabelOptions { @@ -77,6 +81,7 @@ function preactPlugin({ include, exclude, babel, + jsxImportSource, }: PreactPluginOptions = {}): Plugin[] { const baseParserOptions = [ "importMeta", @@ -157,7 +162,7 @@ function preactPlugin({ : "@babel/plugin-transform-react-jsx-development", { runtime: "automatic", - importSource: "preact", + importSource: jsxImportSource ?? "preact", }, ], ...(config.isProduction ? [] : ["babel-plugin-transform-hook-names"]),