@standardagents/builder 0.9.7 → 0.9.8

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/plugin.js CHANGED
@@ -2051,44 +2051,76 @@ function agentbuilder(options = {}) {
2051
2051
  }
2052
2052
  return {
2053
2053
  name: "vite-plugin-agent",
2054
- config() {
2054
+ config(config) {
2055
+ const depsToInclude = [
2056
+ "openai",
2057
+ "zod",
2058
+ "@standardagents/builder/runtime",
2059
+ "@standardagents/builder/built-in-routes"
2060
+ ];
2061
+ const depsToExclude = [
2062
+ "@standardagents/builder/mcp"
2063
+ ];
2064
+ const environments = {};
2065
+ if (config.environments) {
2066
+ for (const envName of Object.keys(config.environments)) {
2067
+ environments[envName] = {
2068
+ optimizeDeps: {
2069
+ include: depsToInclude,
2070
+ exclude: depsToExclude
2071
+ }
2072
+ };
2073
+ }
2074
+ }
2055
2075
  return {
2076
+ // Root optimizeDeps for client environment
2056
2077
  optimizeDeps: {
2057
2078
  // Pre-bundle these deps upfront to prevent "new version of pre-bundle" errors
2058
2079
  // during first startup when node_modules/.vite cache is empty.
2059
2080
  // These are discovered dynamically by the virtual modules, so we need to
2060
2081
  // tell Vite about them ahead of time.
2061
- include: [
2062
- "openai",
2063
- "zod",
2064
- "@standardagents/builder/runtime",
2065
- "@standardagents/builder/built-in-routes"
2066
- ],
2067
- // Exclude MCP as it's not used in the main app
2068
- exclude: [
2069
- "@standardagents/builder/mcp"
2070
- ]
2082
+ include: depsToInclude,
2083
+ exclude: depsToExclude
2071
2084
  },
2085
+ // Also configure for environments (Cloudflare worker uses a custom environment)
2086
+ environments,
2072
2087
  ssr: {
2073
2088
  // Mark as external for SSR/worker builds to prevent bundling
2074
2089
  // Note: @standardagents/builder, @standardagents/builder/runtime, built-in-routes, and rou3
2075
2090
  // are NOT external - they must be bundled into the worker for Cloudflare Workers runtime
2076
- external: [
2077
- "@standardagents/builder/mcp"
2078
- ]
2091
+ external: depsToExclude
2079
2092
  },
2080
2093
  build: {
2081
2094
  rollupOptions: {
2082
2095
  // Also mark as external for Rollup/build (used by Cloudflare Workers plugin)
2083
2096
  // Note: @standardagents/builder, @standardagents/builder/runtime, built-in-routes, and rou3
2084
2097
  // are NOT external - they must be bundled into the worker for Cloudflare Workers runtime
2085
- external: [
2086
- "@standardagents/builder/mcp"
2087
- ]
2098
+ external: depsToExclude
2088
2099
  }
2089
2100
  }
2090
2101
  };
2091
2102
  },
2103
+ // Use configEnvironment hook to set optimizeDeps for each environment including worker
2104
+ configEnvironment(name, config) {
2105
+ const depsToInclude = [
2106
+ "openai",
2107
+ "zod",
2108
+ "@standardagents/builder/runtime",
2109
+ "@standardagents/builder/built-in-routes"
2110
+ ];
2111
+ const depsToExclude = [
2112
+ "@standardagents/builder/mcp"
2113
+ ];
2114
+ config.optimizeDeps = config.optimizeDeps || {};
2115
+ config.optimizeDeps.include = [
2116
+ ...config.optimizeDeps.include || [],
2117
+ ...depsToInclude.filter((dep) => !config.optimizeDeps?.include?.includes(dep))
2118
+ ];
2119
+ config.optimizeDeps.exclude = [
2120
+ ...config.optimizeDeps.exclude || [],
2121
+ ...depsToExclude.filter((dep) => !config.optimizeDeps?.exclude?.includes(dep))
2122
+ ];
2123
+ },
2092
2124
  resolveId(id) {
2093
2125
  if (id === VIRTUAL_TOOLS_ID) {
2094
2126
  return RESOLVED_VIRTUAL_TOOLS_ID;