npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

express-tsx

v5.0.12

Published

express view engine to render tsx file

Downloads

33

Readme

文档

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

使用

/**@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 转成字符串的属性)