Compare commits

...

2 Commits

Author SHA1 Message Date
celestial-vault 02d0d40af4 changeset 2025-04-18 18:55:06 -07:00
celestial-vault 915f3da2b5 add path aliases to the extension side 2025-04-18 18:53:20 -07:00
4 changed files with 41 additions and 2 deletions
+5
View File
@@ -0,0 +1,5 @@
---
"claude-dev": minor
---
Add aliasing to imports in the extension
+24
View File
@@ -9,6 +9,29 @@ const test = process.env.IS_TEST === "true"
/**
* @type {import('esbuild').Plugin}
*/
const aliasResolverPlugin = {
name: "alias-resolver",
setup(build) {
const aliases = {
"@": path.resolve(__dirname, "src"),
"@api": path.resolve(__dirname, "src/api"),
"@core": path.resolve(__dirname, "src/core"),
"@integrations": path.resolve(__dirname, "src/integrations"),
"@services": path.resolve(__dirname, "src/services"),
"@shared": path.resolve(__dirname, "src/shared"),
"@utils": path.resolve(__dirname, "src/utils"),
}
// For each alias entry, create a resolver
Object.entries(aliases).forEach(([alias, aliasPath]) => {
const aliasRegex = new RegExp(`^${alias}($|/.*)`)
build.onResolve({ filter: aliasRegex }, (args) => {
const importPath = args.path.replace(alias, aliasPath)
return { path: importPath }
})
})
},
}
const esbuildProblemMatcherPlugin = {
name: "esbuild-problem-matcher",
@@ -75,6 +98,7 @@ const extensionConfig = {
},
plugins: [
copyWasmFiles,
aliasResolverPlugin,
/* add to the end of plugins array */
esbuildProblemMatcherPlugin,
{
+1 -1
View File
@@ -88,7 +88,7 @@ import {
import { getGlobalState } from "../storage/state"
import { parseSlashCommands } from ".././slash-commands"
import WorkspaceTracker from "../../integrations/workspace/WorkspaceTracker"
import { McpHub } from "../../services/mcp/McpHub"
import { McpHub } from "@services/mcp/McpHub"
export const cwd =
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
+11 -1
View File
@@ -18,7 +18,17 @@
"strict": true,
"target": "es2022",
"useDefineForClassFields": true,
"useUnknownInCatchVariables": false
"useUnknownInCatchVariables": false,
"baseUrl": ".",
"paths": {
"@/*": ["src/*"],
"@api/*": ["src/api/*"],
"@core/*": ["src/core/*"],
"@integrations/*": ["src/integrations/*"],
"@services/*": ["src/services/*"],
"@shared/*": ["src/shared/*"],
"@utils/*": ["src/utils/*"]
}
},
"include": ["src/**/*", "scripts/**/*"],
"exclude": ["node_modules", ".vscode-test", "webview-ui"]