express-tsx
TypeScript icon, indicating that this package has built-in type declarations

5.0.12 • Public • Published

文档

当前版本不适合用于生产环境,因为测试不完善

使用

/**@type {Express}*/
var app = expressTsx(viewsDir="/views",app=Express())
 

核心

  • 编译器
  • tsx文件
  • html载体 充当编译后的文件入口, 模板数据 就是用在这里的, 结构顺序如下(可配置选项用标注了):
    • head
    • lang='en' html语言配置
    • title='express-tsx' html标题
    • keywords='' html关键词
    • description='' html描述
    • heads:string[]=[] 用以配置头部信息
    • <script src=${requirejs.toUrl("requirejs")}></script> 引用requirejs
    • body
    • loading='loading html...'requirejs 引用前写入
    • div#app' app挂载点
    • <script src=${browserRenderJs}> imports_files:[${renderfile},...string[]]=[] </script> 使用浏览器配置脚本进行渲染
    • foots:string[]=[] 用以放置统计脚本之类的
  • 编译好的静态文件服务

扩展

  • 缓存 通过 { cache:boolean } 来开关, 开启后将生成一个名为 ${id}.${renderfile}.${hash} 的html载体
    • id是内置编译器编号
    • renderfile 是被渲染的文件
    • hashJSON.stringify(data)hash
  • 热更新 通过 event-source 发送更新事件, 实现如下:
    • 浏览器配置脚本发起热更新请求, 带上 idrenderfile 参数
    • (req,res)=>void 收到请求后, 找对应编译器的更新事件监听器, 监听事件, 就绪时时发送 { event:ping } 收到更新事件时发送 { event:update, data:changefile }
  • 浏览器模块配置 使用 requirejs 做的模块加载器, 所以配置都继承 requirejs, 下面是需要额外说明的配置
    • transform=false 开启后, 在生产环境下 paths 配置中的 /node_modules/module/path 会被转换为 https://unpkg.com/module@version/path
    • callback 之类的不可序列化的配置是无效的 (比如不能被 JSON.stringify 转成字符串的属性)

Versions

Current Tags

VersionDownloads (Last 7 Days)Tag
5.0.124latest
5.0.80beta

Version History

VersionDownloads (Last 7 Days)Published
5.0.124
5.0.110
5.0.102
5.0.90
5.0.80
5.0.70
5.0.60
5.0.50
5.0.40
5.0.10
4.2.110
4.2.90
4.2.81
4.2.70
4.2.60
4.2.50
4.2.40
4.2.30
4.2.20
4.2.10
4.1.90
4.1.80
4.1.70
4.1.50
4.1.40
4.1.30
4.1.21
4.1.10
4.1.02
4.0.140
4.0.130
4.0.120
4.0.110
4.0.100
4.0.90
4.0.80
4.0.70
4.0.60
4.0.50
4.0.40
4.0.30
4.0.20
4.0.10
3.1.232
3.1.220
3.1.210
3.1.200
3.1.190
3.1.180
3.1.170
3.1.160
3.1.150
3.1.140
3.1.130
3.1.120
3.1.112
3.1.10
3.1.00
3.0.360
3.0.350
3.0.341
3.0.331
3.0.321
3.0.310
3.0.300
3.0.290
3.0.280
3.0.270
3.0.260
3.0.250
3.0.240
3.0.230
3.0.220
3.0.210
3.0.20
3.0.10
3.0.00
2.2.940
2.2.932
2.2.920
2.2.911
2.2.90
2.2.80
2.2.70
2.2.60
2.2.50
2.2.40
2.2.30
2.2.20
2.2.10
2.2.00
2.1.40
2.1.30
2.1.20
2.1.11
2.1.00
2.0.30
2.0.20
2.0.10
2.0.00
1.0.10
1.0.00
0.0.10

Package Sidebar

Install

npm i express-tsx

Weekly Downloads

21

Version

5.0.12

License

MIT

Last publish

Collaborators

  • shynome