Skip to content

Commit a0554d8

Browse files
committed
cr
1 parent 63cb5a2 commit a0554d8

File tree

3 files changed

+60
-9
lines changed

3 files changed

+60
-9
lines changed

.changeset/config.json

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,7 @@
1717
"baseBranch": "main",
1818
"updateInternalDependencies": "patch",
1919
"ignore": [
20-
"examples",
21-
"@langchain/build",
22-
"@langchain/eslint"
20+
"examples"
2321
],
2422
"___experimentalUnsafeOptions_WILL_CHANGE_IN_PATCH": {
2523
"onlyUpdatePeerDependentsWhenOutOfRange": true

.changeset/ready-cars-pick.md

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
---
2+
"@langchain/azure-dynamic-sessions": patch
3+
"@langchain/google-cloud-sql-pg": patch
4+
"@langchain/google-vertexai-web": patch
5+
"@langchain/google-vertexai": patch
6+
"@langchain/azure-cosmosdb": patch
7+
"@langchain/google-webauth": patch
8+
"@langchain/baidu-qianfan": patch
9+
"@langchain/google-common": patch
10+
"@langchain/mixedbread-ai": patch
11+
"@langchain/google-gauth": patch
12+
"@langchain/google-genai": patch
13+
"@langchain/cloudflare": patch
14+
"@langchain/anthropic": patch
15+
"@langchain/mistralai": patch
16+
"@langchain/cerebras": patch
17+
"@langchain/deepseek": patch
18+
"@langchain/pinecone": patch
19+
"@langchain/weaviate": patch
20+
"@langchain/mongodb": patch
21+
"@langchain/cohere": patch
22+
"@langchain/ollama": patch
23+
"@langchain/openai": patch
24+
"@langchain/qdrant": patch
25+
"@langchain/tavily": patch
26+
"@langchain/yandex": patch
27+
"@langchain/nomic": patch
28+
"@langchain/redis": patch
29+
"@langchain/standard-tests": patch
30+
"@langchain/groq": patch
31+
"@langchain/textsplitters": patch
32+
"@langchain/aws": patch
33+
"@langchain/exa": patch
34+
"@langchain/xai": patch
35+
"@langchain/mcp-adapters": patch
36+
"@langchain/community": patch
37+
"@langchain/classic": patch
38+
"@langchain/core": patch
39+
"@langchain/eslint": patch
40+
"@langchain/build": patch
41+
"langchain": patch
42+
---
43+
44+
fix commonjs compatibility

internal/build/plugins/barrel-dts.ts

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -177,7 +177,7 @@ async function generateBarrelFiles(
177177
packagePath: string,
178178
barrelFiles: Record<string, string>
179179
): Promise<void> {
180-
for (const [barrelPath] of Object.entries(barrelFiles)) {
180+
for (const [barrelPath, typesPath] of Object.entries(barrelFiles)) {
181181
const barrelFilePath = resolve(packagePath, `${barrelPath}.d.ts`);
182182

183183
// Ensure parent directory exists
@@ -186,8 +186,8 @@ async function generateBarrelFiles(
186186
fs.mkdirSync(parentDir, { recursive: true });
187187
}
188188

189-
// Calculate relative path from barrel file to the dist path
190-
const relativePath = calculateRelativePath(barrelPath);
189+
// Calculate relative path from barrel file to the dist types file (without extension)
190+
const relativePath = calculateRelativePath(barrelPath, typesPath);
191191

192192
// Generate the barrel file content
193193
const content = `export * from "${relativePath}";`;
@@ -198,16 +198,25 @@ async function generateBarrelFiles(
198198
}
199199

200200
/**
201-
* Calculate the relative path from barrel file location to the dist path
201+
* Calculate the relative path from barrel file location to the dist types file
202202
* Returns path without file extension for proper TypeScript module resolution
203203
*/
204-
function calculateRelativePath(barrelPath: string): string {
204+
function calculateRelativePath(barrelPath: string, typesPath: string): string {
205205
const barrelDepth = barrelPath.split("/").length - 1;
206206

207207
// Build the relative path with appropriate ../
208208
const upLevels = barrelDepth > 0 ? "../".repeat(barrelDepth) : "./";
209209

210-
return `${upLevels}dist/${barrelPath}`;
210+
// Remove the leading ./ and file extension from typesPath
211+
const cleanPath = typesPath
212+
.replace(/^\.\//, "")
213+
.replace(/\.d\.cts$/, "")
214+
.replace(/\.d\.ts$/, "")
215+
.replace(/\.cts$/, "")
216+
.replace(/\.ts$/, "")
217+
.replace(/\.js$/, "");
218+
219+
return `${upLevels}${cleanPath}`;
211220
}
212221

213222
/**

0 commit comments

Comments
 (0)