ENF News Bot
Automated News Bot
- Joined
- Apr 15, 2022
- Messages
- 2,591
Starting November 17, 2026, JavaScript Workers with a compatibility date of
The module registry finds and loads JavaScript modules in your Worker. We announced the new registry in September 2026 ↗︎. It improves compatibility with JavaScript standards and Node.js. In Workers using Node.js compatibility, you can use
You can also use
src/index.jsjs
src/index.tsts
When deployed with
Existing Workers keep their current behavior until you change their compatibility date or flags. To try the new registry before November 17, keep your current date and add
Before updating, check your dependencies for invalid import attributes and changes to
For migration details, refer to the new module registry compatibility flag, bundling documentation, and Node.js compatibility documentation.
Continue reading...
2026-11-17 or later will use the new module registry by default. You will no longer need the new_module_registry flag for these dates. Python Workers keep using the legacy registry.The module registry finds and loads JavaScript modules in your Worker. We announced the new registry in September 2026 ↗︎. It improves compatibility with JavaScript standards and Node.js. In Workers using Node.js compatibility, you can use
require() to load ES modules. The module and its dependencies must not use top-level await.You can also use
import.meta to get information about the current module and find the URL of another module without loading it:src/index.jsjs
Code:
export default {
fetch() {
return Response.json({
moduleUrl: import.meta.url,
isEntrypoint: import.meta.main,
helperUrl: import.meta.resolve("./helper.js"),
});
},
};
Code:
export default {
fetch(): Response {
return Response.json({
moduleUrl: import.meta.url,
isEntrypoint: import.meta.main,
helperUrl: import.meta.resolve("./helper.js"),
});
},
} satisfies ExportedHandler;
When deployed with
src/index.ts as the unbundled entrypoint, isEntrypoint is true. helperUrl is a URL within your Worker bundle. Resolving the URL does not check whether the module exists or load it over the network. Build tools may transform import.meta. To try this example directly, refer to unbundled deployments.Existing Workers keep their current behavior until you change their compatibility date or flags. To try the new registry before November 17, keep your current date and add
new_module_registry to your compatibility flags.Before updating, check your dependencies for invalid import attributes and changes to
require() behavior. The new registry rejects invalid import attributes. Calls to require() also fail if the module or any of its dependencies use top-level await. To keep the legacy registry with a compatibility date of 2026-11-17 or later, add legacy_module_registry.For migration details, refer to the new module registry compatibility flag, bundling documentation, and Node.js compatibility documentation.
Continue reading...