From d5c91eb2d4c0278ccda67cb680d1e547d32a2907 Mon Sep 17 00:00:00 2001 From: Mike Date: Sat, 30 Nov 2024 19:21:01 +0100 Subject: [PATCH] fix: build issues with tools package used in ESM context (#46) --- packages/mcp-server/package.json | 2 +- packages/tools/package.json | 24 ++----------------- packages/tools/src/android.ts | 4 ++-- packages/tools/src/apple.ts | 4 ++-- packages/tools/src/npm.ts | 2 +- packages/tools/src/react-native.ts | 2 +- .../{ => src}/vendor/react-native-cli.ts | 0 tsconfig.json | 3 +-- 8 files changed, 10 insertions(+), 31 deletions(-) rename packages/tools/{ => src}/vendor/react-native-cli.ts (100%) diff --git a/packages/mcp-server/package.json b/packages/mcp-server/package.json index 45216ec..19d0531 100644 --- a/packages/mcp-server/package.json +++ b/packages/mcp-server/package.json @@ -6,7 +6,7 @@ "cali-mcp-server": "./dist/index.js" }, "scripts": { - "build": "bun build ./src/index.ts --outdir ./dist --target node", + "build": "bun build ./src/index.ts --outdir ./dist --target node --packages external", "inspector": "npx @modelcontextprotocol/inspector bun src/index.ts" }, "dependencies": { diff --git a/packages/tools/package.json b/packages/tools/package.json index 3f78b32..fceb501 100644 --- a/packages/tools/package.json +++ b/packages/tools/package.json @@ -1,23 +1,9 @@ { "name": "cali-tools", "description": "Tools to build your own AI agents for application development.", - "type": "module", - "exports": { - ".": { - "bun": "./src/index.ts", - "import": { - "types": "./dist/typescript/module/src/index.d.ts", - "default": "./dist/module/index.js" - }, - "require": { - "types": "./dist/typescript/commonjs/src/index.d.ts", - "default": "./dist/commonjs/index.js" - } - } - }, + "bun": "./src/index.ts", "main": "./dist/commonjs/index.js", - "types": "./dist/typescript/commonjs/src/index.d.ts", - "module": "./dist/module/index.js", + "types": "./dist/typescript/commonjs/index.d.ts", "scripts": { "build": "bob build" }, @@ -72,12 +58,6 @@ "esm": true } ], - [ - "module", - { - "esm": true - } - ], [ "typescript", { diff --git a/packages/tools/src/android.ts b/packages/tools/src/android.ts index f2054c6..8ec4727 100644 --- a/packages/tools/src/android.ts +++ b/packages/tools/src/android.ts @@ -10,8 +10,8 @@ import { getTaskNames, tryLaunchAppOnDevice, tryLaunchEmulator, -} from '../vendor/react-native-cli' -import { adb, getAdbPathString, getEmulatorName } from '../vendor/react-native-cli' +} from './vendor/react-native-cli' +import { adb, getAdbPathString, getEmulatorName } from './vendor/react-native-cli' export const getAdbPath = tool({ description: 'Returns path to ADB executable', diff --git a/packages/tools/src/apple.ts b/packages/tools/src/apple.ts index 53c6465..5a3e306 100644 --- a/packages/tools/src/apple.ts +++ b/packages/tools/src/apple.ts @@ -2,7 +2,7 @@ import { tool } from 'ai' import { execSync } from 'child_process' import { z } from 'zod' -import type { ApplePlatform } from '../vendor/react-native-cli' +import type { ApplePlatform } from './vendor/react-native-cli' import { createAppleBuild, createAppleRun, @@ -10,7 +10,7 @@ import { getPlatformInfo, listAppleDevices, loadReactNativeConfig, -} from '../vendor/react-native-cli' +} from './vendor/react-native-cli' const platforms = ['ios', 'tvos', 'visionos'] as const diff --git a/packages/tools/src/npm.ts b/packages/tools/src/npm.ts index ad19cad..62b10ad 100644 --- a/packages/tools/src/npm.ts +++ b/packages/tools/src/npm.ts @@ -1,7 +1,7 @@ import { tool } from 'ai' import { z } from 'zod' -import { install, installDev, uninstall } from '../vendor/react-native-cli' +import { install, installDev, uninstall } from './vendor/react-native-cli' export const installNpmPackage = tool({ description: 'Install a package from npm by name', diff --git a/packages/tools/src/react-native.ts b/packages/tools/src/react-native.ts index 4e256be..bac05de 100644 --- a/packages/tools/src/react-native.ts +++ b/packages/tools/src/react-native.ts @@ -7,7 +7,7 @@ import { tool } from 'ai' import dedent from 'dedent' import { z } from 'zod' -import { loadReactNativeConfig } from '../vendor/react-native-cli' +import { loadReactNativeConfig } from './vendor/react-native-cli' export const startMetroDevServer = tool({ description: dedent` diff --git a/packages/tools/vendor/react-native-cli.ts b/packages/tools/src/vendor/react-native-cli.ts similarity index 100% rename from packages/tools/vendor/react-native-cli.ts rename to packages/tools/src/vendor/react-native-cli.ts diff --git a/tsconfig.json b/tsconfig.json index 4c8e509..2652517 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -13,6 +13,5 @@ "paths": { "cali-tools": ["./packages/tools/src"] } - }, - "include": ["src/**/*.ts"] + } }