-
-
Notifications
You must be signed in to change notification settings - Fork 5.7k
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
Rewrite .tsx
extension when using rewriteImportExtensions
#16022
Conversation
Build successful! You can test your changes in the REPL here: https://babeljs.io/repl/build/55616/ |
@@ -16,7 +16,7 @@ export default declare(function ({ types: t }) { | |||
? node.importKind | |||
: node.exportKind; | |||
if (kind === "value" && source && /[\\/]/.test(source.value)) { | |||
source.value = source.value.replace(/(\.[mc]?)ts$/, "$1js"); | |||
source.value = source.value.replace(/(\.[mc]?)tsx?$/, "$1js"); |
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.
Not sure if .mtsx
or .ctsx
are valid? Seems like no.
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.
Yeah they are not valid.
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.
Thanks!
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.
I am a little bit on the fence, since with this PR we would support .tsx
but not .jsx
. I think we could eventually supports JSX by adding the same option to the react preset if somebody in the future will ask for it (or we could publish extension rewriting as a separate standalone plugin).
.tsx
extension when using rewriteImportExtensions
option of TS preset.tsx
extension when using rewriteImportExtensions
Include
.tsx
in the file extensions which are rewritten when usingrewriteImportExtensions
option of the TS preset.