diff --git a/tslib.es6.js b/tslib.es6.js index 36b58a5..5b36110 100644 --- a/tslib.es6.js +++ b/tslib.es6.js @@ -357,10 +357,9 @@ export function __rewriteRelativeImportExtension(path, preserveJsx) { if (extMatch) { var ext = extMatch[0].toLowerCase(); var dot = path.lastIndexOf(".", path.length - (ext.length + 1)); - if (dot >= 0 && (path.substring(dot - 2, dot).toLowerCase() === ".d" || path.substring(dot, dot + 2).toLowerCase() === ".d")) { - return path; + if (dot < 0 || !(path.substring(dot - 2, dot).toLowerCase() === ".d" || path.substring(dot, dot + 2).toLowerCase() === ".d")) { + return path.substring(0, path.length - ext.length) + (ext === ".mts" ? ".mjs" : ext === ".cts" ? ".cjs" : ".js"); } - return path.substring(0, path.length - ext.length) + (ext === ".mts" ? ".mjs" : ext === ".cts" ? ".cjs" : ".js"); } } return path; diff --git a/tslib.es6.mjs b/tslib.es6.mjs index ccffef3..7fed569 100644 --- a/tslib.es6.mjs +++ b/tslib.es6.mjs @@ -356,10 +356,9 @@ export function __rewriteRelativeImportExtension(path, preserveJsx) { if (extMatch) { var ext = extMatch[0].toLowerCase(); var dot = path.lastIndexOf(".", path.length - (ext.length + 1)); - if (dot >= 0 && (path.substring(dot - 2, dot).toLowerCase() === ".d" || path.substring(dot, dot + 2).toLowerCase() === ".d")) { - return path; + if (dot < 0 || !(path.substring(dot - 2, dot).toLowerCase() === ".d" || path.substring(dot, dot + 2).toLowerCase() === ".d")) { + return path.substring(0, path.length - ext.length) + (ext === ".mts" ? ".mjs" : ext === ".cts" ? ".cjs" : ".js"); } - return path.substring(0, path.length - ext.length) + (ext === ".mts" ? ".mjs" : ext === ".cts" ? ".cjs" : ".js"); } } return path; diff --git a/tslib.js b/tslib.js index 64090f0..d22e885 100644 --- a/tslib.js +++ b/tslib.js @@ -405,10 +405,9 @@ var __rewriteRelativeImportExtension; if (extMatch) { var ext = extMatch[0].toLowerCase(); var dot = path.lastIndexOf(".", path.length - (ext.length + 1)); - if (dot >= 0 && (path.substring(dot - 2, dot).toLowerCase() === ".d" || path.substring(dot, dot + 2).toLowerCase() === ".d")) { - return path; + if (dot < 0 || !(path.substring(dot - 2, dot).toLowerCase() === ".d" || path.substring(dot, dot + 2).toLowerCase() === ".d")) { + return path.substring(0, path.length - ext.length) + (ext === ".mts" ? ".mjs" : ext === ".cts" ? ".cjs" : ".js"); } - return path.substring(0, path.length - ext.length) + (ext === ".mts" ? ".mjs" : ext === ".cts" ? ".cjs" : ".js"); } } return path;