gt 2.14.36 → 2.14.37
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +6 -0
- package/dist/generated/version.d.ts +1 -1
- package/dist/generated/version.js +1 -1
- package/dist/generated/version.js.map +1 -1
- package/dist/react/jsx/utils/resolveImportPath.d.ts +1 -1
- package/dist/react/jsx/utils/resolveImportPath.js +30 -9
- package/dist/react/jsx/utils/resolveImportPath.js.map +1 -1
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,11 @@
|
|
|
1
1
|
# gtx-cli
|
|
2
2
|
|
|
3
|
+
## 2.14.37
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [#1425](https://github.com/generaltranslation/gt/pull/1425) [`a5e6975`](https://github.com/generaltranslation/gt/commit/a5e697561776466763ee1d6cae1f4b905eed581d) Thanks [@ErnestM1234](https://github.com/ErnestM1234)! - Resolve TypeScript path aliases that point to directory index barrel files during CLI extraction.
|
|
8
|
+
|
|
3
9
|
## 2.14.36
|
|
4
10
|
|
|
5
11
|
### Patch Changes
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const PACKAGE_VERSION = "2.14.
|
|
1
|
+
export declare const PACKAGE_VERSION = "2.14.37";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"version.js","names":[],"sources":["../../src/generated/version.ts"],"sourcesContent":["// This file is auto-generated. Do not edit manually.\nexport const PACKAGE_VERSION = '2.14.
|
|
1
|
+
{"version":3,"file":"version.js","names":[],"sources":["../../src/generated/version.ts"],"sourcesContent":["// This file is auto-generated. Do not edit manually.\nexport const PACKAGE_VERSION = '2.14.37';\n"],"mappings":";AACA,MAAa,kBAAkB"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ParsingConfigOptions } from '../../../types/parsing.js';
|
|
1
|
+
import type { ParsingConfigOptions } from '../../../types/parsing.js';
|
|
2
2
|
/**
|
|
3
3
|
* Resolves import paths to absolute file paths using battle-tested libraries.
|
|
4
4
|
* Handles relative paths, TypeScript paths, and node module resolution.
|
|
@@ -5,6 +5,25 @@ import resolve from "resolve";
|
|
|
5
5
|
import enhancedResolve from "enhanced-resolve";
|
|
6
6
|
//#region src/react/jsx/utils/resolveImportPath.ts
|
|
7
7
|
const { ResolverFactory } = enhancedResolve;
|
|
8
|
+
function resolveExistingPath(filePath, extensions) {
|
|
9
|
+
if (!filePath) return null;
|
|
10
|
+
if (fs.existsSync(filePath)) {
|
|
11
|
+
const stats = fs.statSync(filePath);
|
|
12
|
+
if (stats.isFile()) return filePath;
|
|
13
|
+
if (stats.isDirectory()) {
|
|
14
|
+
for (const ext of extensions) {
|
|
15
|
+
const indexPath = path.join(filePath, `index${ext}`);
|
|
16
|
+
if (fs.existsSync(indexPath) && fs.statSync(indexPath).isFile()) return indexPath;
|
|
17
|
+
}
|
|
18
|
+
return null;
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
for (const ext of extensions) {
|
|
22
|
+
const resolvedWithExt = filePath + ext;
|
|
23
|
+
if (fs.existsSync(resolvedWithExt) && fs.statSync(resolvedWithExt).isFile()) return resolvedWithExt;
|
|
24
|
+
}
|
|
25
|
+
return null;
|
|
26
|
+
}
|
|
8
27
|
/**
|
|
9
28
|
* Resolves import paths to absolute file paths using battle-tested libraries.
|
|
10
29
|
* Handles relative paths, TypeScript paths, and node module resolution.
|
|
@@ -29,23 +48,25 @@ function resolveImportPath(currentFile, importPath, parsingOptions, resolveImpor
|
|
|
29
48
|
const tsConfigResult = loadConfig(basedir);
|
|
30
49
|
if (tsConfigResult.resultType === "success") {
|
|
31
50
|
const matchPath = createMatchPath(tsConfigResult.absoluteBaseUrl, tsConfigResult.paths, mainFields);
|
|
32
|
-
let tsResolved = matchPath(importPath);
|
|
33
|
-
|
|
34
|
-
|
|
51
|
+
let tsResolved = matchPath(importPath, void 0, void 0, extensions);
|
|
52
|
+
const resolvedTsPath = resolveExistingPath(tsResolved, extensions);
|
|
53
|
+
if (resolvedTsPath) {
|
|
54
|
+
result = resolvedTsPath;
|
|
35
55
|
resolveImportPathCache.set(cacheKey, result);
|
|
36
56
|
return result;
|
|
37
57
|
}
|
|
58
|
+
const tsResolvedBase = matchPath(importPath);
|
|
38
59
|
for (const ext of extensions) {
|
|
39
60
|
tsResolved = matchPath(importPath + ext);
|
|
40
|
-
|
|
41
|
-
|
|
61
|
+
const resolvedPathWithExt = resolveExistingPath(tsResolved, extensions);
|
|
62
|
+
if (resolvedPathWithExt) {
|
|
63
|
+
result = resolvedPathWithExt;
|
|
42
64
|
resolveImportPathCache.set(cacheKey, result);
|
|
43
65
|
return result;
|
|
44
66
|
}
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
if (fs.existsSync(resolvedWithExt)) {
|
|
67
|
+
if (tsResolvedBase) {
|
|
68
|
+
const resolvedWithExt = resolveExistingPath(tsResolvedBase + ext, extensions);
|
|
69
|
+
if (resolvedWithExt) {
|
|
49
70
|
result = resolvedWithExt;
|
|
50
71
|
resolveImportPathCache.set(cacheKey, result);
|
|
51
72
|
return result;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"resolveImportPath.js","names":[],"sources":["../../../../src/react/jsx/utils/resolveImportPath.ts"],"sourcesContent":["import { createMatchPath, loadConfig } from 'tsconfig-paths';\nimport { ParsingConfigOptions } from '../../../types/parsing.js';\nimport fs from 'node:fs';\nimport path from 'node:path';\nimport resolve from 'resolve';\nimport enhancedResolve from 'enhanced-resolve';\nimport type { FileSystem } from 'enhanced-resolve';\nconst { ResolverFactory } = enhancedResolve;\n\n/**\n * Resolves import paths to absolute file paths using battle-tested libraries.\n * Handles relative paths, TypeScript paths, and node module resolution.\n *\n * Examples:\n * - './constants' -> '/full/path/to/constants.ts'\n * - '@/components/ui/button' -> '/full/path/to/src/components/ui/button.tsx'\n * - '@shared/utils' -> '/full/path/to/packages/utils/index.ts'\n */\nexport function resolveImportPath(\n currentFile: string,\n importPath: string,\n parsingOptions: ParsingConfigOptions,\n resolveImportPathCache: Map<string, string | null>\n): string | null {\n // Check cache first\n const cacheKey = `${currentFile}::${importPath}`;\n if (resolveImportPathCache.has(cacheKey)) {\n return resolveImportPathCache.get(cacheKey)!;\n }\n\n const basedir = path.dirname(currentFile);\n const extensions = ['.tsx', '.ts', '.jsx', '.js'];\n const mainFields = ['module', 'main'];\n\n let result: string | null = null;\n\n // 1. Try tsconfig-paths resolution first (handles TypeScript path mapping)\n const tsConfigResult = loadConfig(basedir);\n if (tsConfigResult.resultType === 'success') {\n const matchPath = createMatchPath(\n tsConfigResult.absoluteBaseUrl,\n tsConfigResult.paths,\n mainFields\n );\n\n // First try without any extension\n let tsResolved = matchPath(importPath);\n
|
|
1
|
+
{"version":3,"file":"resolveImportPath.js","names":[],"sources":["../../../../src/react/jsx/utils/resolveImportPath.ts"],"sourcesContent":["import { createMatchPath, loadConfig } from 'tsconfig-paths';\nimport type { ParsingConfigOptions } from '../../../types/parsing.js';\nimport fs from 'node:fs';\nimport path from 'node:path';\nimport resolve from 'resolve';\nimport enhancedResolve from 'enhanced-resolve';\nimport type { FileSystem } from 'enhanced-resolve';\nconst { ResolverFactory } = enhancedResolve;\n\nfunction resolveExistingPath(\n filePath: string | undefined,\n extensions: string[]\n): string | null {\n if (!filePath) {\n return null;\n }\n\n if (fs.existsSync(filePath)) {\n const stats = fs.statSync(filePath);\n if (stats.isFile()) {\n return filePath;\n }\n\n if (stats.isDirectory()) {\n for (const ext of extensions) {\n const indexPath = path.join(filePath, `index${ext}`);\n if (fs.existsSync(indexPath) && fs.statSync(indexPath).isFile()) {\n return indexPath;\n }\n }\n return null;\n }\n }\n\n for (const ext of extensions) {\n const resolvedWithExt = filePath + ext;\n if (\n fs.existsSync(resolvedWithExt) &&\n fs.statSync(resolvedWithExt).isFile()\n ) {\n return resolvedWithExt;\n }\n }\n\n return null;\n}\n\n/**\n * Resolves import paths to absolute file paths using battle-tested libraries.\n * Handles relative paths, TypeScript paths, and node module resolution.\n *\n * Examples:\n * - './constants' -> '/full/path/to/constants.ts'\n * - '@/components/ui/button' -> '/full/path/to/src/components/ui/button.tsx'\n * - '@shared/utils' -> '/full/path/to/packages/utils/index.ts'\n */\nexport function resolveImportPath(\n currentFile: string,\n importPath: string,\n parsingOptions: ParsingConfigOptions,\n resolveImportPathCache: Map<string, string | null>\n): string | null {\n // Check cache first\n const cacheKey = `${currentFile}::${importPath}`;\n if (resolveImportPathCache.has(cacheKey)) {\n return resolveImportPathCache.get(cacheKey)!;\n }\n\n const basedir = path.dirname(currentFile);\n const extensions = ['.tsx', '.ts', '.jsx', '.js'];\n const mainFields = ['module', 'main'];\n\n let result: string | null = null;\n\n // 1. Try tsconfig-paths resolution first (handles TypeScript path mapping)\n const tsConfigResult = loadConfig(basedir);\n if (tsConfigResult.resultType === 'success') {\n const matchPath = createMatchPath(\n tsConfigResult.absoluteBaseUrl,\n tsConfigResult.paths,\n mainFields\n );\n\n // First try without any extension\n let tsResolved = matchPath(importPath, undefined, undefined, extensions);\n const resolvedTsPath = resolveExistingPath(tsResolved, extensions);\n if (resolvedTsPath) {\n result = resolvedTsPath;\n resolveImportPathCache.set(cacheKey, result);\n return result;\n }\n\n // Then try with each extension\n const tsResolvedBase = matchPath(importPath);\n for (const ext of extensions) {\n tsResolved = matchPath(importPath + ext);\n const resolvedPathWithExt = resolveExistingPath(tsResolved, extensions);\n if (resolvedPathWithExt) {\n result = resolvedPathWithExt;\n resolveImportPathCache.set(cacheKey, result);\n return result;\n }\n\n // Also try the resolved path with extension\n if (tsResolvedBase) {\n const resolvedWithExt = resolveExistingPath(\n tsResolvedBase + ext,\n extensions\n );\n if (resolvedWithExt) {\n result = resolvedWithExt;\n resolveImportPathCache.set(cacheKey, result);\n return result;\n }\n }\n }\n }\n\n // 2. Try enhanced-resolve (handles package.json exports field and modern resolution)\n try {\n const resolver = ResolverFactory.createResolver({\n useSyncFileSystemCalls: true,\n fileSystem: fs as unknown as FileSystem,\n extensions,\n // Include 'development' condition to resolve to source files in monorepos\n conditionNames: parsingOptions.conditionNames, // defaults to ['browser', 'module', 'import', 'require', 'default']. See generateSettings.ts for more details\n exportsFields: ['exports'],\n mainFields,\n });\n\n const resolved = resolver.resolveSync({}, basedir, importPath);\n if (resolved) {\n result = resolved;\n resolveImportPathCache.set(cacheKey, result);\n return result;\n }\n } catch {\n // Fall through to next resolution strategy\n }\n\n // 3. Fallback to Node.js resolution (handles relative paths and node_modules)\n try {\n result = resolve.sync(importPath, { basedir, extensions });\n resolveImportPathCache.set(cacheKey, result);\n return result;\n } catch {\n // If resolution fails, try to manually replace .js/.jsx with .ts/.tsx for source files\n if (importPath.endsWith('.js')) {\n const tsPath = importPath.replace(/\\.js$/, '.ts');\n try {\n result = resolve.sync(tsPath, { basedir, extensions });\n resolveImportPathCache.set(cacheKey, result);\n return result;\n } catch {\n // Continue to return null\n }\n } else if (importPath.endsWith('.jsx')) {\n const tsxPath = importPath.replace(/\\.jsx$/, '.tsx');\n try {\n result = resolve.sync(tsxPath, { basedir, extensions });\n resolveImportPathCache.set(cacheKey, result);\n return result;\n } catch {\n // Continue to return null\n }\n }\n resolveImportPathCache.set(cacheKey, null);\n return null;\n }\n}\n"],"mappings":";;;;;;AAOA,MAAM,EAAE,oBAAoB;AAE5B,SAAS,oBACP,UACA,YACe;AACf,KAAI,CAAC,SACH,QAAO;AAGT,KAAI,GAAG,WAAW,SAAS,EAAE;EAC3B,MAAM,QAAQ,GAAG,SAAS,SAAS;AACnC,MAAI,MAAM,QAAQ,CAChB,QAAO;AAGT,MAAI,MAAM,aAAa,EAAE;AACvB,QAAK,MAAM,OAAO,YAAY;IAC5B,MAAM,YAAY,KAAK,KAAK,UAAU,QAAQ,MAAM;AACpD,QAAI,GAAG,WAAW,UAAU,IAAI,GAAG,SAAS,UAAU,CAAC,QAAQ,CAC7D,QAAO;;AAGX,UAAO;;;AAIX,MAAK,MAAM,OAAO,YAAY;EAC5B,MAA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