2025-12-17 11:35:06 +01:00
|
|
|
import path from "node:path";
|
2026-02-21 02:05:41 -05:00
|
|
|
import { existsSync } from "node:fs";
|
2025-12-18 11:38:32 +01:00
|
|
|
import { fileURLToPath } from "node:url";
|
2025-12-17 11:35:06 +01:00
|
|
|
|
2025-12-18 11:38:32 +01:00
|
|
|
const here = path.dirname(fileURLToPath(import.meta.url));
|
|
|
|
|
const repoRoot = path.resolve(here, "../../../../..");
|
2026-02-21 02:46:31 -05:00
|
|
|
const uiRoot = path.resolve(repoRoot, "ui");
|
2025-12-17 11:35:06 +01:00
|
|
|
const fromHere = (p) => path.resolve(here, p);
|
2025-12-20 12:17:27 +00:00
|
|
|
const outputFile = path.resolve(
|
|
|
|
|
here,
|
|
|
|
|
"../../../../..",
|
|
|
|
|
"src",
|
|
|
|
|
"canvas-host",
|
|
|
|
|
"a2ui",
|
|
|
|
|
"a2ui.bundle.js",
|
|
|
|
|
);
|
2025-12-17 11:35:06 +01:00
|
|
|
|
|
|
|
|
const a2uiLitDist = path.resolve(repoRoot, "vendor/a2ui/renderers/lit/dist/src");
|
|
|
|
|
const a2uiThemeContext = path.resolve(a2uiLitDist, "0.8/ui/context/theme.js");
|
2026-02-21 02:46:31 -05:00
|
|
|
const uiNodeModules = path.resolve(uiRoot, "node_modules");
|
|
|
|
|
const repoNodeModules = path.resolve(repoRoot, "node_modules");
|
2026-02-21 02:05:41 -05:00
|
|
|
|
2026-02-21 02:46:31 -05:00
|
|
|
function resolveUiDependency(moduleId) {
|
|
|
|
|
const candidates = [
|
|
|
|
|
path.resolve(uiNodeModules, moduleId),
|
|
|
|
|
path.resolve(repoNodeModules, moduleId),
|
|
|
|
|
];
|
|
|
|
|
for (const candidate of candidates) {
|
|
|
|
|
if (existsSync(candidate)) {
|
|
|
|
|
return candidate;
|
|
|
|
|
}
|
2026-02-21 02:05:41 -05:00
|
|
|
}
|
|
|
|
|
|
2026-02-21 02:46:31 -05:00
|
|
|
const fallbackCandidates = candidates.join(", ");
|
|
|
|
|
throw new Error(
|
|
|
|
|
`A2UI bundle config cannot resolve ${moduleId}. Checked: ${fallbackCandidates}. ` +
|
|
|
|
|
"Keep dependency installed in ui workspace or repo root before bundling.",
|
|
|
|
|
);
|
|
|
|
|
}
|
2025-12-17 11:35:06 +01:00
|
|
|
|
2026-02-21 02:46:31 -05:00
|
|
|
export default {
|
2025-12-17 11:35:06 +01:00
|
|
|
input: fromHere("bootstrap.js"),
|
2025-12-20 14:50:10 +01:00
|
|
|
experimental: {
|
|
|
|
|
attachDebugInfo: "none",
|
|
|
|
|
},
|
2025-12-17 11:35:06 +01:00
|
|
|
treeshake: false,
|
|
|
|
|
resolve: {
|
|
|
|
|
alias: {
|
|
|
|
|
"@a2ui/lit": path.resolve(a2uiLitDist, "index.js"),
|
|
|
|
|
"@a2ui/lit/ui": path.resolve(a2uiLitDist, "0.8/ui/ui.js"),
|
2026-01-30 03:15:10 +01:00
|
|
|
"@openclaw/a2ui-theme-context": a2uiThemeContext,
|
2026-02-21 02:46:31 -05:00
|
|
|
"@lit/context": resolveUiDependency("@lit/context"),
|
|
|
|
|
"@lit/context/": resolveUiDependency("@lit/context/"),
|
|
|
|
|
"@lit-labs/signals": resolveUiDependency("@lit-labs/signals"),
|
|
|
|
|
"@lit-labs/signals/": resolveUiDependency("@lit-labs/signals/"),
|
|
|
|
|
lit: resolveUiDependency("lit"),
|
|
|
|
|
"lit/": resolveUiDependency("lit/"),
|
|
|
|
|
"signal-utils/": resolveUiDependency("signal-utils/"),
|
2025-12-17 11:35:06 +01:00
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
output: {
|
2025-12-18 10:44:06 +01:00
|
|
|
file: outputFile,
|
2025-12-17 11:35:06 +01:00
|
|
|
format: "esm",
|
2026-01-26 22:59:02 -05:00
|
|
|
codeSplitting: false,
|
2025-12-17 11:35:06 +01:00
|
|
|
sourcemap: false,
|
|
|
|
|
},
|
2026-02-21 02:46:31 -05:00
|
|
|
};
|