Skip to content

Commit 76fba2c

Browse files
committed
fix: Conditionally sets jsxFactory & jsxImportSource in tsconfigs
1 parent fd4ea1a commit 76fba2c

File tree

1 file changed

+12
-3
lines changed

1 file changed

+12
-3
lines changed

src/index.js

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,7 @@ export default async function microbundle(inputOptions) {
7171
options.pkg.name = pkgName;
7272

7373
if (options.sourcemap === 'inline') {
74+
// eslint-disable-next-line no-console
7475
console.log(
7576
'Warning: inline sourcemaps should only be used for debugging purposes.',
7677
);
@@ -549,9 +550,16 @@ function createConfig(options, entry, format, writeMeta) {
549550
...(options.generateTypes !== false && {
550551
declarationDir: getDeclarationDir({ options, pkg }),
551552
}),
552-
jsx: 'preserve',
553-
jsxFactory: options.jsx,
554-
jsxFragmentFactory: options.jsxFragment,
553+
...(options.jsxImportSource
554+
? {
555+
jsx: 'react-jsx',
556+
jsxImportSource: options.jsxImportSource,
557+
}
558+
: {
559+
jsx: 'preserve',
560+
jsxFactory: options.jsx,
561+
jsxFragmentFactory: options.jsxFragment,
562+
}),
555563
},
556564
files: options.entries,
557565
},
@@ -642,6 +650,7 @@ function createConfig(options, entry, format, writeMeta) {
642650
options.visualize && visualizer(),
643651
// NOTE: OMT only works with amd and esm
644652
// Source: https://github.com/surma/rollup-plugin-off-main-thread#config
653+
// eslint-disable-next-line new-cap
645654
useWorkerLoader && (format === 'es' || modern) && OMT(),
646655
/** @type {import('rollup').Plugin} */
647656
({

0 commit comments

Comments
 (0)