V2EX POST
648 subscribers
138 photos
31 videos
99 files
104K links
v2ex新贴定时推送,可按需置顶本频道然后关闭通知
Download Telegram
Turbopack 发布,比 Vite 快 10 倍

Introducing Turbopack, the successor to Webpack.

◆ ~700x faster than Webpack

◆ 10x faster than Vite

◆ Native incremental architecture built with Rust

◆ Support for React Server Components

◆ Support for TS, JSX, CSS & more


Now open-source in Alpha.

![Screen Shot 2022-10-26 at 10.57.20.png]( https://s2.loli.net/2022/10/26/VIQe5XpqgG8DTZz.png)


![Turbopack vs Vite]( https://pbs.twimg.com/media/Ff8VL2EacAAdIj0?format=jpg&name=medium)


![Screen Shot 2022-10-26 at 11.09.57.png]( https://s2.loli.net/2022/10/26/gKSRqavWmD2ywsi.png)

#2022 #10 #26 #png #https #Turbopack #Webpack #faster #than #Vite
我们将有 60k 行代码 TypeScript (Node.js) 的仓库迁移至 ESM,结果单元测试快了 4 倍

经过三次尝试,我们终于成功地将所有的 Node.js 代码从 CJS 迁移到原生 ESM ,并且单元测试的 CI 大幅减少。

![Comparison]( https://i.v2ex.co/AMInh1Eg.png)

简单介绍一下之前的状况(你可能在 repo 设置或工具链上有不同的选择,但核心步骤和概念应该是一样的):

- 包含前端和后端项目的 TypeScript monorepo
- TypeScript 代码 ~60k 行(包括前端)
- 在 TypeScript 中使用 `import`
- 使用 PNPM 进行 workspace (monorepo) 管理
- 使用 tsc 编译 Node.js ,使用 Parcel 打包前端项目
- 使用 Jest + `ts-jest` 进行单元测试。
- 使用 `module-alias` 处理内部 path alias

顺带一提,我们的项目 [Logto]( https://github.com/logto-io/logto) 是一个开源的身份 (auth) 解决方案。

由于文章篇幅过长,我们分成了上下两篇。感兴趣的朋友可以移步 dev.to 查看:

- [Migrate a 60k LOC TypeScript (NodeJS) repo to ESM and testing become 4x faster (1/2)]( https://dev.to/gaosun/migrate-a-60k-loc-typescript-nodejs-repo-to-esm-and-testing-become-4x-faster-12-5f82)
- [Migrate a 60k LOC TypeScript (NodeJS) repo to ESM and testing become 4x faster (2/2)]( https://dev.to/gaosun/migrate-a-60k-loc-typescript-nodejs-repo-to-esm-and-testing-become-4x-faster-22-4a4k)

#repo #TypeScript #60k #https #testing #become #4x #faster #ESM #dev