Vite library mode vs rollup
Asked Answered
H

1

14

Vite has revolutionised web development for frontend js/ts apps. As it is based on rollup and supports library mode, I wonder if there is still any advantage building js libraries directly with rollup or shall I use vite instead?

Vite hides rollup's config complexity and allows to use many vite plugins, including vitest (for testing).

Hernardo answered 6/9, 2022 at 10:0 Comment(3)
with v 3.2.0 Vite now allows multiple entry points. That provides even better support for building js librariesHernardo
Here is a starter library template for vite. About The starter is built on top of Vite 4.x and prepared for writing libraries in TypeScript. It generates a hybrid package - both support for CommonJS and ESM modules.Hernardo
Here is a nice article on how to build TS library with viteHernardo
G
3

Vite, like any other abstraction, adds another layer on top of other tools like rollup and esbuild.

The advantage of more abstraction is that the tool is more easy to use and you can quickly start without having to make many configuration decisions.

An advantage of using rollup over Vite is that you probably have less complexity and dependencies in your tooling. If you know what you are doing, going with rollup can still be a viable choice. This is especially true if you don't need the dev server and your build process is simple.

Ginkgo answered 30/8, 2023 at 8:17 Comment(0)

© 2022 - 2025 — McMap. All rights reserved.