-
-
Notifications
You must be signed in to change notification settings - Fork 53
The configuration of rslib should be as simple as possible #468
-
我开源了有1x个开源项目,构建工作用过很多,包括你们团队的rspack、rsbuild、还有之前的Modernjs ,但最终稳定在tsup,吸引我的一点就是tsup的配置方式比较人性化简单。
举个例子,我最新开源AutoStore的tsup构建配置如下:
export default defineConfig(
{
entry: [
'src/index.ts'
],
format: ['esm','cjs'],
dts: true,
splitting: true,
sourcemap: true,
clean: true,
treeshake:true,
minify: true,
noExternal:['flex-tools']
}
)
- 一些主要的功能基本上就只要指定
<feature>=true就可以生效,<feature>=true代表了一个最佳实践,很省心。然后,如果你不满足再使用<feature>={....}进行自定义即可。
对比一下rslib的sourceMap配置,我刚开始是比较懵逼的。
output:{
sourceMap: {
js: "source-map",
},
},
有此反直觉的感觉,吐槽一下.
-
对我而言,一个entry,指定多个
output format更加简单。 -
rslib的配置竞然是
defineConfig({
lib:{
// ...........
}
})
我本来就是要defaultConfig的,竞然还要告诉defaultConfig说我是要配置lib,这有点反直觉。rslib的defaultConfig不知道我是要配置rslib,汗.
我知道rslib是基于rsbuild->rspack的,但是既然要有一个rslib不就是为了为库开发者提供开箱即用的方案吗,应该站在库开发者的角度来考虑问题。
我认为以下方式更合理
defineConfig({
// rslib 配置...........
rsbuild:{
// 配置
}
})
因为rslib的配置应该是基本封装了rsbuild的大部分功能,对开发者而言,rsbuild的配置相当于是高级配置,这才更合理
再看看tsup,直接就defineConfig({....}),我们知道tsup是基于esbuild的,大部份情况下,使用tsup的配置就可以了,但有时也需要使用esbuildOptions这样的扩展配置。
- 还有我在
rslib的配置中没有发现类似tsup中的entry这样的配置项,是我理解错了吗?
总之,我认为快是rslib、rsbuild是竞争优势,但是配置的简洁,最佳实践的开箱即用等,也是非常重要的。
您可能说Rslib提供比tsup更丰富、更细粒度的选项,我认为这并不是问题。
默认配置应该要蕴含最佳实践,简化学习成本,然后再让人进行一步。
提些建议,希望rslib发展得更好,
Beta Was this translation helpful? Give feedback.
All reactions
-
👍 2
Replies: 1 comment 1 reply
-
Rslib's configuration is designed to be consistent with Rsbuild, making it easy for Rsbuild users to get started with Rslib. This also allows users to reuse common Rsbuild configurations between any Rsbuild-based project, such as Rspress.
You may find that the tsup configuration is "flatter", but in most cases this is a minor difference; what really matters is the completeness of the functionality and how intuitive it is to Rsbuild users.
- See [tsup - Configuration Migration] if you are looking for the
entryoption. - The
sourceMapoption has been simplified, see The configuration of sourceMap is complex and not simple enough #467 .
Beta Was this translation helpful? Give feedback.
All reactions
-
As a user of almost all Rstack products I totally agree! The power of Rslib is the seamless integration into the whole ecosystem. When managing a lot of repositories it is an immense efficiency bonus to have a consistent API across different products. In addition, this makes some config parts reusable which I really love.
Beta Was this translation helpful? Give feedback.
All reactions
-
😄 2