-
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?
Conversation
🦋 Changeset detectedLatest commit: e4d8db3 The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
--importSource
is set
Size Change: 0 B Total Size: 63.4 kB ℹ️ View Unchanged
|
2f6f13f
to
74de373
Compare
74de373
to
e4d8db3
Compare
...(options.jsxImportSource | ||
? { | ||
jsx: 'react-jsx', | ||
jsxImportSource: options.jsxImportSource, | ||
} | ||
: { | ||
jsx: 'preserve', | ||
jsxFactory: options.jsx, | ||
jsxFragmentFactory: options.jsxFragment, | ||
}), |
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.
Theoretically we would be fine to leave jsx
untouched & remove that first piece of the ternary, however, that relies on the assumption that the user does have a tsconfig.json
and that it's correctly set.
Conditionally adding jsxFactory
(and jsxFragmentFactory
) is enough to quell the errors we were getting in the linked issue, but when using --jsxImportSource
with TS, the tsconfig.json
will need to have different values. While users in all likelihood will have a tsconfig.json
that's correctly configured in that case, if they do not, their typings will contain any
where JSX references should be.
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).
jsxImportSource: options.jsxImportSource, | ||
} | ||
: { | ||
jsx: 'preserve', |
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
, or react
?
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 Docs
I 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 regarding preserve
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.
Closes #857
If a user supplies
--jsxImportSource
we should removejsxFactory
andjsxFragmentFactory
from the defaulttsconfig
as they're mutually exclusive withjsx: 'react-jsx'
.