@cloudflare/worker-bundler 0.0.3 → 0.1.0

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.d.ts CHANGED
@@ -1,3 +1,11 @@
1
+ import {
2
+ a as createFileSystemSnapshot,
3
+ i as InMemoryFileSystem,
4
+ n as DurableObjectRawFileSystem,
5
+ r as FileSystem,
6
+ t as DurableObjectKVFileSystem
7
+ } from "./file-system-BQyEt1bf.js";
8
+
1
9
  //#region src/types.d.ts
2
10
  /**
3
11
  * Input files for the bundler
@@ -25,7 +33,7 @@ interface CreateWorkerOptions {
25
33
  /**
26
34
  * Input files - keys are paths relative to project root, values are file contents
27
35
  */
28
- files: Files;
36
+ files: Files | FileSystem;
29
37
  /**
30
38
  * Entry point file path (relative to project root)
31
39
  * If not specified, will try to determine from wrangler.toml main field,
@@ -223,9 +231,10 @@ declare function handleAssetRequest(
223
231
  interface CreateAppOptions {
224
232
  /**
225
233
  * Input files — keys are paths relative to project root, values are file contents.
226
- * Should include both server and client source files.
234
+ * Accepts a plain object (which is wrapped in an InMemoryFileSystem automatically)
235
+ * or any FileSystem implementation for custom storage backends.
227
236
  */
228
- files: Files;
237
+ files: Files | FileSystem;
229
238
  /**
230
239
  * Server entry point (the Worker fetch handler).
231
240
  * If not specified, detected from wrangler config / package.json / defaults.
@@ -274,26 +283,17 @@ interface CreateAppOptions {
274
283
  * npm registry URL for fetching packages.
275
284
  */
276
285
  registry?: string;
277
- /**
278
- * Generate a Durable Object class wrapper instead of a module worker.
279
- * When set, the output exports a named class that can be used with
280
- * ctx.facets.get() / getDurableObjectClass() for persistent storage.
281
- *
282
- * If the user's server exports a DurableObject subclass (default export),
283
- * the wrapper extends it. Otherwise, it wraps the fetch handler in a DO.
284
- *
285
- * Pass `true` for className "App", or an object with a custom className.
286
- */
287
- durableObject?:
288
- | {
289
- className?: string;
290
- }
291
- | boolean;
292
286
  }
293
287
  /**
294
288
  * Result from createApp
295
289
  */
296
290
  interface CreateAppResult extends CreateWorkerResult {
291
+ /**
292
+ * Combined assets (user-provided + client bundles) for host-side serving.
293
+ * The host should use createMemoryStorage(assets) and handleAssetRequest()
294
+ * to serve these before forwarding requests to the isolate.
295
+ */
296
+ assets: Record<string, string | ArrayBuffer>;
297
297
  /**
298
298
  * The asset manifest for runtime request handling.
299
299
  * Contains metadata (content types, ETags) for each asset.
@@ -307,22 +307,17 @@ interface CreateAppResult extends CreateWorkerResult {
307
307
  * Client bundle output paths (relative to asset root).
308
308
  */
309
309
  clientBundles?: string[];
310
- /**
311
- * The Durable Object class name exported by the wrapper.
312
- * Only set when `durableObject` option was used.
313
- * Use with `worker.getDurableObjectClass(className)` and `ctx.facets.get()`.
314
- */
315
- durableObjectClassName?: string;
316
310
  }
317
311
  /**
318
312
  * Creates a full-stack app bundle from source files.
319
313
  *
320
314
  * This function:
321
315
  * 1. Bundles client entry point(s) for the browser (if provided)
322
- * 2. Collects static assets
316
+ * 2. Collects static assets and builds the asset manifest
323
317
  * 3. Bundles the server Worker
324
- * 4. Generates a server wrapper that serves assets and falls through to user code
325
- * 5. Returns everything ready for the Worker Loader
318
+ * 4. Returns server modules (for the isolate) and assets (for host-side serving) separately
319
+ *
320
+ * How the output is mounted (module worker, DO class, facet) is the caller's concern.
326
321
  */
327
322
  declare function createApp(options: CreateAppOptions): Promise<CreateAppResult>;
328
323
  //#endregion
@@ -341,6 +336,47 @@ declare function inferContentType(path: string): string | undefined;
341
336
  */
342
337
  declare function isTextContentType(contentType: string): boolean;
343
338
  //#endregion
339
+ //#region src/installer.d.ts
340
+ interface InstallOptions {
341
+ /**
342
+ * Include devDependencies (default: false)
343
+ */
344
+ dev?: boolean;
345
+ /**
346
+ * Registry URL (default: https://registry.npmjs.org)
347
+ */
348
+ registry?: string;
349
+ }
350
+ interface InstallResult {
351
+ /**
352
+ * Packages that were freshly installed in this call.
353
+ * Packages already present in the filesystem are skipped and not listed here.
354
+ */
355
+ installed: string[];
356
+ /**
357
+ * Warnings encountered during installation
358
+ */
359
+ warnings: string[];
360
+ }
361
+ /**
362
+ * Install npm dependencies into a virtual file system.
363
+ *
364
+ * Reads the package.json from the files, resolves all dependencies,
365
+ * and populates node_modules with the package contents.
366
+ *
367
+ * @param fileSystem - Virtual file system containing package.json
368
+ * @param options - Installation options
369
+ * @returns Metadata about the installation
370
+ */
371
+ declare function installDependencies(
372
+ fileSystem: FileSystem,
373
+ options?: InstallOptions
374
+ ): Promise<InstallResult>;
375
+ /**
376
+ * Check if files contain a package.json with dependencies that need installing.
377
+ */
378
+ declare function hasDependencies(files: FileSystem): boolean;
379
+ //#endregion
344
380
  //#region src/index.d.ts
345
381
  /**
346
382
  * Creates a worker bundle from source files.
@@ -368,16 +404,24 @@ export {
368
404
  type CreateAppResult,
369
405
  type CreateWorkerOptions,
370
406
  type CreateWorkerResult,
407
+ DurableObjectKVFileSystem,
408
+ DurableObjectRawFileSystem,
409
+ type FileSystem,
371
410
  type Files,
411
+ InMemoryFileSystem,
412
+ type InstallResult,
372
413
  type Modules,
373
414
  type WranglerConfig,
374
415
  buildAssetManifest,
375
416
  buildAssets,
376
417
  createApp,
418
+ createFileSystemSnapshot,
377
419
  createMemoryStorage,
378
420
  createWorker,
379
421
  handleAssetRequest,
422
+ hasDependencies,
380
423
  inferContentType,
424
+ installDependencies,
381
425
  isTextContentType
382
426
  };
383
427
  //# sourceMappingURL=index.d.ts.map