GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — Rewrite `.tsx` extension when using `rewriteImportExtensions` by jimmydief · Pull Request #16022 · babel/babel

Conversation

@jimmydief

@jimmydief jimmydief commented Oct 6, 2023

Copy link
Copy Markdown
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.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@jimmydief
rewrite TSX extensions
c9be2af
@babel-bot

babel-bot commented Oct 6, 2023 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Collaborator

Build successful! You can test your changes in the REPL here: https://babeljs.io/repl/build/55616/

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

jimmydief
jimmydief commented Oct 6, 2023
View reviewed changes
Comment thread packages/babel-preset-typescript/src/plugin-rewrite-ts-imports.ts Outdated
: 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");

@jimmydief jimmydief Oct 6, 2023

Copy link
Copy Markdown
Contributor Author

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.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions

@nicolo-ribaudo nicolo-ribaudo Oct 9, 2023 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Member

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.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@jimmydief
avoid rewriting .mtsx & .ctsx
e71545a
liuxingbaoyu
liuxingbaoyu approved these changes Oct 8, 2023
View reviewed changes

@liuxingbaoyu liuxingbaoyu left a comment

Copy link
Copy Markdown
Member

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!

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@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
nicolo-ribaudo
nicolo-ribaudo approved these changes Oct 9, 2023
View reviewed changes

@nicolo-ribaudo nicolo-ribaudo left a comment

Copy link
Copy Markdown
Member

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).

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@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
@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.

Reviewers

@nicolo-ribaudo nicolo-ribaudo nicolo-ribaudo approved these changes
@liuxingbaoyu liuxingbaoyu liuxingbaoyu approved these changes

Uh oh!

There was an error while loading. Please reload this page.

Assignees

No one assigned

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

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

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

Uh oh!

There was an error while loading. Please reload this page.

4 participants

@jimmydief @babel-bot @nicolo-ribaudo @liuxingbaoyu
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
You are visitor 01402775 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.