You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

91 lines
1.8 KiB
Plaintext

4 months ago
# @haina/npm
可复用的 npm 模块
支持 `ESM`(import) 和 `CommonJS`(require)
4 months ago
## Dev
4 months ago
### Package Structure
4 months ago
```
4 months ago
├─dist
│ ├── haina-npm-0.1.0.tgz
│ ├── hooks-0.1.0.tgz
│ ├── utils-0.1.0.tgz
│ ├── utils-commons-0.1.0.tgz
│ └── utils-request-0.1.0.tgz
└─src
├─ index.js
├─ hooks/
└─ utils/
4 months ago
```
### Build & Pack
```sh
# 打包各模块
npm run pack
4 months ago
# 打包整个项目(各模块和root)
4 months ago
npm run pack:all
```
4 months ago
1. 生成导出文件 `index.js`
2. 创建`ESM`和`CommonJS` 版本
3. 打包
1. 打包`src`下的子文件夹 --> `hooks-0.1.10.tgz` `utils-0.1.10.tgz` …
2. `src/utils`下的模块, 分别单独打包 --> `utils-request-0.1.10.tgz` `utils-commons-0.1.10.tgz` …
3. 打包整个项目(root) --> `haina-npm-0.1.10.tgz`
### Serve
#### FTP
#### Github Action
4 months ago
```
https://github.com/hainatravel-it/hai-npm/releases/download/v0.1.0/commons-0.1.0.tgz
```
4 months ago
## Usage
### 安装整个包
```sh
npm install http://xxxx/npm/haina-npm-0.1.0.tgz
```
```js
4 months ago
//
import { commons, request, utils, hooks } from '@haina/npm';
// Import only common utilities
import { isEmpty } from '@haina/npm/build/esm/utils/commons.js';
// Import only request utilities
import { fetchJSON } from '@haina/npm/build/esm/utils/request.js';
4 months ago
```
4 months ago
### 安装单个模块
4 months ago
```sh
npm install http://xxxx/npm/utils-0.1.0.tgz
npm install http://xxxx/npm/hooks-0.1.0.tgz
```
```js
import { commons, request } from '@haina/utils';
```
### 安装Utils的子模块
4 months ago
```sh
npm install http://xxxx/npm/utils-commons-0.1.0.tgz
4 months ago
npm install https://package.mycht.cn/npmjs/commons-0.1.0.tgz
4 months ago
```
```js
import { isEmpty } from '@haina/utils-commons';
```