Minor Changes
-
#1277
0cd0487Thanks @zebp! - IntroduceFileSystemabstraction for all bundler APIs.The
filesoption oncreateWorkerandcreateAppnow accepts anyFileSystem
implementation in addition to a plainRecord<string, string>. This lets callers
back the virtual filesystem with persistent or custom storage — for example, a
DurableObjectKVFileSystemthat buffers writes in memory and flushes to Durable
Object KV on demand, avoiding a KV write for every individual file operation.Three concrete implementations are exported from the package:
InMemoryFileSystem— aMap-backed filesystem suitable for tests and
in-process pipelines. Accepts an optional seed object orMapof initial
files.DurableObjectKVFileSystem— a Durable Object KV-backed filesystem with a
write-overlay. Writes accumulate in memory and are flushed to KV in one batch
whenflush()is called. Reads are served from the overlay first, so callers
always observe their own writes immediately.DurableObjectRawFileSystem— a thin Durable Object KV-backed filesystem
with no buffering. Every write is committed to KV synchronously. Use when
per-write durability is preferred over batching.
createFileSystemSnapshotcreates anInMemoryFileSystemfrom any sync or
async iterable of[path, content]pairs, bridging async storage backends
(e.g.Workspacefrom@cloudflare/shell) to the synchronousFileSystem
interface.The
FileSystem.read()method returnsstring | null(null = file does not
exist) rather than an empty string, eliminating the need for a separate
exists()check.Plain
Record<string, string>objects continue to work unchanged — they are
wrapped in anInMemoryFileSystemautomatically. -
#1277
0cd0487Thanks @zebp! - ExportinstallDependencies,hasDependencies, andInstallResultso callers
can pre-warm aFileSystemwith npm packages independently ofcreateWorkeror
createApp.When
createWorkerorcreateAppencounter aFileSystemthat already contains
a package undernode_modules/, that package is skipped during installation,
avoiding redundant network fetches. This makes a second call to
installDependencies(or the internal call insidecreateWorker) a no-op for
packages that were pre-installed into the sameFileSystem. -
#1277
0cd0487Thanks @zebp! - Add in-process TypeScript language service viacreateTypescriptLanguageService.createTypescriptLanguageServicewraps anyFileSystemin a
TypescriptFileSystemthat mirrors every write and delete into an underlying
virtual TypeScript environment. Diagnostics returned by the language service
always reflect the current state of the filesystem — an edit that fixes a type
error immediately clearsgetSemanticDiagnostics.TypeScript is pre-bundled as a browser-safe artifact so it runs inside the
Workers runtime without Node.js APIs. Lib declarations are fetched from the
TypeScript npm tarball at runtime.Exposed under a separate
./typescriptsubpath export to keep the TypeScript
bundle out of the main import path.