跳到主内容
@wquguru
精选88Cloudflare Workers(Changelog)云与平台

Cloudflare Workers v2026-11-17 起默认启用新模块注册表

Workers - Workers will use the new module registry by default on November 17

原文
发到 X
推荐理由

面向所有 Cloudflare Workers 开发者:11 月 17 日后 JS Worker 默认切换新模块注册表,可能因 require() 顶层 await 限制或 import attributes 校验导致构建失败,请提前检查依赖并调整配置。

Starting November 17, 2026, JavaScript Workers with a compatibility date of 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.

自 2026 年 11 月 17 日起,兼容性日期为 2026-11-17 或更晚的 JavaScript Workers 将默认使用新的模块注册表。对于这些日期,您将不再需要 new_module_registry 标志。Python Workers 继续使用旧版注册表。

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.

模块注册表用于查找并加载 Worker 中的 JavaScript 模块。我们于 2026 年 9 月宣布了新的注册表 ↗︎。它提高了与 JavaScript 标准及 Node.js 的兼容性。在使用 Node.js 兼容性的 Workers 中,您可以使用 require() 来加载 ES 模块。模块及其依赖项不得使用顶层 await。

You can also use import.meta to get information about the current module and find the URL of another module without loading it:

您还可以使用 import.meta 获取当前模块的信息,并找到另一个模块的 URL 而无需加载它:

src/index.jsjs

代码 · 9 行
export default {
	fetch() {
		return Response.json({
			moduleUrl: import.meta.url,
			isEntrypoint: import.meta.main,
			helperUrl: import.meta.resolve("./helper.js"),
		});
	},
};

src/index.tsts

代码 · 9 行
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.

当以 src/index.ts 作为未打包入口点部署时,isEntrypoint 为 true。helperUrl 是位于您的 Worker 包内的一个 URL。解析该 URL 不会检查模块是否存在或通过网络加载它。构建工具可能会转换 import.meta。要直接尝试此示例,请参阅未打包部署。

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.

现有 Workers 在更改其兼容性日期或标志之前,将保持当前行为。若要在 11 月 17 日之前试用新注册表,请保留当前日期并在兼容性标志中添加 new_module_registry。

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.

在更新之前,请检查您的依赖项是否存在无效的导入属性以及 require() 行为的变化。新注册表会拒绝无效的导入属性。如果模块或其任何依赖项使用顶层 await,对 require() 的调用也会失败。若要在 2026-11-17 或更晚的兼容性日期下继续使用旧版注册表,请添加 legacy_module_registry。

For migration details, refer to the new module registry compatibility flag, bundling documentation, and Node.js compatibility documentation.

有关迁移详情,请参阅新的模块注册表兼容性标志、打包文档以及 Node.js 兼容性文档。

更进一步:量化金融体系

看懂新闻只是起点——沿量化金融路径,把它变成能交付的工程能力

进入量化体系 →

相似阅读

关联信息,但可能不是同一事件