Cloudflare Workers: Module Specifiers Are URLs Now

On September 9, 2026 Cloudflare published the details of a rewrite most teams will never see directly: the module registry inside workerd, the runtime behind Workers, no longer resolves import specifiers as filesystem paths. It resolves them as URLs. That single distinction is what finally makes import.meta.url, import.meta.resolve() and Node.js-accurate require(esm) possible on the platform.

The problem: a path is not a URL

The original registry treated specifiers as filesystem-style paths. It sounds like a semantic quibble, but the consequences compounded. There was no clean way to implement import.meta.url. Relative imports did not follow the same resolution rules as new URL(). Protocols like node: and cloudflare: were handled as special-cased string prefixes rather than actual protocols. And the runtime compiled entire bundles upfront, keeping a separate copy of the compiled code per isolate.

What changed

Specifiers now parse as real URLs, query strings and fragments included. The practical consequence: ./counter.js?a and ./counter.js?b are two distinct module instances, each with its own state. Familiar to anyone who has written for the browser, new to Workers.

A cluster of details rides along with it:

  • import.meta.main returns true only for the entry point module.
  • import.meta.resolve() is a pure string transform with no import: it normalizes percent-encoding the way new URL() does — collapsing ./a/../b.js — while leaving already-encoded characters alone.
  • require(esm) follows the Node.js rule: if the module exports module.exports, that value is returned; otherwise you get the namespace object.
  • Import attributes are actually validated. { type: 'json' } is accepted; text and bytes are rejected with a specific error instead of being silently ignored.
  • Errors use consistent classes and messages whether a module arrived via static import, dynamic import or require().
  • Compilation is lazy: a module compiles on first import, and the compiled code is cached and shared across isolate replicas rather than duplicated.

A practical example

js
// wrangler.jsonc → { "compatibility_flags": ["new_module_registry"] }

import counterA from './counter.js?a';
import counterB from './counter.js?b'; // separate instance, separate state

export default {
  async fetch() {
    const fsSpecifier = import.meta.resolve('fs'); // 'node:fs'
    const { createHash } = await import('node:crypto');

    return Response.json({
      here: import.meta.url,
      isEntry: import.meta.main,
      fsSpecifier,
      a: counterA.next(),
      b: counterB.next(),
      digest: createHash('sha256').update('bahashwan').digest('hex'),
    });
  },
};

Real-world caveats

None of this is on by default. It requires the new_module_registry compatibility flag, and that restraint is correct: changing module resolution semantics under a Worker already serving production traffic is not a decision to make silently.

Three things deserve attention before flipping it on. First, require() throws if the module being required — or anything in its module graph — contains a top-level await, matching Node.js' ERR_REQUIRE_ASYNC_MODULE. That is compatibility, not a defect. Second, source phase imports (import source) currently work only for WebAssembly; anything else throws a SyntaxError. Third, this change sits on top of a larger one: since the 2026-08-04 compatibility date, Node.js compatibility is enabled by default in Workers, and turning it off now requires both no_nodejs_compat and no_nodejs_compat_v2. Worker size, meanwhile, is capped at 64 MiB uncompressed on every plan, with no limit on the compressed bundle.

Takeaway

The direction is unmistakable: edge runtimes are done being a simplified JavaScript environment. They are converging on Node.js and browser semantics rather than approximating them with polyfills. The same current showed up when Bun 1.4 absorbed the dependency layer into the runtime. The payoff is that code written for one environment increasingly runs in another without a translation layer. The cost is that the sharp edges move from "this feature is missing" to "this feature exists and behaves precisely — read its terms."

Primary source: How we rebuilt Cloudflare Workers' module registry for Node.js compatibility, plus the Cloudflare changelog on Node.js compatibility by default.