-
Notifications
You must be signed in to change notification settings - Fork 362
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix: Strips jsxFactory from tsconfig if --importSource
is set
#988
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
'microbundle': patch | ||
--- | ||
|
||
Fixes tsconfig merge issue with jsxImportSource and default jsxFactory value |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -71,6 +71,7 @@ export default async function microbundle(inputOptions) { | |
options.pkg.name = pkgName; | ||
|
||
if (options.sourcemap === 'inline') { | ||
// eslint-disable-next-line no-console | ||
console.log( | ||
'Warning: inline sourcemaps should only be used for debugging purposes.', | ||
); | ||
|
@@ -549,9 +550,16 @@ function createConfig(options, entry, format, writeMeta) { | |
...(options.generateTypes !== false && { | ||
declarationDir: getDeclarationDir({ options, pkg }), | ||
}), | ||
jsx: 'preserve', | ||
jsxFactory: options.jsx, | ||
jsxFragmentFactory: options.jsxFragment, | ||
...(options.jsxImportSource | ||
? { | ||
jsx: 'react-jsx', | ||
jsxImportSource: options.jsxImportSource, | ||
} | ||
: { | ||
jsx: 'preserve', | ||
jsxFactory: options.jsx, | ||
jsxFragmentFactory: options.jsxFragment, | ||
}), | ||
Comment on lines
+553
to
+562
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Theoretically we would be fine to leave Conditionally adding Setting these configurations ourselves, at least as defaults, allows us to make fewer assumptions about users' configs that are external to Microbundle (and hopefully will raise fewer issues). |
||
}, | ||
files: options.entries, | ||
}, | ||
|
@@ -642,6 +650,7 @@ function createConfig(options, entry, format, writeMeta) { | |
options.visualize && visualizer(), | ||
// NOTE: OMT only works with amd and esm | ||
// Source: https://github.com/surma/rollup-plugin-off-main-thread#config | ||
// eslint-disable-next-line new-cap | ||
useWorkerLoader && (format === 'es' || modern) && OMT(), | ||
/** @type {import('rollup').Plugin} */ | ||
({ | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
should this be
preserve
, orreact
?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
preserve
should be correct, though from my quick tests I don't think it makes a difference either way.preserve
is to be used when having another tool transpile JSX (e.g., babel), which is what we do.react
on the other hand has TSC transpile it itself. TS DocsI think, at best,react
would do nothing, and at worst, it'd slow down type generation due to trying to handle JSX which we don't need. No one's raised any issues regardingpreserve
so I'd assume it's fine.Edit: Depends on what we want, I suppose. I'd prefer to have TS handle as little as possible and
preserve
is already the default behavior. I didn't originally realize we did have TS handle JSX.