Skip to content

Commit 99bbe17

Browse files
What's yer path? (RooCodeInc#3047)
* update extension imports to use aliasing * changeset
1 parent b3b7b9d commit 99bbe17

File tree

82 files changed

+311
-270
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

82 files changed

+311
-270
lines changed

.changeset/smooth-poems-beam.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"claude-dev": minor
3+
---
4+
5+
Update the extension import paths to use aliasing

esbuild.js

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,11 +26,41 @@ const aliasResolverPlugin = {
2626
const aliasRegex = new RegExp(`^${alias}($|/.*)`)
2727
build.onResolve({ filter: aliasRegex }, (args) => {
2828
const importPath = args.path.replace(alias, aliasPath)
29+
30+
// First, check if the path exists as is
31+
if (fs.existsSync(importPath)) {
32+
const stats = fs.statSync(importPath)
33+
if (stats.isDirectory()) {
34+
// If it's a directory, try to find index files
35+
const extensions = [".ts", ".tsx", ".js", ".jsx"]
36+
for (const ext of extensions) {
37+
const indexFile = path.join(importPath, `index${ext}`)
38+
if (fs.existsSync(indexFile)) {
39+
return { path: indexFile }
40+
}
41+
}
42+
} else {
43+
// It's a file that exists, so return it
44+
return { path: importPath }
45+
}
46+
}
47+
48+
// If the path doesn't exist, try appending extensions
49+
const extensions = [".ts", ".tsx", ".js", ".jsx"]
50+
for (const ext of extensions) {
51+
const pathWithExtension = `${importPath}${ext}`
52+
if (fs.existsSync(pathWithExtension)) {
53+
return { path: pathWithExtension }
54+
}
55+
}
56+
57+
// If nothing worked, return the original path and let esbuild handle the error
2958
return { path: importPath }
3059
})
3160
})
3261
},
3362
}
63+
3464
const esbuildProblemMatcherPlugin = {
3565
name: "esbuild-problem-matcher",
3666

package-lock.json

Lines changed: 31 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -350,6 +350,7 @@
350350
"sinon": "^19.0.2",
351351
"ts-node": "^10.9.2",
352352
"ts-proto": "^2.6.1",
353+
"tsconfig-paths": "^4.2.0",
353354
"typescript": "^5.4.5"
354355
},
355356
"dependencies": {

src/api/providers/__tests__/ollama.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import "should"
33
import sinon from "sinon"
44
import { Anthropic } from "@anthropic-ai/sdk"
55
import { OllamaHandler } from "../ollama"
6-
import { ApiHandlerOptions } from "../../../shared/api"
6+
import { ApiHandlerOptions } from "@shared/api"
77
import axios from "axios"
88

99
describe("OllamaHandler", () => {

src/api/providers/anthropic.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { Anthropic } from "@anthropic-ai/sdk"
22
import { Stream as AnthropicStream } from "@anthropic-ai/sdk/streaming"
33
import { withRetry } from "../retry"
4-
import { anthropicDefaultModelId, AnthropicModelId, anthropicModels, ApiHandlerOptions, ModelInfo } from "../../shared/api"
4+
import { anthropicDefaultModelId, AnthropicModelId, anthropicModels, ApiHandlerOptions, ModelInfo } from "@shared/api"
55
import { ApiHandler } from "../index"
66
import { ApiStream } from "../transform/stream"
77

src/api/providers/asksage.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import {
77
askSageModels,
88
askSageDefaultModelId,
99
askSageDefaultURL,
10-
} from "../../shared/api"
10+
} from "@shared/api"
1111
import { ApiStream } from "../transform/stream"
1212

1313
type AskSageRequest = {

src/api/providers/bedrock.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import { Anthropic } from "@anthropic-ai/sdk"
33
import { withRetry } from "../retry"
44
import { ApiHandler } from "../"
55
import { convertToR1Format } from "../transform/r1-format"
6-
import { ApiHandlerOptions, bedrockDefaultModelId, BedrockModelId, bedrockModels, ModelInfo } from "../../shared/api"
6+
import { ApiHandlerOptions, bedrockDefaultModelId, BedrockModelId, bedrockModels, ModelInfo } from "@shared/api"
77
import { calculateApiCostOpenAI } from "../../utils/cost"
88
import { ApiStream } from "../transform/stream"
99
import { fromNodeProviderChain } from "@aws-sdk/credential-providers"

src/api/providers/cline.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { Anthropic } from "@anthropic-ai/sdk"
22
import OpenAI from "openai"
33
import { ApiHandler } from "../"
4-
import { ApiHandlerOptions, ModelInfo, openRouterDefaultModelId, openRouterDefaultModelInfo } from "../../shared/api"
4+
import { ApiHandlerOptions, ModelInfo, openRouterDefaultModelId, openRouterDefaultModelInfo } from "@shared/api"
55
import { createOpenRouterStream } from "../transform/openrouter-stream"
66
import { ApiStream, ApiStreamUsageChunk } from "../transform/stream"
77
import axios from "axios"

src/api/providers/deepseek.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import { Anthropic } from "@anthropic-ai/sdk"
22
import OpenAI from "openai"
33
import { withRetry } from "../retry"
44
import { ApiHandler } from "../"
5-
import { ApiHandlerOptions, DeepSeekModelId, ModelInfo, deepSeekDefaultModelId, deepSeekModels } from "../../shared/api"
5+
import { ApiHandlerOptions, DeepSeekModelId, ModelInfo, deepSeekDefaultModelId, deepSeekModels } from "@shared/api"
66
import { calculateApiCostOpenAI } from "../../utils/cost"
77
import { convertToOpenAiMessages } from "../transform/openai-format"
88
import { ApiStream } from "../transform/stream"

0 commit comments

Comments
 (0)