mirror of
https://github.com/getcompanion-ai/co-mono.git
synced 2026-04-16 20:01:24 +00:00
Fix jiti alias for typebox subpath imports in custom tools/hooks
fixes #311
This commit is contained in:
parent
c53b22db43
commit
66d19ac9c8
3 changed files with 83 additions and 4 deletions
|
|
@ -23,12 +23,20 @@ function getAliases(): Record<string, string> {
|
|||
const __dirname = path.dirname(fileURLToPath(import.meta.url));
|
||||
const packageIndex = path.resolve(__dirname, "../..", "index.js");
|
||||
|
||||
// For typebox, we need the package root directory (not the entry file)
|
||||
// because jiti's alias is prefix-based: imports like "@sinclair/typebox/compiler"
|
||||
// get the alias prepended. If we alias to the entry file (.../build/cjs/index.js),
|
||||
// then "@sinclair/typebox/compiler" becomes ".../build/cjs/index.js/compiler" (invalid).
|
||||
// By aliasing to the package root, it becomes ".../typebox/compiler" which resolves correctly.
|
||||
const typeboxEntry = require.resolve("@sinclair/typebox");
|
||||
const typeboxRoot = typeboxEntry.replace(/\/build\/cjs\/index\.js$/, "");
|
||||
|
||||
_aliases = {
|
||||
"@mariozechner/pi-coding-agent": packageIndex,
|
||||
"@mariozechner/pi-coding-agent/hooks": path.resolve(__dirname, "index.js"),
|
||||
"@mariozechner/pi-tui": require.resolve("@mariozechner/pi-tui"),
|
||||
"@mariozechner/pi-ai": require.resolve("@mariozechner/pi-ai"),
|
||||
"@sinclair/typebox": require.resolve("@sinclair/typebox"),
|
||||
"@sinclair/typebox": typeboxRoot,
|
||||
};
|
||||
return _aliases;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue