<!-- mobian-agent-page publisher="dailydev" canonical="https://daily.dev/posts/how-we-rebuilt-cloudflare-workers-module-registry-for-node-js-compatibility-jqnzndbcb" -->

---
title: How we rebuilt Cloudflare Workers’ module registry for...
description: Cloudflare rewrote the module registry in workerd, the open-source core of the Workers runtime, to align module resolution with Node.js and web standards. The...
canonical: https://daily.dev/posts/how-we-rebuilt-cloudflare-workers-module-registry-for-node-js-compatibility-jqnzndbcb
twitter:card: summary_large_image
twitter:site: @dailydotdev
og:type: website
og:site_name: daily.dev
og:title: How we rebuilt Cloudflare Workers’ module registry for Node.js compatibility | daily.dev
og:description: Cloudflare rewrote the module registry in workerd, the open-source core of the Workers runtime, to align module resolution with Node.js and web standards. The...
og:url: https://daily.dev/posts/how-we-rebuilt-cloudflare-workers-module-registry-for-node-js-compatibility-jqnzndbcb
og:image: https://api.daily.dev/og/posts/jQnZnDbCb.png
og:image:alt: How we rebuilt Cloudflare Workers’ module registry for Node.js compatibility
og:image:width: 1200
og:image:height: 630
og:locale: en
---

> ## Documentation Index
> Fetch the complete documentation index at: https://daily.dev/llms.txt
> Use this file to discover all available pages before exploring further.

# How we rebuilt Cloudflare Workers’ module registry for Node.js compatibility

**[Cloudflare](https://daily.dev/sources/cloudflare)** · 12 min read · 25 upvotes · 1 comments

## Summary

Cloudflare rewrote the module registry in workerd, the open-source core of the Workers runtime, to align module resolution with Node.js and web standards. The new implementation, enabled via the new_module_registry compatibility flag, resolves specifiers as real URLs, supports import.meta.url/main/resolve(), validates import attributes like with { type: 'json' }, implements Node.js' require(esm) rules, unifies error classes across import/require paths, compiles modules lazily, and adds WebAssembly source phase imports. This pairs with Node.js compatibility now being enabled by default and a worker size limit increase to 64 MiB on all plans. The flag is opt-in with no default-on date yet, and the existing registry keeps working for currently deployed Workers.

## Full article

daily.dev links to this article rather than hosting it. Read it at the original source: <https://blog.cloudflare.com/workers-module-registry-nodejs>

## Questions this post answers

### How do I enable the new module registry in Cloudflare Workers?

Add the new_module_registry compatibility flag to your Worker's wrangler configuration, for example setting compatibility_flags to include new_module_registry in wrangler.json. This enables URL-based specifier resolution, import.meta.url/main/resolve(), validated import attributes, Node.js-compliant require(esm), consistent error classes, lazy compilation, and WebAssembly source phase imports. It has no default-on date yet, so existing Workers keep using the old registry unless you opt in explicitly.

_daily.dev surfaces runtime changes like this for developers rolling out Cloudflare Workers upgrades._

### Why didn't import.meta.resolve() work in Cloudflare Workers before?

The original Workers module registry resolved specifiers as filesystem-style paths rather than URLs, which made import.meta.resolve() impossible to implement cleanly, broke relative import resolution compared to new URL(), and treated protocols like node: and cloudflare: as special-cased string prefixes instead of real URL protocols. The rewritten registry, enabled via the new_module_registry compatibility flag, treats specifiers as URLs from the start, fixing this.

_developers debugging module resolution quirks in Workers can track these runtime fixes on daily.dev._

### How does require() behave when requiring an ES module in the new Cloudflare Workers module registry?

It follows Node.js' require(esm) rules: if the ES module exports a string-named export called 'module.exports', that value is returned; otherwise require() returns the module's namespace object, except for workerd's built-in node: modules which return their default export directly. If the module or its graph has a top-level await, require() throws an ERR_REQUIRE_ASYNC_MODULE-style error instead of blocking.

_teams mixing CommonJS and ESM in Workers can follow module-loading behavior changes like this on daily.dev._

## Community discussion

Top comments from developers on daily.dev.

**@agustinbarrientos** · 0 upvotes

> I'd throw CommonJS, ESM, JSON attributes, and dynamic imports into one package test. Then I'd run the same mess once bundled and once through runtime resolution.

## Similar posts on daily.dev

- [Migrating Express and Koa Apps to Cloudflare Workers: Node.js Compatibility Production Guide](https://daily.dev/posts/migrating-express-and-koa-apps-to-cloudflare-workers-node-js-compatibility-production-guide-wiuwlhzj1) · SitePoint · 1 upvotes · 0 comments
- [Node.js 20 — Here’s What’s Actually Worth Caring About](https://daily.dev/posts/node-js-20-here-s-what-s-actually-worth-caring-about-6lpzz9vwc) · Medium · 0 upvotes · 0 comments
- [Native JSON modules are finally real](https://daily.dev/posts/native-json-modules-are-finally-real-zkdi3tmao) · Matt Smith · 23 upvotes · 2 comments
- [How workerd, the Cloudflare Workers runtime, is built](https://daily.dev/posts/how-workerd-the-cloudflare-workers-runtime-is-built-jripr3oyh) · Flavio Copes · 0 upvotes · 0 comments
- [Dogfooding at scale: migrating cdnjs to Cloudflare’s Developer Platform](https://daily.dev/posts/dogfooding-at-scale-migrating-cdnjs-to-cloudflare-s-developer-platform-rysprc2qr) · Cloudflare · 8 upvotes · 0 comments

---

Tags: [#javascript](https://daily.dev/tags/javascript), [#nodejs](https://daily.dev/tags/nodejs), [#webassembly](https://daily.dev/tags/webassembly), [#cloudflare](https://daily.dev/tags/cloudflare)

[View this post on daily.dev](https://daily.dev/posts/how-we-rebuilt-cloudflare-workers-module-registry-for-node-js-compatibility-jqnzndbcb)

```json
{"@context":"https://schema.org","@graph":[{"@type":"Organization","@id":"https://daily.dev/#organization","name":"daily.dev","url":"https://daily.dev","logo":{"@type":"ImageObject","url":"https://daily.dev/apple-touch-icon.png","width":180,"height":180},"sameAs":["https://twitter.com/dailydotdev","https://github.com/dailydotdev","https://www.linkedin.com/company/daily-dev-ltd"]},{"@type":"WebSite","@id":"https://daily.dev/#website","url":"https://daily.dev","name":"daily.dev","publisher":{"@id":"https://daily.dev/#organization"},"potentialAction":{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https://daily.dev/search?q={search_term_string}"},"query-input":"required name=search_term_string"}}]}
{"@context":"https://schema.org","@type":"TechArticle","headline":"How we rebuilt Cloudflare Workers’ module registry for Node.js compatibility","url":"https://daily.dev/posts/how-we-rebuilt-cloudflare-workers-module-registry-for-node-js-compatibility-jqnzndbcb","mainEntityOfPage":{"@type":"WebPage","@id":"https://daily.dev/posts/how-we-rebuilt-cloudflare-workers-module-registry-for-node-js-compatibility-jqnzndbcb"},"datePublished":"2026-09-09T13:13:51.215Z","dateModified":"2026-09-14T06:46:59.532Z","description":"Cloudflare rewrote the module registry in workerd, the open-source core of the Workers runtime, to align module resolution with Node.js and web standards. The...","image":"https://media.daily.dev/image/upload/f_auto,q_auto/v1/posts/152d16f5fa6c4e6119b78234ce2e9d55?_a=AQAEuop","thumbnailUrl":"https://media.daily.dev/image/upload/f_auto,q_auto/v1/posts/152d16f5fa6c4e6119b78234ce2e9d55?_a=AQAEuop","isAccessibleForFree":true,"articleSection":"Cloudflare","inLanguage":"en","publisher":{"@type":"Organization","name":"daily.dev","url":"https://daily.dev","logo":{"@type":"ImageObject","url":"https://daily.dev/apple-touch-icon.png","width":180,"height":180}},"author":{"@type":"Organization","name":"Cloudflare","logo":"https://media.daily.dev/image/upload/t_logo,f_auto/v1/logos/38522e1d11354cd6b7af66f9d4316735","url":"https://daily.dev/sources/cloudflare"},"commentCount":1,"discussionUrl":"https://daily.dev/posts/how-we-rebuilt-cloudflare-workers-module-registry-for-node-js-compatibility-jqnzndbcb","interactionStatistic":[{"@type":"InteractionCounter","interactionType":{"@type":"LikeAction"},"userInteractionCount":25},{"@type":"InteractionCounter","interactionType":{"@type":"CommentAction"},"userInteractionCount":1}],"keywords":"javascript,nodejs,webassembly,cloudflare","timeRequired":"PT12M"}
{"@context":"https://schema.org","@type":"BreadcrumbList","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https://daily.dev"},{"@type":"ListItem","position":2,"name":"Cloudflare","item":"https://daily.dev/sources/cloudflare"},{"@type":"ListItem","position":3,"name":"How we rebuilt Cloudflare Workers’ module registry for Node.js compatibility"}]}
{"@context":"https://schema.org","@type":"WebPage","@id":"https://daily.dev/posts/how-we-rebuilt-cloudflare-workers-module-registry-for-node-js-compatibility-jqnzndbcb","comment":[{"@type":"Comment","text":"I’d throw CommonJS, ESM, JSON attributes, and dynamic imports into one package test. Then I’d run the same mess once bundled and once through runtime resolution.","datePublished":"2026-09-13T07:51:01.361Z","url":"https://daily.dev/posts/jQnZnDbCb#c-3b6BXZgAq","author":{"@type":"Person","name":"Agustin Barrientos","url":"https://daily.dev/agustinbarrientos","image":"https://media.daily.dev/image/upload/s--5ayxQnqn--/f_auto/v1788281802/avatars/avatar_wQYYVe5Tbj0NJ7C7qPoa8?_a=BAMAMicg0"}}]}
{"@context":"https://schema.org","@type":"FAQPage","@id":"https://daily.dev/posts/how-we-rebuilt-cloudflare-workers-module-registry-for-node-js-compatibility-jqnzndbcb#faq","mainEntity":[{"@type":"Question","name":"How do I enable the new module registry in Cloudflare Workers?","acceptedAnswer":{"@type":"Answer","text":"Add the new_module_registry compatibility flag to your Worker's wrangler configuration, for example setting compatibility_flags to include new_module_registry in wrangler.json. This enables URL-based specifier resolution, import.meta.url/main/resolve(), validated import attributes, Node.js-compliant require(esm), consistent error classes, lazy compilation, and WebAssembly source phase imports. It has no default-on date yet, so existing Workers keep using the old registry unless you opt in explicitly. daily.dev surfaces runtime changes like this for developers rolling out Cloudflare Workers upgrades."}},{"@type":"Question","name":"Why didn't import.meta.resolve() work in Cloudflare Workers before?","acceptedAnswer":{"@type":"Answer","text":"The original Workers module registry resolved specifiers as filesystem-style paths rather than URLs, which made import.meta.resolve() impossible to implement cleanly, broke relative import resolution compared to new URL(), and treated protocols like node: and cloudflare: as special-cased string prefixes instead of real URL protocols. The rewritten registry, enabled via the new_module_registry compatibility flag, treats specifiers as URLs from the start, fixing this. developers debugging module resolution quirks in Workers can track these runtime fixes on daily.dev."}},{"@type":"Question","name":"How does require() behave when requiring an ES module in the new Cloudflare Workers module registry?","acceptedAnswer":{"@type":"Answer","text":"It follows Node.js' require(esm) rules: if the ES module exports a string-named export called 'module.exports', that value is returned; otherwise require() returns the module's namespace object, except for workerd's built-in node: modules which return their default export directly. If the module or its graph has a top-level await, require() throws an ERR_REQUIRE_ASYNC_MODULE-style error instead of blocking. teams mixing CommonJS and ESM in Workers can follow module-loading behavior changes like this on daily.dev."}}]}
```

