# sm-tool

> sm-tool工具包

Latest version **1.0.77** (published 2025-11-21) · MIT license · 0 weekly downloads

## Install

```sh
npm install sm-tool
pnpm add sm-tool
yarn add sm-tool
bun add sm-tool
```

## Health

**Score 50/100 (C)** — status: stable.

Positive: esm support; no vulnerabilities.

Warnings: low downloads; no types.

## Facts

| | |
|---|---|
| Version | 1.0.77 |
| Published | 2025-11-21 |
| First published | 2023-07-17 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | ESM + CommonJS |
| Dependencies | 0 |
| Unpacked size | 169.1 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | shimin Zhang |
| Maintainers | zsm_123 |
| Keywords | 前端开发, 工具包, sm-tool |

## Links

- npm: https://www.npmjs.com/package/sm-tool
- npm.io page: https://npm.io/package/sm-tool

## Recent versions

- 1.0.77 (latest) — 2025-11-21
- 1.0.76 — 2025-09-05
- 1.0.75 — 2025-09-05
- 1.0.73 — 2025-09-01
- 1.0.72 — 2025-09-01
- 1.0.71 — 2025-07-02
- 1.0.70 — 2025-06-24
- 1.0.69 — 2025-06-24
- 1.0.68 — 2025-06-17
- 1.0.67 — 2025-06-04
- 1.0.66 — 2025-06-04
- 1.0.65 — 2025-06-04
- 1.0.63 — 2025-05-28
- 1.0.62 — 2025-05-14
- 1.0.61 — 2025-04-29
- … 39 more at https://npm.io/package/sm-tool/versions

## README

### rollup打包npm资源并发布到官方npm源步骤：
1. 创建目录结构如：
```.txt
sm-tool/src
sm-tool/src/core
sm-tool/src/types # 所有导出的类型声明放在该目录下的文件中
sm-tool/src/util
```

2. 初始化npm目录，生成packages.json文件
npm init -y

3. 初始化typescript配置，生成tsconfig.json文件
tsc --init

4. 创建rollup.config.js文件

5. 安装依赖包
```sh
npm i rollup -D
npm i rollup-plugin-dts -D
npm i rollup-plugin-typescript2 -D
npm i typescript -D
npm i rollup-plugin-uglify -D
```

6. 编写rollup打包配置文件rollup.config.js

7. 配置package.json中的打包命令build
```.sh
# 默认采用当前目录下的rollup.config.js配置文件
"build": "rollup -c"
```

8. 先随便写几行代码测试打包是否正常，如果打包出错，就按照提示信息修改，主要是tsconfig.json文件；
如果按照提示修改还是报错，多半是依赖包的版本问题，可以尝试先去掉支持cjs方式的导入。
以下配套的依赖版本暂时是ok的。
```.json
{
    "rollup": "~2.77.0",
    "rollup-plugin-dts": "~4.2.2",
    "rollup-plugin-typescript2": "~0.32.1",
    "typescript": "~4.7.4"
}
```

9. 修改package.json文件中的main、module、browser

10. 其它注意事项
（1）发布到npm官网之前，要确保使用的registry为npm官方源https://registry.npmjs.org
（2）查看当前登录的npm账号信息：npm profile get
```.sh
nrm ls
nrm use npm
# 默认公开发布
npm publish
npm publish --access public
npm publish --access restricted # 仅限域级npm包才能使用私有发布，但是官网的私有包收费
# 卸载发布的包
npm unpublish sm-tool -f
```

---
_Source: https://npm.io/package/sm-tool · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
