Skip to content

Commit

Permalink
Rewrite .tsx extension when using rewriteImportExtensions (#16022)
Browse files Browse the repository at this point in the history
  • Loading branch information
jimmydief committed Oct 10, 2023
1 parent d25f265 commit ccb6323
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 1 deletion.
Expand Up @@ -16,7 +16,9 @@ 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]?)ts$/, "$1js")
.replace(/\.tsx$/, ".js");
}
},
},
Expand Down
@@ -1,6 +1,10 @@
import "./a.ts";
import "./a.mts";
import "./a.cts";
import "./react.tsx";
// .mtsx and .ctsx are not valid and should not be transformed.
import "./react.mtsx";
import "./react.ctsx";
import "a-package/file.ts";
// Bare import, it's either a node package or remapped by an import map
import "soundcloud.ts";
@@ -1,6 +1,10 @@
import "./a.js";
import "./a.mjs";
import "./a.cjs";
import "./react.js";
// .mtsx and .ctsx are not valid and should not be transformed.
import "./react.mtsx";
import "./react.ctsx";
import "a-package/file.js";
// Bare import, it's either a node package or remapped by an import map
import "soundcloud.ts";

0 comments on commit ccb6323

Please sign in to comment.