tsn 0.1.0

TypeScript to native executable compiler
tsn-0.1.0 is not a library.

tsn

是什么

TypeScript 编译器,编译 TS 为原生可执行文件(10-14KB),无需 Node.js。

能做什么

  • 编译 TypeScript 为原生 exe
  • 生成无依赖的可执行文件
  • 调用 Rust FFI 函数

怎么做

tsn main.ts
./a.exe

有什么缺陷

tsn自带函数非常少

怎么弥补

可以集成rust现有包来扩展能力,暂时不支持c/c++的扩展。

用什么工具

tsn plugin(tsnp)

这个工具怎么用

通过tsnp 告诉 tsn:

  • Rust 有哪些函数
  • 函数参数和返回值类型
  • 函数在哪个库

tsnp快速开始:

# 1. 用 tsnp 把现有crate包xxx装成tsn的插件
tsnp gen xxx

# 得到插件目录
# tsnp/xxx/ts-native.toml

# 2. tsn main.ts 编译时自动加载tsnp下的插件

详见 tsnp 文档:https://github.com/itszzl-sudo/tsnp

许可证

MIT