gitnexus 1.6.5-rc.16 → 1.6.5-rc.17
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.
|
@@ -28,3 +28,8 @@ export declare const resolveImportPath: (currentFile: string, importPath: string
|
|
|
28
28
|
export declare function resolveStandard(rawImportPath: string, filePath: string, ctx: ResolveCtx, language: SupportedLanguages): ImportResult;
|
|
29
29
|
/** Create a reusable standard-resolution strategy for a given language. */
|
|
30
30
|
export declare function createStandardStrategy(language: SupportedLanguages): ImportResolverStrategy;
|
|
31
|
+
/**
|
|
32
|
+
* Strip a JS-family extension from a path, returning the stem.
|
|
33
|
+
* Returns `null` if the path does not end with a JS-family extension.
|
|
34
|
+
*/
|
|
35
|
+
export declare function stripJsExtension(path: string): string | null;
|
|
@@ -108,7 +108,20 @@ export const resolveImportPath = (currentFile, importPath, allFiles, allFileList
|
|
|
108
108
|
const basePath = currentDir.join('/');
|
|
109
109
|
if (importPath.startsWith('.')) {
|
|
110
110
|
const resolved = tryResolveWithExtensions(basePath, allFiles);
|
|
111
|
-
|
|
111
|
+
if (resolved)
|
|
112
|
+
return cache(resolved);
|
|
113
|
+
// TypeScript ESM: imports use .js/.jsx/.mjs/.cjs but source files are
|
|
114
|
+
// .ts/.tsx/.mts/.cts. Strip the JS-family extension and re-resolve.
|
|
115
|
+
// NOTE: This fallback only applies to relative imports. Path alias imports
|
|
116
|
+
// (e.g. @/utils.js via tsconfig paths) do not yet strip .js extensions —
|
|
117
|
+
// that is a known limitation tracked for follow-up.
|
|
118
|
+
if (language === SupportedLanguages.TypeScript || language === SupportedLanguages.JavaScript) {
|
|
119
|
+
const stripped = stripJsExtension(basePath);
|
|
120
|
+
if (stripped !== null) {
|
|
121
|
+
return cache(tryResolveWithExtensions(stripped, allFiles));
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
return cache(null);
|
|
112
125
|
}
|
|
113
126
|
// ---- Generic package/absolute import resolution (suffix matching) ----
|
|
114
127
|
// Java wildcards are handled in processImports, not here
|
|
@@ -140,3 +153,16 @@ export function resolveStandard(rawImportPath, filePath, ctx, language) {
|
|
|
140
153
|
export function createStandardStrategy(language) {
|
|
141
154
|
return (raw, fp, ctx) => resolveStandard(raw, fp, ctx, language);
|
|
142
155
|
}
|
|
156
|
+
// ============================================================================
|
|
157
|
+
// ESM extension helpers
|
|
158
|
+
// ============================================================================
|
|
159
|
+
/** JS-family extensions that TypeScript ESM maps to TS equivalents. */
|
|
160
|
+
const JS_EXTENSION_PATTERN = /\.(js|jsx|mjs|cjs)$/;
|
|
161
|
+
/**
|
|
162
|
+
* Strip a JS-family extension from a path, returning the stem.
|
|
163
|
+
* Returns `null` if the path does not end with a JS-family extension.
|
|
164
|
+
*/
|
|
165
|
+
export function stripJsExtension(path) {
|
|
166
|
+
const match = JS_EXTENSION_PATTERN.exec(path);
|
|
167
|
+
return match ? path.slice(0, -match[0].length) : null;
|
|
168
|
+
}
|
package/package.json
CHANGED