Cloudflare has rebuilt the module registry in workerd, the core Workers runtime component, to improve Node.js compatibility and runtime efficiency. This redesign shifts from filesystem-style path resolution to URL-based specifiers, enabling features like import.meta and consistent module loading. The new registry also introduces lazy compilation and shared module caching across V8 isolates, optimizing resource utilization and allowing bundlers to offload more responsibilities to the runtime.
Read original on Cloudflare BlogThe Cloudflare Workers runtime, powered by workerd, has undergone a significant architectural change with the introduction of a new module registry. This rewrite aims to align more closely with Node.js's module resolution semantics, providing greater compatibility for Node.js applications and enhancing the overall efficiency of the serverless platform. Historically, Workers relied heavily on client-side bundling to resolve module graphs, but the new registry enables the runtime to handle more of this complexity directly.
The original module registry treated module specifiers as filesystem-style paths, leading to inconsistencies and limitations when implementing web-standard features like `import.meta.url` or `node:` protocols. The new registry fundamentally shifts to treating specifiers as URLs, which has several key architectural implications:
Beyond compatibility, the new registry introduces crucial performance and resource optimization features: