-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathvitest.workspace-aliases.ts
More file actions
49 lines (42 loc) · 1.75 KB
/
Copy pathvitest.workspace-aliases.ts
File metadata and controls
49 lines (42 loc) · 1.75 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
/** @file Workspace source aliases shared by Vitest project configurations. */
import path from "node:path";
import { fileURLToPath } from "node:url";
interface WorkspaceSourceAlias {
readonly find: string | RegExp;
readonly replacement: string;
}
const repoRoot = path.dirname(fileURLToPath(import.meta.url));
function alias(specifier: string, ...segments: string[]): WorkspaceSourceAlias {
return {
find: new RegExp(`^${specifier}$`),
replacement: fromRoot(...segments),
};
}
function fromRoot(...segments: string[]): string {
return path.join(repoRoot, ...segments);
}
/**
* Workspace packages a suite consumes as built output rather than through a
* source alias below.
*
* Vitest inlines a linked workspace package by default and then resolves that
* package's own imports against the importing project, so `dist` reaching for
* `jose` fails wherever the importer does not itself declare it. Keeping these
* external returns them to Node's resolution, which finds `jose` under each
* package's own `node_modules`. Declaring `jose` in the importer instead would
* be a dependency no source file imports, which knip rejects.
*/
export const builtWorkspaceDependencies: RegExp[] = [
/@moltzap\/(?:identity|router)/,
];
/** Source aliases, ordered with specific subpaths before package roots. */
export const workspaceSourceAliases: WorkspaceSourceAlias[] = [
alias("@moltzap/client", "packages/client/src/index.ts"),
alias("@moltzap/simulator/ledger", "packages/simulator/src/ledger/index.ts"),
alias("@moltzap/simulator", "packages/simulator/src/index.ts"),
alias(
"@moltzap/nanoclaw-channel",
"packages/nanoclaw-channel/src/channels/moltzap.ts",
),
alias("@moltzap/openclaw-channel", "packages/openclaw-channel/src/plugin.ts"),
];