Skip to content

Commit 4cb4b32

Browse files
committed
feat: tsup
1 parent ee8a223 commit 4cb4b32

File tree

7 files changed

+174
-6765
lines changed

7 files changed

+174
-6765
lines changed

.github/workflows/release.yml

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
name: release
2+
on:
3+
push:
4+
# 监听 main 分支的 push 事件
5+
branches:
6+
- main
7+
# 赋予 release-please-action 权限
8+
permissions:
9+
contents: write
10+
pull-requests: write
11+
jobs:
12+
# 设置 release-please 任务
13+
release-please:
14+
# 设置任务运行环境为 ubuntu-latest
15+
runs-on: ubuntu-latest
16+
steps:
17+
# 使用 release-please-action 动作来自动创建发布 PR
18+
- uses: googleapis/release-please-action@v4
19+
id: release
20+
with:
21+
# 设置发布类型为 node
22+
release-type: node
23+
# 检出代码
24+
- uses: actions/checkout@v4
25+
if: ${{ steps.release.outputs.release_created }}
26+
# 设置 Node.js 环境
27+
- uses: actions/setup-node@v4
28+
with:
29+
# 设置 Node.js 版本
30+
node-version: 16
31+
# 设置 npm 源
32+
registry-url: "https://registry.npmjs.org"
33+
# 安装依赖
34+
- run: npm install
35+
env:
36+
NODE_AUTH_TOKEN: ${{ secrets.RELEASE }}
37+
if: ${{ steps.release.outputs.release_created }}
38+
# 构建输出
39+
- run: npm run build
40+
if: ${{ steps.release.outputs.release_created }}
41+
# 删除开发依赖
42+
- run: npm pkg delete devDependencies
43+
if: ${{ steps.release.outputs.release_created }}
44+
# 发布到 npm
45+
- run: npm run pub
46+
env:
47+
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
48+
if: ${{ steps.release.outputs.release_created }}

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,3 +5,5 @@ lib
55
coverage
66
node_modules
77
npm-debug.log
8+
/dist
9+
package-lock.json

README.md

Lines changed: 40 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,49 @@
1-
# art-template
1+
# @karinjs/art-template
22

3-
[![NPM Version](https://img.shields.io/npm/v/art-template.svg)](https://npmjs.org/package/art-template)
4-
[![NPM Downloads](http://img.shields.io/npm/dm/art-template.svg)](https://npmjs.org/package/art-template)
5-
[![Node.js Version](https://img.shields.io/node/v/art-template.svg)](http://nodejs.org/download/)
6-
[![Travis-ci](https://travis-ci.org/aui/art-template.svg?branch=master)](https://travis-ci.org/aui/art-template)
7-
[![Coverage Status](https://coveralls.io/repos/github/aui/art-template/badge.svg?branch=master)](https://coveralls.io/github/aui/art-template?branch=master)
3+
[![NPM Version](https://img.shields.io/npm/v/@karinjs/art-template.svg)](https://npmjs.org/package/@karinjs/art-template)
4+
[![Node.js Version](https://img.shields.io/node/v/@karinjs/art-template.svg)](http://nodejs.org/download/)
85

9-
[English document](https://goofychris.github.io/art-template/) | [中文文档](https://goofychris.github.io/art-template/zh-cn/index.html)
6+
art-template 是一个简约、超快的模板引擎。它采用作用域预声明的技术来优化模板渲染速度,从而获得接近 JavaScript 极限的运行性能,并且同时支持 NodeJS 和浏览器。
107

11-
art-template is a simple and superfast templating engine that optimizes template rendering speed by scope pre-declared technique, hence achieving runtime performance which is close to the limits of JavaScript. At the same time, it supports both NodeJS and browser. [speed test online](https://goofychris.github.io/art-template/rendering-test/).
8+
本项目是对原 art-template 的重新打包优化版本,使用 tsup 进行构建,大幅减小了包体积和依赖数量。
129

13-
art-template 是一个简约、超快的模板引擎。它采用作用域预声明的技术来优化模板渲染速度,从而获得接近 JavaScript 极限的运行性能,并且同时支持 NodeJS 和浏览器。[在线速度测试](https://goofychris.github.io/art-template/rendering-test/)
10+
## 特性
1411

15-
[![chart](https://goofychris.github.io/art-template/images/[email protected])](https://goofychris.github.io/art-template/rendering-test/)
12+
1. 拥有接近 JavaScript 渲染极限的的性能
13+
2. 调试友好:语法、运行时错误日志精确到模板所在行
14+
3. 支持 Express、Koa、Webpack
15+
4. 支持模板继承与子模板
16+
5. 浏览器版本仅 6KB 大小
17+
6. 零依赖,包体积小(从原版的 8.3MB 减小到 327KB)
18+
7. 对源代码无任何修改,发布到`npm`上的所有操作均由`github actions`自动完成
1619

17-
## Feature
20+
## 安装
1821

19-
1. performance is close to the JavaScript rendering limits
20-
2. debugging friendly. Syntax errors or runtime errors will be positioned accurately at which line of template. Support setting breakpoint in templating files (Webpack Loader)
21-
3. support Express, Koa, Webpack
22-
4. support template inheritance and sub template
23-
5. browser version is only 6KB
22+
```bash
23+
# npm
24+
npm install @karinjs/art-template
2425

25-
## 特性
26+
# yarn
27+
yarn add @karinjs/art-template
2628

27-
1. 拥有接近 JavaScript 渲染极限的的性能
28-
2. 调试友好:语法、运行时错误日志精确到模板所在行;支持在模板文件上打断点(Webpack Loader)
29-
5. 支持 Express、Koa、Webpack
30-
6. 支持模板继承与子模板
31-
7. 浏览器版本仅 6KB 大小
29+
# pnpm
30+
pnpm add @karinjs/art-template
31+
```
32+
33+
## 优化对比
34+
35+
| 指标 | 原版 art-template | @karinjs/art-template |
36+
| -------- | ----------------- | --------------------- |
37+
| 包体积 | 8.3MB | 327KB |
38+
| 依赖数量 | 33个 | 0个 |
39+
40+
数据来源:[pkg-size.dev/art-template](https://pkg-size.dev/art-template)
41+
42+
## 版本更新 (2025-03-29)
43+
44+
- 使用 tsup 重新打包
45+
- 移除所有外部依赖
46+
- 减小包体积
47+
- 优化类型定义
48+
- 升级多个依赖包版本
49+
- 将 html-minifier 替换为 html-minifier-terser,解决高危安全警告

0 commit comments

Comments
 (0)