zitejs 0.9.112 → 0.9.114

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.
@@ -1 +1,25 @@
1
+ /**
2
+ * `npx zitejs bundle` — Bundle endpoint files for cloudflare-lambda deployment.
3
+ *
4
+ * Replaces the legacy `scripts/bundle-endpoints.js` from zitejs-starter.
5
+ * Reads endpoints from src/api/*.ts, resolves SDK imports via .zite/backend.ts
6
+ * (monorepo) or src/__zite__/integrations.ts (legacy), and outputs bundled ESM
7
+ * code suitable for the cloudflare-lambda worker runtime.
8
+ *
9
+ * Usage:
10
+ * npx zitejs bundle # bundle all endpoints
11
+ * npx zitejs bundle --app admin-panel # bundle endpoints for a specific app
12
+ * npx zitejs bundle --script <path> # bundle a one-off script
13
+ *
14
+ * Output: JSON to stdout
15
+ * { bundledEndpoints: Record<string, string>, endpointErrors?: Record<string, string> }
16
+ * or for --script: { bundledCode: string } or { error: string }
17
+ *
18
+ * Dependencies (add to zitejs package.json):
19
+ * "esbuild": "^0.25.0"
20
+ * "@babel/parser": "^7.26.0"
21
+ */
22
+ import * as esbuild from 'esbuild';
23
+ export declare const UNSUPPORTED_IN_WORKERD: Set<string>;
24
+ export declare const BASE_BUILD_OPTIONS: esbuild.BuildOptions;
1
25
  export declare function runBundle(): Promise<void>;
@@ -33,6 +33,7 @@ var __importStar = (this && this.__importStar) || (function () {
33
33
  };
34
34
  })();
35
35
  Object.defineProperty(exports, "__esModule", { value: true });
36
+ exports.BASE_BUILD_OPTIONS = exports.UNSUPPORTED_IN_WORKERD = void 0;
36
37
  exports.runBundle = runBundle;
37
38
  /**
38
39
  * `npx zitejs bundle` — Bundle endpoint files for cloudflare-lambda deployment.
@@ -59,14 +60,21 @@ const esbuild = __importStar(require("esbuild"));
59
60
  const path = __importStar(require("path"));
60
61
  const fs = __importStar(require("fs"));
61
62
  const parser_1 = require("@babel/parser");
62
- const _NODE_BUILTIN_NAMES = [
63
- 'http', 'https', 'http2', 'stream', 'buffer', 'util', 'events', 'crypto',
64
- 'path', 'fs', 'url', 'querystring', 'zlib', 'net', 'tls', 'os', 'assert',
65
- 'process', 'child_process', 'cluster', 'dgram', 'dns', 'inspector', 'module',
66
- 'perf_hooks', 'readline', 'repl', 'string_decoder', 'timers', 'tty', 'v8',
67
- 'vm', 'worker_threads', 'async_hooks', 'trace_events', 'punycode',
68
- ];
69
- const NODE_BUILTINS = _NODE_BUILTIN_NAMES.flatMap(m => [m, `node:${m}`]);
63
+ const node_module_1 = require("node:module");
64
+ // workerd's `nodejs_compat` does not provide these. Left external they bundle
65
+ // fine and then kill the worker at load time with `No such module`; excluded,
66
+ // esbuild fails the one endpoint with a resolvable error instead. Pinned by
67
+ // apps/cloudflare-lambda tests/sdk-compat/node-builtin-support.test.ts.
68
+ exports.UNSUPPORTED_IN_WORKERD = new Set([
69
+ 'child_process', 'dgram', 'inspector', 'inspector/promises', 'perf_hooks',
70
+ 'readline', 'readline/promises', 'repl', 'tty', 'v8', 'worker_threads',
71
+ ]);
72
+ // External, not bundled: the worker supplies them. Sourced from Node because
73
+ // the hand-written list covered 36 of 68, so a dependency reaching for a name
74
+ // we forgot (`constants`, `fs/promises`) failed the whole endpoint.
75
+ const NODE_BUILTINS = node_module_1.builtinModules
76
+ .filter(m => !m.startsWith('_') && !exports.UNSUPPORTED_IN_WORKERD.has(m))
77
+ .flatMap(m => [m, `node:${m}`]);
70
78
  const PREBUNDLED_LIBS = {
71
79
  '@zite/endpoints-runtime-sdk': '__zite-runtime__.js',
72
80
  'zod': '__zod__.js',
@@ -85,8 +93,9 @@ const PREBUNDLED_LIBS = {
85
93
  'twilio': '__twilio__.js',
86
94
  'intercom-client': '__intercom__.js',
87
95
  '@google/generative-ai': '__gemini__.js',
96
+ '@elevenlabs/elevenlabs-js': '__elevenlabs__.js',
88
97
  };
89
- const BASE_BUILD_OPTIONS = {
98
+ exports.BASE_BUILD_OPTIONS = {
90
99
  bundle: true,
91
100
  write: false,
92
101
  format: 'esm',
@@ -391,7 +400,7 @@ async function bundleEndpointsImpl(baseDir, endpointNames) {
391
400
  const wrapperCode = generateEndpointWrapper(name, usedImports, sdkExportKinds, sdkSource);
392
401
  try {
393
402
  const result = await esbuild.build({
394
- ...BASE_BUILD_OPTIONS,
403
+ ...exports.BASE_BUILD_OPTIONS,
395
404
  stdin: {
396
405
  contents: wrapperCode,
397
406
  resolveDir: `${baseDir}/src`,
@@ -461,7 +470,7 @@ globalThis.__endpoint = endpoint;
461
470
  `;
462
471
  try {
463
472
  const result = await esbuild.build({
464
- ...BASE_BUILD_OPTIONS,
473
+ ...exports.BASE_BUILD_OPTIONS,
465
474
  stdin: {
466
475
  contents: dispatcherCode,
467
476
  resolveDir: `${baseDir}/src`,
@@ -541,7 +550,7 @@ ${bodySection}
541
550
  }`;
542
551
  try {
543
552
  const result = await esbuild.build({
544
- ...BASE_BUILD_OPTIONS,
553
+ ...exports.BASE_BUILD_OPTIONS,
545
554
  stdin: {
546
555
  contents: wrappedScript,
547
556
  loader: 'ts',
@@ -1 +1,25 @@
1
+ /**
2
+ * `npx zitejs bundle` — Bundle endpoint files for cloudflare-lambda deployment.
3
+ *
4
+ * Replaces the legacy `scripts/bundle-endpoints.js` from zitejs-starter.
5
+ * Reads endpoints from src/api/*.ts, resolves SDK imports via .zite/backend.ts
6
+ * (monorepo) or src/__zite__/integrations.ts (legacy), and outputs bundled ESM
7
+ * code suitable for the cloudflare-lambda worker runtime.
8
+ *
9
+ * Usage:
10
+ * npx zitejs bundle # bundle all endpoints
11
+ * npx zitejs bundle --app admin-panel # bundle endpoints for a specific app
12
+ * npx zitejs bundle --script <path> # bundle a one-off script
13
+ *
14
+ * Output: JSON to stdout
15
+ * { bundledEndpoints: Record<string, string>, endpointErrors?: Record<string, string> }
16
+ * or for --script: { bundledCode: string } or { error: string }
17
+ *
18
+ * Dependencies (add to zitejs package.json):
19
+ * "esbuild": "^0.25.0"
20
+ * "@babel/parser": "^7.26.0"
21
+ */
22
+ import * as esbuild from 'esbuild';
23
+ export declare const UNSUPPORTED_IN_WORKERD: Set<string>;
24
+ export declare const BASE_BUILD_OPTIONS: esbuild.BuildOptions;
1
25
  export declare function runBundle(): Promise<void>;
@@ -23,14 +23,21 @@ import * as esbuild from 'esbuild';
23
23
  import * as path from 'path';
24
24
  import * as fs from 'fs';
25
25
  import { parse } from '@babel/parser';
26
- const _NODE_BUILTIN_NAMES = [
27
- 'http', 'https', 'http2', 'stream', 'buffer', 'util', 'events', 'crypto',
28
- 'path', 'fs', 'url', 'querystring', 'zlib', 'net', 'tls', 'os', 'assert',
29
- 'process', 'child_process', 'cluster', 'dgram', 'dns', 'inspector', 'module',
30
- 'perf_hooks', 'readline', 'repl', 'string_decoder', 'timers', 'tty', 'v8',
31
- 'vm', 'worker_threads', 'async_hooks', 'trace_events', 'punycode',
32
- ];
33
- const NODE_BUILTINS = _NODE_BUILTIN_NAMES.flatMap(m => [m, `node:${m}`]);
26
+ import { builtinModules } from 'node:module';
27
+ // workerd's `nodejs_compat` does not provide these. Left external they bundle
28
+ // fine and then kill the worker at load time with `No such module`; excluded,
29
+ // esbuild fails the one endpoint with a resolvable error instead. Pinned by
30
+ // apps/cloudflare-lambda tests/sdk-compat/node-builtin-support.test.ts.
31
+ export const UNSUPPORTED_IN_WORKERD = new Set([
32
+ 'child_process', 'dgram', 'inspector', 'inspector/promises', 'perf_hooks',
33
+ 'readline', 'readline/promises', 'repl', 'tty', 'v8', 'worker_threads',
34
+ ]);
35
+ // External, not bundled: the worker supplies them. Sourced from Node because
36
+ // the hand-written list covered 36 of 68, so a dependency reaching for a name
37
+ // we forgot (`constants`, `fs/promises`) failed the whole endpoint.
38
+ const NODE_BUILTINS = builtinModules
39
+ .filter(m => !m.startsWith('_') && !UNSUPPORTED_IN_WORKERD.has(m))
40
+ .flatMap(m => [m, `node:${m}`]);
34
41
  const PREBUNDLED_LIBS = {
35
42
  '@zite/endpoints-runtime-sdk': '__zite-runtime__.js',
36
43
  'zod': '__zod__.js',
@@ -49,8 +56,9 @@ const PREBUNDLED_LIBS = {
49
56
  'twilio': '__twilio__.js',
50
57
  'intercom-client': '__intercom__.js',
51
58
  '@google/generative-ai': '__gemini__.js',
59
+ '@elevenlabs/elevenlabs-js': '__elevenlabs__.js',
52
60
  };
53
- const BASE_BUILD_OPTIONS = {
61
+ export const BASE_BUILD_OPTIONS = {
54
62
  bundle: true,
55
63
  write: false,
56
64
  format: 'esm',
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "zitejs",
3
- "version": "0.9.112",
3
+ "version": "0.9.114",
4
4
  "description": "The Zite framework — build apps on Zite Database",
5
5
  "type": "module",
6
6
  "main": "./dist/cjs/index.js",