Skip to content

Commit 06196cf

Browse files
Don't call me by my name (RooCodeInc#2982)
* add path aliases to the extension side * changeset
1 parent 1761c0e commit 06196cf

File tree

4 files changed

+41
-2
lines changed

4 files changed

+41
-2
lines changed

.changeset/green-impalas-sit.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+
Add aliasing to imports in the extension

esbuild.js

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,29 @@ const test = process.env.IS_TEST === "true"
99
/**
1010
* @type {import('esbuild').Plugin}
1111
*/
12+
const aliasResolverPlugin = {
13+
name: "alias-resolver",
14+
setup(build) {
15+
const aliases = {
16+
"@": path.resolve(__dirname, "src"),
17+
"@api": path.resolve(__dirname, "src/api"),
18+
"@core": path.resolve(__dirname, "src/core"),
19+
"@integrations": path.resolve(__dirname, "src/integrations"),
20+
"@services": path.resolve(__dirname, "src/services"),
21+
"@shared": path.resolve(__dirname, "src/shared"),
22+
"@utils": path.resolve(__dirname, "src/utils"),
23+
}
24+
25+
// For each alias entry, create a resolver
26+
Object.entries(aliases).forEach(([alias, aliasPath]) => {
27+
const aliasRegex = new RegExp(`^${alias}($|/.*)`)
28+
build.onResolve({ filter: aliasRegex }, (args) => {
29+
const importPath = args.path.replace(alias, aliasPath)
30+
return { path: importPath }
31+
})
32+
})
33+
},
34+
}
1235
const esbuildProblemMatcherPlugin = {
1336
name: "esbuild-problem-matcher",
1437

@@ -75,6 +98,7 @@ const extensionConfig = {
7598
},
7699
plugins: [
77100
copyWasmFiles,
101+
aliasResolverPlugin,
78102
/* add to the end of plugins array */
79103
esbuildProblemMatcherPlugin,
80104
{

src/core/task/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ import {
8888
import { getGlobalState } from "../storage/state"
8989
import { parseSlashCommands } from ".././slash-commands"
9090
import WorkspaceTracker from "../../integrations/workspace/WorkspaceTracker"
91-
import { McpHub } from "../../services/mcp/McpHub"
91+
import { McpHub } from "@services/mcp/McpHub"
9292

9393
export const cwd =
9494
vscode.workspace.workspaceFolders?.map((folder) => folder.uri.fsPath).at(0) ?? path.join(os.homedir(), "Desktop") // may or may not exist but fs checking existence would immediately ask for permission which would be bad UX, need to come up with a better solution

tsconfig.json

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,17 @@
1818
"strict": true,
1919
"target": "es2022",
2020
"useDefineForClassFields": true,
21-
"useUnknownInCatchVariables": false
21+
"useUnknownInCatchVariables": false,
22+
"baseUrl": ".",
23+
"paths": {
24+
"@/*": ["src/*"],
25+
"@api/*": ["src/api/*"],
26+
"@core/*": ["src/core/*"],
27+
"@integrations/*": ["src/integrations/*"],
28+
"@services/*": ["src/services/*"],
29+
"@shared/*": ["src/shared/*"],
30+
"@utils/*": ["src/utils/*"]
31+
}
2232
},
2333
"include": ["src/**/*", "scripts/**/*"],
2434
"exclude": ["node_modules", ".vscode-test", "webview-ui"]

0 commit comments

Comments
 (0)