tsup 包含依赖的处理

tsup 默认打包的bundle 实际上是结合依赖自动处理的,但是默认会排除dependencies以及devDependencies,此模式与我们实际希望的效果可能是不一致的,可选的解决方法是配置noExternal(通过正则匹配处理)

参考使用

  • noExternal 参考配置
import  {defineConfig} from 'tsup';

export default defineConfig({
  dts: true,
  sourcemap: false,
  clean: true,
  minify: true,
  entryPoints: ['src/app.ts'],
  format: ['cjs', 'esm'],
  noExternal: [ /(.*)/ ]
});

说明

当然类似可选的工具还是很多的,ncc 也是一个不错的工具,天然支持typescript

参考资料

https://github.com/egoist/tsup/issues/619

https://esbuild.github.io/

https://github.com/developit/microbundle

https://github.com/vercel/ncc

https://tsup.egoist.dev/#excluding-packages

posted on   荣锋亮  阅读(29)  评论(0编辑  收藏  举报

相关博文:
阅读排行:
· 全程不用写代码,我用AI程序员写了一个飞机大战
· DeepSeek 开源周回顾「GitHub 热点速览」
· 记一次.NET内存居高不下排查解决与启示
· MongoDB 8.0这个新功能碉堡了,比商业数据库还牛
· .NET10 - 预览版1新功能体验(一)
历史上的今天:
2023-12-05 minio 新的minio grid server 通信框架
2023-12-05 cerbos lite webassembly 处理简单说明
2023-12-05 h2o 多http 协议支持的http server
2023-12-05 avvio fastify的异步node 应用启动框架
2023-12-05 cosmo 开源apollo Graphos 工具
2022-12-05 maven-dependency-plugin unpack 使用
2021-12-05 nginx 动态模块问题

导航

< 2025年3月 >
23 24 25 26 27 28 1
2 3 4 5 6 7 8
9 10 11 12 13 14 15
16 17 18 19 20 21 22
23 24 25 26 27 28 29
30 31 1 2 3 4 5
点击右上角即可分享
微信分享提示