用户空间迁移

¥Userland Migrations

Node.js 为 "userland"(你编写的代码与 Node 自身代码)源代码提供了迁移,以便于采用新功能并升级受重大更改影响的源代码。这些迁移是与 codemod 合作完成的,codemod 还与其他主要项目合作,例如 Next.js、React 和 Tailwind。Node.js 的迁移位于 nodejs/userland-migrations 代码库中,并由 @nodejs/userland-migrations 团队监督。

¥Node.js provides migrations for "userland" (what you write vs node's own) source-code to facilitate adoption of new features and upgrading source-code affected by breaking changes. These are done in collaboration with codemod, who also work with other major projects like Next.js, React, and Tailwind. Node.js's migrations live in the nodejs/userland-migrations repository and are overseen by the @nodejs/userland-migrations team.

官方迁移发布在 codemod 注册表 中的 @nodejs 命名空间下。这些内容已由 Node.js 成员审阅和/或撰写。还有一些非官方的迁移可用,这些迁移尚未经过 Node.js 审核。

¥Official migrations are published under the @nodejs namespace within the codemod registry. These have been reviewed and/or authored by Node.js members. There are also unofficial migrations available which have not been reviewed by Node.js.

迁移会修改项目的源代码以应用新的设计模式,例如:

¥A migration alters a project's source-code to apply a new design pattern, like:

cd path/to/your/project
npx codemod@latest @nodejs/correct-ts-specifiers

上述迁移将遗留的 TypeScript 导入转换为符合标准的说明符,例如:

¥The cited migration transforms legacy typescript imports to standards-compliant specifiers like:

import Foo from './foo';
阅读时间
2 min