Skip to content

Commit

Permalink
fix: init project for npm placeholder
Browse files Browse the repository at this point in the history
  • Loading branch information
sonofmagic committed Jul 27, 2023
1 parent cd2a9a1 commit d9eb8ab
Show file tree
Hide file tree
Showing 6 changed files with 274 additions and 127 deletions.
32 changes: 1 addition & 31 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,31 +1 @@
# npm-lib-rollup-template

[![codecov](https://codecov.io/gh/sonofmagic/npm-lib-rollup-template/branch/main/graph/badge.svg?token=zn05qXYznt)](https://codecov.io/gh/sonofmagic/npm-lib-rollup-template)

本人用于编写的一个 `npm` 包的一个模板

- 使用 `rollup` 打包 (兼容 `tsc`)
- 使用 ~~`jest`~~ `vitest` 作为单元测试框架
- 使用 `eslint` 来规范代码风格,默认风格为 `standard`
- 输出 `dist` -> `cjs`,`esm` and `.d.ts`
- 使用 `semantic-release` 来发布 `npm`/`github`

## 为什么使用 `vitest` 而不是原先的 `jest`

`vitest` 开箱即用,`jest` 在同时遇到 `cjs``esm` 依赖的时候,支持很差,经常会失败,而且配置复杂,依赖的 `preset` 多,比如 `ts-jest`..

## scripts

### rename

执行 `npm run init:rename`

作用为替换 `package.json` 中默认包含的所有名称为 `npm-lib-rollup-template` 的字段

默认替换为新建代码仓库的文件夹名称!

### bin

执行 `npm run init:bin`

作用为 `package.json` 添加 `files``bin`,同时生成 `bin/{{pkg.name}}.js``src/cli.ts` 文件
# weapp-pandacss (WIP)
26 changes: 20 additions & 6 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "npm-lib-rollup-template",
"name": "weapp-pandacss",
"version": "0.0.0",
"description": "npm-lib-rollup-template",
"description": "weapp-pandacss (WIP)",
"main": "dist/index.js",
"module": "dist/index.mjs",
"types": "types/index.d.ts",
Expand All @@ -24,7 +24,7 @@
"packageManager": "[email protected]",
"repository": {
"type": "git",
"url": "https://github.com/sonofmagic/npm-lib-rollup-template.git"
"url": "https://github.com/sonofmagic/weapp-pandacss.git"
},
"files": [
"dist",
Expand All @@ -38,9 +38,9 @@
"author": "SonOfMagic <[email protected]>",
"license": "MIT",
"bugs": {
"url": "https://github.com/sonofmagic/npm-lib-rollup-template/issues"
"url": "https://github.com/sonofmagic/weapp-pandacss/issues"
},
"homepage": "https://github.com/sonofmagic/npm-lib-rollup-template#readme",
"homepage": "https://github.com/sonofmagic/weapp-pandacss#readme",
"devDependencies": {
"@rollup/plugin-alias": "^5.0.0",
"@rollup/plugin-commonjs": "^25.0.3",
Expand Down Expand Up @@ -77,6 +77,20 @@
"tslib": "^2.6.1",
"typescript": "^5.1.6",
"typescript-transform-paths": "^3.4.6",
"vitest": "^0.33.0"
"vitest": "^0.33.0",
"postcss": "^8.4.27"
},
"dependencies": {
"@babel/generator": "^7.22.9",
"@babel/parser": "^7.22.7",
"@babel/traverse": "^7.22.8",
"@babel/types": "^7.22.5",
"@csstools/postcss-cascade-layers": "^4.0.0",
"@pandacss/config": "^0.8.0",
"postcss-selector-parser": "^6.0.13",
"semver": "^7.5.4"
},
"peerDependencies": {
"postcss": "^8.4"
}
}
Loading

0 comments on commit d9eb8ab

Please sign in to comment.