typescript-transform-paths
Advanced tools
Comparing version 2.2.1 to 2.2.2
@@ -5,2 +5,9 @@ # Changelog | ||
### [2.2.2](https://github.com/LeDDGroup/typescript-transform-paths/compare/v2.2.1...v2.2.2) (2021-01-11) | ||
### Bug Fixes | ||
* Corrected explicit extensions fix from previous patch ([a90e550](https://github.com/LeDDGroup/typescript-transform-paths/commit/a90e550a3d0c4804ef3a4e27cbc4e32ce6971296)) | ||
### [2.2.1](https://github.com/LeDDGroup/typescript-transform-paths/compare/v2.2.0...v2.2.1) (2021-01-10) | ||
@@ -7,0 +14,0 @@ |
@@ -9,5 +9,10 @@ "use strict"; | ||
const general_utils_1 = require("./general-utils"); | ||
/* ****************************************************************************************************************** * | ||
* Node Updater | ||
* ****************************************************************************************************************** */ | ||
/* ****************************************************************************************************************** */ | ||
// region: Config | ||
/* ****************************************************************************************************************** */ | ||
const explicitExtensions = [".js", ".jsx"]; | ||
// endregion | ||
/* ****************************************************************************************************************** */ | ||
// region: Node Updater Utility | ||
/* ****************************************************************************************************************** */ | ||
/** | ||
@@ -87,6 +92,14 @@ * Gets proper path and calls updaterFn to get the new node if it should be updated | ||
// Remove extension if implicit | ||
if (extension && implicitExtensions.includes(extension) && path_1.default.basename(moduleName) !== path_1.default.basename(filePath)) | ||
filePath = filePath.slice(0, -extension.length); | ||
if (extension && implicitExtensions.includes(extension)) | ||
filePath = filePath.slice(0, -extension.length) + maybeGetExplicitJsExtension(filePath, extension); | ||
return filePath[0] === "." || general_utils_1.isURL(filePath) ? filePath : `./${filePath}`; | ||
} | ||
function maybeGetExplicitJsExtension(filePath, resolvedExtension) { | ||
const moduleExtension = path_1.default.extname(moduleName); | ||
if (moduleExtension && !explicitExtensions.includes(moduleExtension)) | ||
return ""; | ||
return path_1.default.basename(moduleName, moduleExtension) === path_1.default.basename(filePath, resolvedExtension) | ||
? moduleExtension | ||
: ""; | ||
} | ||
function getStatementTags() { | ||
@@ -119,1 +132,2 @@ var _a, _b, _c; | ||
exports.resolvePathAndUpdateNode = resolvePathAndUpdateNode; | ||
// endregion |
{ | ||
"name": "typescript-transform-paths", | ||
"version": "2.2.1", | ||
"version": "2.2.2", | ||
"description": "Transforms module resolution paths using TypeScript path mapping", | ||
@@ -5,0 +5,0 @@ "keywords": [ |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
51571
505