typescript-transform-paths
Advanced tools
Comparing version 3.4.9 to 3.4.10-1723086173.5a2b0c9
@@ -5,2 +5,19 @@ # Changelog | ||
## v3.4.10-1723086173.5a2b0c9 | ||
[compare changes](https://github.com/LeDDGroup/typescript-transform-paths/compare/v3.4.9...v3.4.10-1723086173.5a2b0c9) | ||
### 📖 Documentation | ||
- Update readme ([5a2b0c9](https://github.com/LeDDGroup/typescript-transform-paths/commit/5a2b0c9)) | ||
### 🏡 Chore | ||
- Update dependencies ([#226](https://github.com/LeDDGroup/typescript-transform-paths/pull/226)) | ||
- Replace standard-version with changelogen ([4134b5d](https://github.com/LeDDGroup/typescript-transform-paths/commit/4134b5d)) | ||
### ❤️ Contributors | ||
- Daniel Perez Alvarez <danielpza@protonmail.com> | ||
### [3.4.9](https://github.com/LeDDGroup/typescript-transform-paths/compare/v3.4.8...v3.4.9) (2024-08-07) | ||
@@ -7,0 +24,0 @@ |
@@ -13,4 +13,3 @@ "use strict"; | ||
function createHarmonyFactory(context) { | ||
var _a; | ||
return new Proxy((_a = context.tsFactory) !== null && _a !== void 0 ? _a : context.tsInstance, { | ||
return new Proxy(context.tsFactory ?? context.tsInstance, { | ||
get(target, prop) { | ||
@@ -17,0 +16,0 @@ if (versions_1.TsThreeEight.predicate(context)) { |
@@ -16,5 +16,5 @@ "use strict"; | ||
exports.nxTransformerPlugin = { | ||
before: (pluginConfig, program) => (pluginConfig === null || pluginConfig === void 0 ? void 0 : pluginConfig.afterDeclarations) ? voidTransformer : (0, transformer_1.default)(program, { ...pluginConfig }), | ||
afterDeclarations: (pluginConfig, program) => !(pluginConfig === null || pluginConfig === void 0 ? void 0 : pluginConfig.afterDeclarations) ? voidTransformer : (0, transformer_1.default)(program, { ...pluginConfig }), | ||
before: (pluginConfig, program) => pluginConfig?.afterDeclarations ? voidTransformer : (0, transformer_1.default)(program, { ...pluginConfig }), | ||
afterDeclarations: (pluginConfig, program) => !pluginConfig?.afterDeclarations ? voidTransformer : (0, transformer_1.default)(program, { ...pluginConfig }), | ||
}; | ||
//# sourceMappingURL=nx-transformer-plugin.js.map |
@@ -30,9 +30,8 @@ "use strict"; | ||
function mergeTransformers(baseTransformers, transformers) { | ||
var _a, _b, _c, _d; | ||
const res = { | ||
...((baseTransformers.before || transformers.before) && { | ||
before: [...((_a = transformers.before) !== null && _a !== void 0 ? _a : []), ...((_b = baseTransformers.before) !== null && _b !== void 0 ? _b : [])], | ||
before: [...(transformers.before ?? []), ...(baseTransformers.before ?? [])], | ||
}), | ||
...((baseTransformers.afterDeclarations || transformers.afterDeclarations) && { | ||
afterDeclarations: [...((_c = transformers.afterDeclarations) !== null && _c !== void 0 ? _c : []), ...((_d = baseTransformers.afterDeclarations) !== null && _d !== void 0 ? _d : [])], | ||
afterDeclarations: [...(transformers.afterDeclarations ?? []), ...(baseTransformers.afterDeclarations ?? [])], | ||
}), | ||
@@ -82,3 +81,3 @@ }; | ||
} | ||
catch (_a) { | ||
catch { | ||
throw new Error(`Cannot resolve ts-node. Make sure ts-node is installed before using typescript-transform-paths/register`); | ||
@@ -85,0 +84,0 @@ } |
@@ -18,3 +18,2 @@ "use strict"; | ||
function getTsProperties(args) { | ||
var _a, _b; | ||
let tsInstance; | ||
@@ -26,3 +25,3 @@ let fileNames; | ||
const { 0: program, 2: extras, 3: manualTransformOptions } = args; | ||
tsInstance = (_a = extras === null || extras === void 0 ? void 0 : extras.ts) !== null && _a !== void 0 ? _a : typescript_1.default; | ||
tsInstance = extras?.ts ?? typescript_1.default; | ||
if (program) | ||
@@ -51,3 +50,3 @@ compilerOptions = program.getCompilerOptions(); | ||
!program || | ||
(fileNames.length > 1 && (program === null || program === void 0 ? void 0 : program.getRootFileNames().length) === 1) || | ||
(fileNames.length > 1 && program?.getRootFileNames().length === 1) || | ||
(!compilerOptions.paths && tsNodeProps.compilerOptions.paths) | ||
@@ -60,3 +59,3 @@ ? types_1.TsNodeState.Stripped | ||
: { | ||
...((_b = program === null || program === void 0 ? void 0 : program.getCompilerOptions()) !== null && _b !== void 0 ? _b : {}), | ||
...(program?.getCompilerOptions() ?? {}), | ||
...tsNodeProps.compilerOptions, | ||
@@ -81,7 +80,6 @@ }; | ||
return (transformationContext) => { | ||
var _a, _b, _c; | ||
// prettier-ignore | ||
const { tsInstance, compilerOptions, fileNames, runMode, tsNodeState } = getTsProperties([program, pluginConfig, transformerExtras, manualTransformOptions]); | ||
const rootDirs = (_a = compilerOptions.rootDirs) === null || _a === void 0 ? void 0 : _a.filter(path_1.default.isAbsolute); | ||
const config = pluginConfig !== null && pluginConfig !== void 0 ? pluginConfig : {}; | ||
const rootDirs = compilerOptions.rootDirs?.filter(path_1.default.isAbsolute); | ||
const config = pluginConfig ?? {}; | ||
const getCanonicalFileName = tsInstance.createGetCanonicalFileName(tsInstance.sys.useCaseSensitiveFileNames); | ||
@@ -113,3 +111,3 @@ /* Add supplements for various run modes */ | ||
tsNodeState, | ||
excludeMatchers: (_b = config.exclude) === null || _b === void 0 ? void 0 : _b.map((globPattern) => new minimatch_1.Minimatch(globPattern, { matchBase: true })), | ||
excludeMatchers: config.exclude?.map((globPattern) => new minimatch_1.Minimatch(globPattern, { matchBase: true })), | ||
outputFileNamesCache: new Map(), | ||
@@ -119,3 +117,3 @@ // Get paths patterns appropriate for TS compiler version | ||
(tryParsePatterns | ||
? ((_c = configFile === null || configFile === void 0 ? void 0 : configFile.configFileSpecs) === null || _c === void 0 ? void 0 : _c.pathPatterns) || tryParsePatterns(paths) | ||
? configFile?.configFileSpecs?.pathPatterns || tryParsePatterns(paths) | ||
: tsInstance.getOwnKeys(paths)), | ||
@@ -122,0 +120,0 @@ }; |
@@ -6,3 +6,2 @@ "use strict"; | ||
function elideImportOrExportDeclaration(context, node, newModuleSpecifier, resolver) { | ||
var _a; | ||
const { tsInstance, factory } = context; | ||
@@ -14,3 +13,3 @@ const { compilerOptions } = context; | ||
isIdentifier, isExportSpecifier, } = tsInstance; | ||
const isNamespaceExport = (_a = tsInstance.isNamespaceExport) !== null && _a !== void 0 ? _a : ((node) => node.kind === SyntaxKind.NamespaceExport); | ||
const isNamespaceExport = tsInstance.isNamespaceExport ?? ((node) => node.kind === SyntaxKind.NamespaceExport); | ||
if (tsInstance.isImportDeclaration(node)) { | ||
@@ -17,0 +16,0 @@ // Do not elide a side-effect only import declaration. |
@@ -46,3 +46,3 @@ "use strict"; | ||
} | ||
catch (_a) { } | ||
catch { } | ||
} | ||
@@ -60,3 +60,3 @@ function getIsFsCaseSensitive() { | ||
} | ||
catch (_a) { | ||
catch { | ||
} | ||
@@ -92,3 +92,3 @@ finally { | ||
} | ||
catch (_a) { | ||
catch { | ||
if (!getIsFsCaseSensitive()) { | ||
@@ -95,0 +95,0 @@ const matchPortion = getMatchPortion(from, to); |
@@ -44,5 +44,4 @@ "use strict"; | ||
function getPathDetail(moduleName, resolvedModule) { | ||
var _a, _b; | ||
let resolvedFileName = (_a = resolvedModule.originalPath) !== null && _a !== void 0 ? _a : resolvedModule.resolvedFileName; | ||
const implicitPackageIndex = (_b = resolvedModule.packageId) === null || _b === void 0 ? void 0 : _b.subModuleName; | ||
let resolvedFileName = resolvedModule.originalPath ?? resolvedModule.resolvedFileName; | ||
const implicitPackageIndex = resolvedModule.packageId?.subModuleName; | ||
const resolvedDir = implicitPackageIndex | ||
@@ -132,3 +131,3 @@ ? (0, typescript_1.removeSuffix)(resolvedFileName, `/${implicitPackageIndex}`) | ||
/* Determine output filename */ | ||
let outputBaseName = resolvedBaseNameNoExtension !== null && resolvedBaseNameNoExtension !== void 0 ? resolvedBaseNameNoExtension : ""; | ||
let outputBaseName = resolvedBaseNameNoExtension ?? ""; | ||
if (indexType === IndexType.Implicit) | ||
@@ -135,0 +134,0 @@ outputBaseName = outputBaseName.replace(/(\/index$)|(^index$)/, ""); |
@@ -46,6 +46,5 @@ "use strict"; | ||
function getStatementTags() { | ||
var _a; | ||
let targetNode = tsInstance.isStatement(node) | ||
? node | ||
: ((_a = tsInstance.findAncestor(node, tsInstance.isStatement)) !== null && _a !== void 0 ? _a : node); | ||
: (tsInstance.findAncestor(node, tsInstance.isStatement) ?? node); | ||
targetNode = tsInstance.getOriginalNode(targetNode); | ||
@@ -56,3 +55,3 @@ let jsDocTags; | ||
} | ||
catch (_b) { } | ||
catch { } | ||
const commentTags = new Map(); | ||
@@ -66,3 +65,3 @@ if (targetNode.pos >= 0) { | ||
} | ||
catch (_c) { } | ||
catch { } | ||
} | ||
@@ -78,3 +77,3 @@ const overridePath = findTag("transform-path"); | ||
return commentTags.get(expected) || true; | ||
if (!(jsDocTags === null || jsDocTags === void 0 ? void 0 : jsDocTags.length)) | ||
if (!jsDocTags?.length) | ||
return void 0; | ||
@@ -81,0 +80,0 @@ for (const tag of jsDocTags) { |
@@ -55,8 +55,7 @@ "use strict"; | ||
function getTsNodeRegistrationProperties(tsInstance) { | ||
var _a; | ||
let tsNodeSymbol; | ||
try { | ||
tsNodeSymbol = (_a = require("ts-node")) === null || _a === void 0 ? void 0 : _a["REGISTER_INSTANCE"]; | ||
tsNodeSymbol = require("ts-node")?.["REGISTER_INSTANCE"]; | ||
} | ||
catch (_b) { | ||
catch { | ||
return undefined; | ||
@@ -71,4 +70,4 @@ } | ||
: void 0; | ||
const fileNames = (pcl === null || pcl === void 0 ? void 0 : pcl.fileNames) || config.fileNames; | ||
const compilerOptions = Object.assign({}, config.options, options.compilerOptions, { outDir: pcl === null || pcl === void 0 ? void 0 : pcl.options.outDir }); | ||
const fileNames = pcl?.fileNames || config.fileNames; | ||
const compilerOptions = Object.assign({}, config.options, options.compilerOptions, { outDir: pcl?.options.outDir }); | ||
return { compilerOptions, fileNames, tsNodeOptions: options }; | ||
@@ -75,0 +74,0 @@ } |
@@ -84,7 +84,6 @@ "use strict"; | ||
return (0, utils_1.resolvePathAndUpdateNode)(this, node, node.moduleSpecifier.text, (p) => { | ||
var _a; | ||
// TODO - In next major version, we can remove this entirely due to TS PR 57223 | ||
// see: https://github.com/microsoft/TypeScript/pull/57223 | ||
// We should at least skip this if doing a minor version update if the ts version is high enough to not need it | ||
if (!this.isDeclarationFile && ((_a = node.importClause) === null || _a === void 0 ? void 0 : _a.namedBindings)) { | ||
if (!this.isDeclarationFile && node.importClause?.namedBindings) { | ||
const resolver = transformationContext.getEmitResolver(); | ||
@@ -91,0 +90,0 @@ // If run in "manual" mode without a Program, we won't have a resolver, so we can't elide |
{ | ||
"name": "typescript-transform-paths", | ||
"version": "3.4.9", | ||
"version": "3.4.10-1723086173.5a2b0c9", | ||
"description": "Transforms module resolution paths using TypeScript path mapping and/or custom paths", | ||
@@ -11,3 +11,3 @@ "main": "dist/index.js", | ||
"test": "yarn test/ install && yarn test/ add-package && yarn test/ test", | ||
"release": "standard-version", | ||
"release": "changelogen --release --push", | ||
"--------------": "", | ||
@@ -57,2 +57,3 @@ "format": "prettier --write .", | ||
"devDependencies": { | ||
"@tsconfig/node18": "^18.2.4", | ||
"@types/minimatch": "^5.1.2", | ||
@@ -62,4 +63,4 @@ "@types/node": "^18.19.43", | ||
"@types/ts-node": "npm:ts-node@^10.9.2", | ||
"changelogen": "^0.5.5", | ||
"prettier": "^3.3.3", | ||
"standard-version": "^9.5.0", | ||
"ts-patch": "^3.2.1", | ||
@@ -66,0 +67,0 @@ "typescript": "^5.5.4" |
@@ -203,6 +203,10 @@ # typescript-transform-paths | ||
- Package Manager: `yarn` (`yarn install`) | ||
- Format before commit: `prettier` (`yarn format`) | ||
- Commit messages: [Conventional Commit Specs](https://www.conventionalcommits.org/en/v1.0.0/) | ||
- Format before commit: `prettier` (`yarn run format`) | ||
- Releases: `standard-version` (`yarn run release`) | ||
- Releases: `changelogen` (`yarn release`) | ||
```shell | ||
GH_TOKEN=$(gh auth token) yarn release | ||
``` | ||
## Alternatives | ||
@@ -209,0 +213,0 @@ |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
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
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
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
226
140828
9
1614
1