Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

esbuild 和 rollup 都是 vite 的基础依赖, 那么他们有啥不同? #1115

Open
hankliu62 opened this issue Jun 29, 2024 · 0 comments
Assignees
Labels
engine 工程化相关 top100互联网 互联网Top100相关
Milestone

Comments

@hankliu62
Copy link
Owner

esbuild 和 Rollup 都是 Vite 的基础依赖,但它们在 Vite 中担负着不同的角色和任务。

  1. esbuild:esbuild 是一个快速、可扩展的 JavaScript 打包器,它被用作 Vite 的默认构建工具。esbuild 的主要任务是将源代码转换为浏览器可以理解的代码,同时还支持压缩、代码分割、按需加载等功能。esbuild 利用其高性能的构建能力,实现了快速的开发服务器和热模块替换。

  2. Rollup:Rollup 是一个 JavaScript 模块打包工具,也是 Vite 的另一个基础依赖。在 Vite 中,Rollup 主要用于生产构建阶段。它通过静态分析模块依赖关系,将多个模块打包为一个或多个最终的输出文件。Rollup 支持多种输出格式,如 ES 模块、CommonJS、UMD 等,可以根据项目的需要进行配置。

尽管 esbuild 和 Rollup 都是 Vite 的基础依赖,但它们的分工是不同的。esbuild 用于开发服务器阶段,通过实时编译和提供模块来实现快速的冷启动和热模块替换。而 Rollup 用于生产构建阶段,将源代码打包为最终可发布的文件,以用于部署到生产环境。这样的分工使得 Vite 在开发过程中能够快速响应变化,并在构建过程中生成高效的最终输出文件。

@hankliu62 hankliu62 added engine 工程化相关 top100互联网 互联网Top100相关 labels Jun 29, 2024
@hankliu62 hankliu62 added this to the 4 milestone Jun 29, 2024
@hankliu62 hankliu62 self-assigned this Jun 29, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
engine 工程化相关 top100互联网 互联网Top100相关
Projects
None yet
Development

No branches or pull requests

1 participant