@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/index.js CHANGED
@@ -5848,44 +5848,76 @@ function agentbuilder(options = {}) {
5848
5848
  }
5849
5849
  return {
5850
5850
  name: "vite-plugin-agent",
5851
- config() {
5851
+ config(config) {
5852
+ const depsToInclude = [
5853
+ "openai",
5854
+ "zod",
5855
+ "@standardagents/builder/runtime",
5856
+ "@standardagents/builder/built-in-routes"
5857
+ ];
5858
+ const depsToExclude = [
5859
+ "@standardagents/builder/mcp"
5860
+ ];
5861
+ const environments = {};
5862
+ if (config.environments) {
5863
+ for (const envName of Object.keys(config.environments)) {
5864
+ environments[envName] = {
5865
+ optimizeDeps: {
5866
+ include: depsToInclude,
5867
+ exclude: depsToExclude
5868
+ }
5869
+ };
5870
+ }
5871
+ }
5852
5872
  return {
5873
+ // Root optimizeDeps for client environment
5853
5874
  optimizeDeps: {
5854
5875
  // Pre-bundle these deps upfront to prevent "new version of pre-bundle" errors
5855
5876
  // during first startup when node_modules/.vite cache is empty.
5856
5877
  // These are discovered dynamically by the virtual modules, so we need to
5857
5878
  // tell Vite about them ahead of time.
5858
- include: [
5859
- "openai",
5860
- "zod",
5861
- "@standardagents/builder/runtime",
5862
- "@standardagents/builder/built-in-routes"
5863
- ],
5864
- // Exclude MCP as it's not used in the main app
5865
- exclude: [
5866
- "@standardagents/builder/mcp"
5867
- ]
5879
+ include: depsToInclude,
5880
+ exclude: depsToExclude
5868
5881
  },
5882
+ // Also configure for environments (Cloudflare worker uses a custom environment)
5883
+ environments,
5869
5884
  ssr: {
5870
5885
  // Mark as external for SSR/worker builds to prevent bundling
5871
5886
  // Note: @standardagents/builder, @standardagents/builder/runtime, built-in-routes, and rou3
5872
5887
  // are NOT external - they must be bundled into the worker for Cloudflare Workers runtime
5873
- external: [
5874
- "@standardagents/builder/mcp"
5875
- ]
5888
+ external: depsToExclude
5876
5889
  },
5877
5890
  build: {
5878
5891
  rollupOptions: {
5879
5892
  // Also mark as external for Rollup/build (used by Cloudflare Workers plugin)
5880
5893
  // Note: @standardagents/builder, @standardagents/builder/runtime, built-in-routes, and rou3
5881
5894
  // are NOT external - they must be bundled into the worker for Cloudflare Workers runtime
5882
- external: [
5883
- "@standardagents/builder/mcp"
5884
- ]
5895
+ external: depsToExclude
5885
5896
  }
5886
5897
  }
5887
5898
  };
5888
5899
  },
5900
+ // Use configEnvironment hook to set optimizeDeps for each environment including worker
5901
+ configEnvironment(name, config) {
5902
+ const depsToInclude = [
5903
+ "openai",
5904
+ "zod",
5905
+ "@standardagents/builder/runtime",
5906
+ "@standardagents/builder/built-in-routes"
5907
+ ];
5908
+ const depsToExclude = [
5909
+ "@standardagents/builder/mcp"
5910
+ ];
5911
+ config.optimizeDeps = config.optimizeDeps || {};
5912
+ config.optimizeDeps.include = [
5913
+ ...config.optimizeDeps.include || [],
5914
+ ...depsToInclude.filter((dep) => !config.optimizeDeps?.include?.includes(dep))
5915
+ ];
5916
+ config.optimizeDeps.exclude = [
5917
+ ...config.optimizeDeps.exclude || [],
5918
+ ...depsToExclude.filter((dep) => !config.optimizeDeps?.exclude?.includes(dep))
5919
+ ];
5920
+ },
5889
5921
  resolveId(id) {
5890
5922
  if (id === VIRTUAL_TOOLS_ID) {
5891
5923
  return RESOLVED_VIRTUAL_TOOLS_ID;