Skip to content
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

Merged
merged 2 commits into from Oct 10, 2023

Conversation

jimmydief
Copy link
Contributor

Q                       A
Fixed Issues? Fixes #16021
Patch: Bug Fix? Not sure
Major: Breaking Change? Not sure
Minor: New Feature? Not sure
Tests Added + Pass? Yes
Documentation PR Link N/A
Any Dependency Changes? No
License MIT

Include .tsx in the file extensions which are rewritten when using rewriteImportExtensions option of the TS preset.

@babel-bot
Copy link
Collaborator

babel-bot commented Oct 6, 2023

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");
Copy link
Contributor Author

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.

Copy link
Member

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.

Copy link
Member

@liuxingbaoyu liuxingbaoyu left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

@liuxingbaoyu liuxingbaoyu added the PR: Polish 💅 A type of pull request used for our changelog categories label Oct 8, 2023
@nicolo-ribaudo nicolo-ribaudo added PR: Bug Fix 🐛 A type of pull request used for our changelog categories and removed PR: Polish 💅 A type of pull request used for our changelog categories labels Oct 9, 2023
Copy link
Member

@nicolo-ribaudo nicolo-ribaudo left a 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).

@nicolo-ribaudo nicolo-ribaudo changed the title Rewrite .tsx extension when using rewriteImportExtensions option of TS preset Rewrite .tsx extension when using rewriteImportExtensions Oct 10, 2023
@nicolo-ribaudo nicolo-ribaudo merged commit ccb6323 into babel:main Oct 10, 2023
46 of 47 checks passed
@jimmydief jimmydief deleted the rewrite_tsx branch October 11, 2023 16:12
@github-actions github-actions bot added the outdated A closed issue/PR that is archived due to age. Recommended to make a new issue label Jan 11, 2024
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Jan 11, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
outdated A closed issue/PR that is archived due to age. Recommended to make a new issue PR: Bug Fix 🐛 A type of pull request used for our changelog categories
Projects
None yet
Development

Successfully merging this pull request may close these issues.

rewriteImportExtensions option for TS preset does not work with .tsx files
4 participants