@sidecar-ai/cli 0.1.0-alpha.8 → 0.1.0-alpha.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.js +26 -1
- package/dist/index.js.map +1 -1
- package/package.json +5 -5
package/dist/index.js
CHANGED
|
@@ -897,6 +897,7 @@ function warnRuntimeSchemaFallback(sourcePath, error) {
|
|
|
897
897
|
import { createHash } from "crypto";
|
|
898
898
|
import { existsSync as existsSync3 } from "fs";
|
|
899
899
|
import { mkdir, readFile, writeFile } from "fs/promises";
|
|
900
|
+
import { createRequire } from "module";
|
|
900
901
|
import path4 from "path";
|
|
901
902
|
import { pathToFileURL as pathToFileURL2 } from "url";
|
|
902
903
|
import { build as esbuild } from "esbuild";
|
|
@@ -906,6 +907,7 @@ import {
|
|
|
906
907
|
SyntaxKind
|
|
907
908
|
} from "ts-morph";
|
|
908
909
|
var CLAUDE_FONT_RESOURCE_DOMAIN = "https://assets.claude.ai";
|
|
910
|
+
var requireFromCompiler = createRequire(import.meta.url);
|
|
909
911
|
async function buildWidgets(rootDir, outDir, tools, config = void 0) {
|
|
910
912
|
const widgets = tools.filter(
|
|
911
913
|
(entry) => Boolean(entry.widget)
|
|
@@ -938,7 +940,7 @@ createRoot(document.getElementById("root")!).render(
|
|
|
938
940
|
);
|
|
939
941
|
const baseOptions = enforceWidgetBuildInvariants({
|
|
940
942
|
absWorkingDir: rootDir,
|
|
941
|
-
alias:
|
|
943
|
+
alias: sidecarWidgetAliases(rootDir),
|
|
942
944
|
bundle: true,
|
|
943
945
|
entryPoints: [entryFile],
|
|
944
946
|
format: "iife",
|
|
@@ -1069,9 +1071,11 @@ function mergeWidgetBuildOptions(...options) {
|
|
|
1069
1071
|
return merged;
|
|
1070
1072
|
}
|
|
1071
1073
|
function enforceWidgetBuildInvariants(options, required) {
|
|
1074
|
+
const aliases = required ? { ...options.alias ?? {}, ...reactSingletonAliases(required.rootDir) } : options.alias;
|
|
1072
1075
|
return {
|
|
1073
1076
|
...options,
|
|
1074
1077
|
absWorkingDir: required?.rootDir ?? options.absWorkingDir,
|
|
1078
|
+
alias: aliases,
|
|
1075
1079
|
bundle: true,
|
|
1076
1080
|
entryPoints: required ? [required.entryFile] : options.entryPoints,
|
|
1077
1081
|
format: "iife",
|
|
@@ -1080,6 +1084,27 @@ function enforceWidgetBuildInvariants(options, required) {
|
|
|
1080
1084
|
write: false
|
|
1081
1085
|
};
|
|
1082
1086
|
}
|
|
1087
|
+
function sidecarWidgetAliases(rootDir) {
|
|
1088
|
+
return {
|
|
1089
|
+
...devSidecarBundleAliases(rootDir) ?? {},
|
|
1090
|
+
...reactSingletonAliases(rootDir)
|
|
1091
|
+
};
|
|
1092
|
+
}
|
|
1093
|
+
function reactSingletonAliases(rootDir) {
|
|
1094
|
+
return {
|
|
1095
|
+
react: resolveProjectModule(rootDir, "react"),
|
|
1096
|
+
"react/jsx-runtime": resolveProjectModule(rootDir, "react/jsx-runtime"),
|
|
1097
|
+
"react/jsx-dev-runtime": resolveProjectModule(rootDir, "react/jsx-dev-runtime"),
|
|
1098
|
+
"react-dom": resolveProjectModule(rootDir, "react-dom"),
|
|
1099
|
+
"react-dom/client": resolveProjectModule(rootDir, "react-dom/client"),
|
|
1100
|
+
"react-dom/server": resolveProjectModule(rootDir, "react-dom/server")
|
|
1101
|
+
};
|
|
1102
|
+
}
|
|
1103
|
+
function resolveProjectModule(rootDir, specifier) {
|
|
1104
|
+
return requireFromCompiler.resolve(specifier, {
|
|
1105
|
+
paths: [rootDir, process.cwd()]
|
|
1106
|
+
});
|
|
1107
|
+
}
|
|
1083
1108
|
function normalizeAliases(rootDir, aliases) {
|
|
1084
1109
|
if (!aliases) {
|
|
1085
1110
|
return void 0;
|