@icebreakers/monorepo-templates 0.1.16 → 1.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +12 -0
- package/assets/.changeset/config.json +7 -2
- package/assets/.github/workflows/ci.yml +8 -2
- package/assets/.github/workflows/release.yml +2 -2
- package/assets/.husky/commit-msg +1 -1
- package/assets/.husky/pre-commit +1 -1
- package/assets/.husky/pre-push +5 -0
- package/assets/AGENTS.md +8 -7
- package/assets/Dockerfile +5 -14
- package/assets/commitlint.config.ts +2 -2
- package/assets/eslint.config.js +2 -6
- package/assets/lint-staged.config.js +3 -0
- package/assets/package.json +41 -31
- package/assets/repoctl.config.ts +68 -0
- package/assets/stylelint.config.js +2 -2
- package/assets/tsconfig.json +1 -49
- package/assets/turbo.json +17 -6
- package/assets/vitest.config.ts +2 -125
- package/assets-data.mjs +3 -2
- package/dist/index.d.mts +22 -1
- package/dist/index.mjs +114 -32
- package/package.json +12 -8
- package/template-data.mjs +48 -8
- package/templates/cli/bin/index.js +1 -1
- package/templates/cli/package.json +5 -2
- package/templates/cli/{tsup.config.ts → tsdown.config.ts} +3 -2
- package/templates/client/eslint.config.js +5 -5
- package/templates/client/gitignore +0 -1
- package/templates/client/package.json +22 -22
- package/templates/client/vite.config.ts +4 -3
- package/templates/client/worker-configuration.d.ts +13557 -0
- package/templates/client/wrangler.jsonc +4 -6
- package/templates/server/eslint.config.js +8 -0
- package/templates/server/gitignore +0 -1
- package/templates/server/package.json +9 -8
- package/templates/server/src/app.ts +4 -4
- package/templates/server/tsconfig.json +1 -2
- package/templates/server/{tsup.config.ts → tsdown.config.ts} +2 -1
- package/templates/server/vitest.config.ts +7 -5
- package/templates/server/worker-configuration.d.ts +13557 -0
- package/templates/server/wrangler.jsonc +4 -6
- package/templates/tsdown/package.json +2 -1
- package/templates/tsdown/test-d/index.test-d.ts +5 -0
- package/templates/tsdown/tsconfig.json +1 -2
- package/templates/tsdown/vitest.config.ts +7 -5
- package/templates/vitepress/.vitepress/config.ts +34 -36
- package/templates/vitepress/getting-started.md +243 -0
- package/templates/vitepress/gitignore +2 -1
- package/templates/vitepress/index.md +144 -79
- package/templates/vitepress/monorepo/commands.md +291 -0
- package/templates/vitepress/monorepo/index.md +103 -34
- package/templates/vitepress/monorepo/manage.md +181 -80
- package/templates/vitepress/monorepo/publish.md +128 -57
- package/templates/vitepress/monorepo/templates.md +67 -0
- package/templates/vitepress/monorepo/troubleshooting.md +226 -0
- package/templates/vitepress/package.json +5 -5
- package/templates/vitepress/thinking.md +1 -1
- package/templates/vitepress/tools/husky.md +7 -2
- package/templates/vitepress/tools/lint-staged.md +15 -1
- package/templates/vitepress/why/examples/3.npm-basic-package/package-lock.json +605 -2770
- package/templates/vitepress/why/examples/3.npm-basic-package/package.json +5 -6
- package/templates/vitepress/why/examples/3.npm-basic-package/tsdown.config.ts +16 -0
- package/templates/vitepress/why/examples/usage-cjs/index.js +2 -6
- package/templates/vitepress/why/examples/usage-cjs/package-lock.json +7 -13
- package/templates/vitepress/why/examples/usage-cjs/package.json +2 -2
- package/templates/vitepress/why/examples/usage-esm/index.js +2 -2
- package/templates/vitepress/why/examples/usage-esm/package-lock.json +7 -13
- package/templates/vitepress/why/examples/usage-esm/package.json +2 -2
- package/templates/vitepress/why/modern/bundlers.md +19 -46
- package/templates/vue-lib/eslint.config.js +4 -4
- package/templates/vue-lib/package.json +15 -10
- package/templates/vue-lib/test-d/index.test-d.ts +6 -0
- package/templates/vue-lib/tsconfig.test.json +1 -1
- package/templates/vue-lib/vitest.config.ts +6 -5
- package/assets/monorepo.config.ts +0 -22
- package/assets/nano-staged.js +0 -18
- package/templates/tsup/build.config.ts +0 -24
- package/templates/tsup/package.json +0 -49
- package/templates/tsup/src/index.ts +0 -12
- package/templates/tsup/test/index.test.ts +0 -18
- package/templates/tsup/tsconfig.json +0 -15
- package/templates/tsup/tsup.config.ts +0 -18
- package/templates/tsup/vitest.config.ts +0 -15
- package/templates/unbuild/build.config.ts +0 -24
- package/templates/unbuild/package.json +0 -49
- package/templates/unbuild/src/index.ts +0 -9
- package/templates/unbuild/src/utils.ts +0 -5
- package/templates/unbuild/test/index.test.ts +0 -18
- package/templates/unbuild/tsconfig.json +0 -15
- package/templates/unbuild/vitest.config.ts +0 -15
- package/templates/vitepress/why/examples/3.npm-basic-package/build.config.ts +0 -24
- package/templates/vitepress/why/examples/3.npm-basic-package/tsup.config.ts +0 -16
|
@@ -19,14 +19,13 @@
|
|
|
19
19
|
"dist"
|
|
20
20
|
],
|
|
21
21
|
"scripts": {
|
|
22
|
-
"dev": "
|
|
23
|
-
"build:watch": "
|
|
24
|
-
"build": "
|
|
22
|
+
"dev": "tsdown --watch --sourcemap",
|
|
23
|
+
"build:watch": "tsdown --watch --sourcemap",
|
|
24
|
+
"build": "tsdown"
|
|
25
25
|
},
|
|
26
26
|
"devDependencies": {
|
|
27
|
-
"
|
|
27
|
+
"tsdown": "0.21.10",
|
|
28
28
|
"tsx": "^4.19.4",
|
|
29
|
-
"typescript": "^5.8.3"
|
|
30
|
-
"unbuild": "^3.5.0"
|
|
29
|
+
"typescript": "^5.8.3"
|
|
31
30
|
}
|
|
32
31
|
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { defineConfig } from 'tsdown'
|
|
2
|
+
|
|
3
|
+
export default defineConfig({
|
|
4
|
+
entry: ['src/index.ts'],
|
|
5
|
+
shims: true,
|
|
6
|
+
format: ['esm', 'cjs'],
|
|
7
|
+
clean: true,
|
|
8
|
+
dts: true,
|
|
9
|
+
target: 'node18',
|
|
10
|
+
cjsInterop: true,
|
|
11
|
+
outExtensions({ format }) {
|
|
12
|
+
return {
|
|
13
|
+
js: format === 'esm' ? '.mjs' : '.cjs',
|
|
14
|
+
}
|
|
15
|
+
},
|
|
16
|
+
})
|
|
@@ -1,12 +1,8 @@
|
|
|
1
1
|
/* eslint-disable no-console */
|
|
2
|
-
// import c from 'chalk'
|
|
3
|
-
// const c = require('chalk')
|
|
4
2
|
const { sayHello } = require('icebreaker-npm-basic-package')
|
|
5
3
|
const { sayHello: sayHelloCjs } = require('icebreaker-npm-basic-package-multiple-exports')
|
|
4
|
+
const pc = require('picocolors')
|
|
6
5
|
|
|
7
6
|
sayHello()
|
|
8
7
|
sayHelloCjs()
|
|
9
|
-
|
|
10
|
-
import('chalk').then(({ default: c }) => {
|
|
11
|
-
console.log(c.green('Hello World!'))
|
|
12
|
-
})
|
|
8
|
+
console.log(pc.green('Hello World!'))
|
|
@@ -9,22 +9,16 @@
|
|
|
9
9
|
"version": "1.0.0",
|
|
10
10
|
"license": "ISC",
|
|
11
11
|
"dependencies": {
|
|
12
|
-
"chalk": "^5.6.2",
|
|
13
12
|
"icebreaker-npm-basic-package": "^1.0.5",
|
|
14
|
-
"icebreaker-npm-basic-package-multiple-exports": "^0.0.0"
|
|
13
|
+
"icebreaker-npm-basic-package-multiple-exports": "^0.0.0",
|
|
14
|
+
"picocolors": "^1.1.1"
|
|
15
15
|
}
|
|
16
16
|
},
|
|
17
|
-
"node_modules/
|
|
18
|
-
"version": "
|
|
19
|
-
"resolved": "https://registry.npmjs.org/
|
|
20
|
-
"integrity": "sha512-
|
|
21
|
-
"license": "
|
|
22
|
-
"engines": {
|
|
23
|
-
"node": "^12.17.0 || ^14.13 || >=16.0.0"
|
|
24
|
-
},
|
|
25
|
-
"funding": {
|
|
26
|
-
"url": "https://github.com/chalk/chalk?sponsor=1"
|
|
27
|
-
}
|
|
17
|
+
"node_modules/picocolors": {
|
|
18
|
+
"version": "1.1.1",
|
|
19
|
+
"resolved": "https://registry.npmjs.org/picocolors/-/picocolors-1.1.1.tgz",
|
|
20
|
+
"integrity": "sha512-xceH2snhtb5M9liqDsmEw56le376mTZkEX/jEb/RxNFyegNul7eNslCXP9FDj/Lcu0X8KEyMceP2ntpaHrDEVA==",
|
|
21
|
+
"license": "ISC"
|
|
28
22
|
},
|
|
29
23
|
"node_modules/icebreaker-npm-basic-package": {
|
|
30
24
|
"version": "1.0.5",
|
|
@@ -13,8 +13,8 @@
|
|
|
13
13
|
"cjs": "node cjs.cjs"
|
|
14
14
|
},
|
|
15
15
|
"dependencies": {
|
|
16
|
-
"chalk": "^5.6.2",
|
|
17
16
|
"icebreaker-npm-basic-package": "^1.0.5",
|
|
18
|
-
"icebreaker-npm-basic-package-multiple-exports": "^0.0.0"
|
|
17
|
+
"icebreaker-npm-basic-package-multiple-exports": "^0.0.0",
|
|
18
|
+
"picocolors": "^1.1.1"
|
|
19
19
|
}
|
|
20
20
|
}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
/* eslint-disable no-console */
|
|
2
|
-
import c from 'chalk'
|
|
3
2
|
import { sayHello } from 'icebreaker-npm-basic-package'
|
|
4
3
|
import { sayHello as sayHello2 } from 'icebreaker-npm-basic-package-multiple-exports'
|
|
4
|
+
import pc from 'picocolors'
|
|
5
5
|
|
|
6
6
|
sayHello()
|
|
7
7
|
sayHello2()
|
|
8
|
-
console.log(
|
|
8
|
+
console.log(pc.green('Hello World!'))
|
|
@@ -9,22 +9,16 @@
|
|
|
9
9
|
"version": "1.0.0",
|
|
10
10
|
"license": "ISC",
|
|
11
11
|
"dependencies": {
|
|
12
|
-
"chalk": "^5.6.2",
|
|
13
12
|
"icebreaker-npm-basic-package": "1.0.5",
|
|
14
|
-
"icebreaker-npm-basic-package-multiple-exports": "^0.0.0"
|
|
13
|
+
"icebreaker-npm-basic-package-multiple-exports": "^0.0.0",
|
|
14
|
+
"picocolors": "^1.1.1"
|
|
15
15
|
}
|
|
16
16
|
},
|
|
17
|
-
"node_modules/
|
|
18
|
-
"version": "
|
|
19
|
-
"resolved": "https://registry.npmjs.org/
|
|
20
|
-
"integrity": "sha512-
|
|
21
|
-
"license": "
|
|
22
|
-
"engines": {
|
|
23
|
-
"node": "^12.17.0 || ^14.13 || >=16.0.0"
|
|
24
|
-
},
|
|
25
|
-
"funding": {
|
|
26
|
-
"url": "https://github.com/chalk/chalk?sponsor=1"
|
|
27
|
-
}
|
|
17
|
+
"node_modules/picocolors": {
|
|
18
|
+
"version": "1.1.1",
|
|
19
|
+
"resolved": "https://registry.npmjs.org/picocolors/-/picocolors-1.1.1.tgz",
|
|
20
|
+
"integrity": "sha512-xceH2snhtb5M9liqDsmEw56le376mTZkEX/jEb/RxNFyegNul7eNslCXP9FDj/Lcu0X8KEyMceP2ntpaHrDEVA==",
|
|
21
|
+
"license": "ISC"
|
|
28
22
|
},
|
|
29
23
|
"node_modules/icebreaker-npm-basic-package": {
|
|
30
24
|
"version": "1.0.5",
|
|
@@ -14,8 +14,8 @@
|
|
|
14
14
|
"cjs": "node cjs.cjs"
|
|
15
15
|
},
|
|
16
16
|
"dependencies": {
|
|
17
|
-
"chalk": "^5.6.2",
|
|
18
17
|
"icebreaker-npm-basic-package": "1.0.5",
|
|
19
|
-
"icebreaker-npm-basic-package-multiple-exports": "^0.0.0"
|
|
18
|
+
"icebreaker-npm-basic-package-multiple-exports": "^0.0.0",
|
|
19
|
+
"picocolors": "^1.1.1"
|
|
20
20
|
}
|
|
21
21
|
}
|
|
@@ -7,64 +7,37 @@
|
|
|
7
7
|
- `webpack` 我不用,因为打出来的产物代码丑,配置复杂
|
|
8
8
|
- `rollup` 我最早用的就是这个,现在不用因为要装的包太多了,而且需要你对打包器有一定的理解,在打包复杂需要高度自定义的场景下使用
|
|
9
9
|
- `esbuild` 用的少,直接用不是很方便,但是可以基于它做高度自定义(写插件)
|
|
10
|
-
- `tsup` 基于 `esbuild` 的傻瓜无脑式的打包器,非常好用
|
|
11
|
-
- `unbuild` 基于 `rollup` 的傻瓜无脑式的打包器,众多 `vite plugin` 源代码的御用打包器,还有基于 `jiti` 的 `stub` 模式,非常好用
|
|
12
10
|
- `vite` 在 Vite 8 中默认基于 `rolldown` + `oxc`,假如你需要构建前端组件,这个就是首选,毕竟你也懒得去自己处理各种各样的样式文件吧,比如打包新版本 `vue` 组件,只能使用这个的库模式进行打包。
|
|
13
11
|
- `rolldown`/`tsdown` 适合更偏向库构建和工具链场景,但生态兼容面和迁移经验仍然不如 `vite`/`rollup` 成熟,是否采用要看你的实际约束
|
|
14
12
|
|
|
15
|
-
|
|
13
|
+
当前这个仓库已经把通用类库模板收敛到 `tsdown`,组件库则继续使用 `vite` 库模式。
|
|
16
14
|
|
|
17
|
-
##
|
|
15
|
+
## 过时的方案
|
|
18
16
|
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
:::
|
|
22
|
-
|
|
23
|
-
```ts [tsup.config.ts]
|
|
24
|
-
import { defineConfig } from 'tsup'
|
|
17
|
+
:::warning 不推荐继续使用
|
|
18
|
+
`tsup` 和 `unbuild` 在这个模板仓库里已经被标记为过时方案,不再作为新项目的推荐构建工具。
|
|
19
|
+
:::
|
|
25
20
|
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
shims: true,
|
|
29
|
-
format: ['cjs', 'esm'],
|
|
30
|
-
clean: true,
|
|
31
|
-
dts: true,
|
|
32
|
-
cjsInterop: true,
|
|
33
|
-
splitting: true,
|
|
34
|
-
outExtension({ format }) {
|
|
35
|
-
return {
|
|
36
|
-
js: `.${format === 'esm' ? 'mjs' : 'cjs'}`,
|
|
37
|
-
}
|
|
38
|
-
},
|
|
39
|
-
})
|
|
40
|
-
```
|
|
21
|
+
- `tsup` 曾经用于部分 TypeScript 包和服务模板,但现在这些模板已经迁移到 `tsdown`。如果旧项目里还有 `tsup.config.ts`,建议改成 `tsdown.config.ts`,并把 `build` / `dev` 脚本切到 `tsdown`。
|
|
22
|
+
- `unbuild` 曾经用于库包开发时的 stub 流程,但这里的新模板已经统一使用 `tsdown --watch` 处理开发构建。新项目不要继续引入 `unbuild`。
|
|
41
23
|
|
|
42
|
-
|
|
24
|
+
新建 TypeScript 类库优先使用 `tsdown` 模板;Vue 组件库继续使用 `vite` 库模式。
|
|
43
25
|
|
|
44
|
-
##
|
|
26
|
+
## tsdown
|
|
45
27
|
|
|
46
|
-
|
|
28
|
+
本项目当前的通用类库模板是 [tsdown](https://github.com/sonofmagic/monorepo-template/tree/main/templates/tsdown)
|
|
47
29
|
|
|
48
30
|
:::code-group
|
|
49
31
|
|
|
50
|
-
```ts [
|
|
51
|
-
import
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
cjsBridge: true,
|
|
60
|
-
dts: {
|
|
61
|
-
respectExternal: false,
|
|
62
|
-
},
|
|
63
|
-
},
|
|
64
|
-
alias: {
|
|
65
|
-
'@': path.resolve(__dirname, './src'),
|
|
66
|
-
},
|
|
67
|
-
declaration: true,
|
|
32
|
+
```ts [tsdown.config.ts]
|
|
33
|
+
import { defineConfig } from 'tsdown'
|
|
34
|
+
|
|
35
|
+
export default defineConfig({
|
|
36
|
+
entry: ['./src/index.ts'],
|
|
37
|
+
format: ['cjs', 'esm'],
|
|
38
|
+
dts: true,
|
|
39
|
+
clean: true,
|
|
40
|
+
target: 'node18',
|
|
68
41
|
})
|
|
69
42
|
```
|
|
70
43
|
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { defineEslintConfig } from 'repoctl/tooling'
|
|
2
2
|
|
|
3
|
-
export default
|
|
4
|
-
{
|
|
3
|
+
export default await defineEslintConfig({
|
|
4
|
+
options: {
|
|
5
5
|
vue: true,
|
|
6
6
|
typescript: true,
|
|
7
7
|
ignores: ['**/fixtures/**'],
|
|
8
8
|
},
|
|
9
|
-
)
|
|
9
|
+
})
|
|
@@ -16,8 +16,12 @@
|
|
|
16
16
|
"keywords": [],
|
|
17
17
|
"sideEffects": false,
|
|
18
18
|
"exports": {
|
|
19
|
-
".":
|
|
19
|
+
".": {
|
|
20
|
+
"types": "./dist/index.d.ts",
|
|
21
|
+
"default": "./src/index.ts"
|
|
22
|
+
}
|
|
20
23
|
},
|
|
24
|
+
"types": "./dist/index.d.ts",
|
|
21
25
|
"files": [
|
|
22
26
|
"dist"
|
|
23
27
|
],
|
|
@@ -28,7 +32,8 @@
|
|
|
28
32
|
"release": "pnpm publish",
|
|
29
33
|
"lint": "eslint .",
|
|
30
34
|
"lint:fix": "eslint . --fix",
|
|
31
|
-
"typecheck": "vue-tsc -b"
|
|
35
|
+
"typecheck": "vue-tsc -b",
|
|
36
|
+
"tsd": "pnpm build && tsd --typings dist/index.d.ts --files test-d/**/*.test-d.ts"
|
|
32
37
|
},
|
|
33
38
|
"publishConfig": {
|
|
34
39
|
"exports": {
|
|
@@ -44,13 +49,13 @@
|
|
|
44
49
|
"types": "./dist/index.d.ts"
|
|
45
50
|
},
|
|
46
51
|
"devDependencies": {
|
|
47
|
-
"@vitejs/plugin-vue": "^6.0.
|
|
48
|
-
"@vue/test-utils": "^2.4.
|
|
49
|
-
"@vue/tsconfig": "^0.9.
|
|
50
|
-
"jsdom": "^29.
|
|
51
|
-
"vite": "^8.0.
|
|
52
|
-
"vite-plugin-dts": "^
|
|
53
|
-
"vue": "^3.5.
|
|
54
|
-
"vue-tsc": "^3.2.
|
|
52
|
+
"@vitejs/plugin-vue": "^6.0.6",
|
|
53
|
+
"@vue/test-utils": "^2.4.10",
|
|
54
|
+
"@vue/tsconfig": "^0.9.1",
|
|
55
|
+
"jsdom": "^29.1.1",
|
|
56
|
+
"vite": "^8.0.10",
|
|
57
|
+
"vite-plugin-dts": "^5.0.0",
|
|
58
|
+
"vue": "^3.5.33",
|
|
59
|
+
"vue-tsc": "^3.2.8"
|
|
55
60
|
}
|
|
56
61
|
}
|
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
import Vue from '@vitejs/plugin-vue'
|
|
2
|
+
import { defineVitestProjectConfig } from 'repoctl/tooling'
|
|
2
3
|
import { mergeConfig } from 'vitest/config'
|
|
3
4
|
import { sharedConfig } from './vite.shared.config'
|
|
4
5
|
|
|
5
6
|
export default mergeConfig(sharedConfig, {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
},
|
|
7
|
+
...await defineVitestProjectConfig({
|
|
8
|
+
options: {
|
|
9
|
+
environment: 'jsdom',
|
|
10
|
+
},
|
|
11
|
+
}),
|
|
11
12
|
plugins: [Vue()],
|
|
12
13
|
})
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
import { defineMonorepoConfig } from '@icebreakers/monorepo'
|
|
2
|
-
|
|
3
|
-
export default defineMonorepoConfig({
|
|
4
|
-
commands: {
|
|
5
|
-
create: {
|
|
6
|
-
defaultTemplate: 'unbuild',
|
|
7
|
-
renameJson: false,
|
|
8
|
-
},
|
|
9
|
-
clean: {
|
|
10
|
-
autoConfirm: false,
|
|
11
|
-
includePrivate: true,
|
|
12
|
-
},
|
|
13
|
-
sync: {
|
|
14
|
-
concurrency: 4,
|
|
15
|
-
command: 'cnpm sync {name}',
|
|
16
|
-
},
|
|
17
|
-
upgrade: {
|
|
18
|
-
skipOverwrite: false,
|
|
19
|
-
mergeTargets: true,
|
|
20
|
-
},
|
|
21
|
-
},
|
|
22
|
-
})
|
package/assets/nano-staged.js
DELETED
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
export default {
|
|
2
|
-
'*.{js,jsx,mjs,ts,tsx,mts}': [
|
|
3
|
-
'eslint --fix',
|
|
4
|
-
],
|
|
5
|
-
'*.vue': [
|
|
6
|
-
'eslint --fix',
|
|
7
|
-
'stylelint --fix --allow-empty-input',
|
|
8
|
-
],
|
|
9
|
-
'*.{json,md,mdx,html,yml,yaml}': [
|
|
10
|
-
// 'prettier --with-node-modules --ignore-path .prettierignore --write',
|
|
11
|
-
'eslint --fix',
|
|
12
|
-
],
|
|
13
|
-
'*.{css,scss,sass,less}': [
|
|
14
|
-
'stylelint --fix --allow-empty-input',
|
|
15
|
-
],
|
|
16
|
-
// for rust
|
|
17
|
-
// '*.rs': ['cargo fmt --'],
|
|
18
|
-
}
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
import path from 'node:path'
|
|
2
|
-
import { defineBuildConfig } from 'unbuild'
|
|
3
|
-
|
|
4
|
-
export default defineBuildConfig({
|
|
5
|
-
// entries: ['./src/index', './src/cli'],
|
|
6
|
-
rollup: {
|
|
7
|
-
// 内联,相当于 nodeResolve
|
|
8
|
-
inlineDependencies: true,
|
|
9
|
-
// cjs
|
|
10
|
-
emitCJS: true,
|
|
11
|
-
// 添加 cjs 注入
|
|
12
|
-
cjsBridge: true,
|
|
13
|
-
dts: {
|
|
14
|
-
// https://github.com/unjs/unbuild/issues/135
|
|
15
|
-
respectExternal: false,
|
|
16
|
-
},
|
|
17
|
-
},
|
|
18
|
-
alias: {
|
|
19
|
-
// 别名
|
|
20
|
-
'@': path.resolve(__dirname, './src'),
|
|
21
|
-
},
|
|
22
|
-
// dts
|
|
23
|
-
declaration: true,
|
|
24
|
-
})
|
|
@@ -1,49 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "@icebreakers/tsup-template",
|
|
3
|
-
"type": "module",
|
|
4
|
-
"version": "0.0.0",
|
|
5
|
-
"description": "tsup package template",
|
|
6
|
-
"author": "ice breaker <hi@sonofmagic.top>",
|
|
7
|
-
"license": "MIT",
|
|
8
|
-
"repository": {
|
|
9
|
-
"type": "git",
|
|
10
|
-
"url": "git+https://github.com/sonofmagic/monorepo-template.git",
|
|
11
|
-
"directory": "templates/tsup"
|
|
12
|
-
},
|
|
13
|
-
"bugs": {
|
|
14
|
-
"url": "https://github.com/sonofmagic/monorepo-template/issues"
|
|
15
|
-
},
|
|
16
|
-
"keywords": [],
|
|
17
|
-
"sideEffects": false,
|
|
18
|
-
"exports": {
|
|
19
|
-
".": {
|
|
20
|
-
"types": "./dist/index.d.ts",
|
|
21
|
-
"import": {
|
|
22
|
-
"types": "./dist/index.d.ts",
|
|
23
|
-
"default": "./dist/index.mjs"
|
|
24
|
-
},
|
|
25
|
-
"require": {
|
|
26
|
-
"types": "./dist/index.d.cts",
|
|
27
|
-
"default": "./dist/index.cjs"
|
|
28
|
-
}
|
|
29
|
-
}
|
|
30
|
-
},
|
|
31
|
-
"main": "./dist/index.cjs",
|
|
32
|
-
"module": "./dist/index.mjs",
|
|
33
|
-
"types": "./dist/index.d.ts",
|
|
34
|
-
"files": [
|
|
35
|
-
"dist"
|
|
36
|
-
],
|
|
37
|
-
"scripts": {
|
|
38
|
-
"stub": "unbuild --stub",
|
|
39
|
-
"dev": "tsup --watch --sourcemap",
|
|
40
|
-
"build": "tsup",
|
|
41
|
-
"test": "vitest run",
|
|
42
|
-
"test:dev": "vitest",
|
|
43
|
-
"release": "pnpm publish",
|
|
44
|
-
"lint": "eslint .",
|
|
45
|
-
"lint:fix": "eslint . --fix",
|
|
46
|
-
"typecheck": "tsc -p tsconfig.json"
|
|
47
|
-
},
|
|
48
|
-
"publishConfig": {}
|
|
49
|
-
}
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
import { bar, getDirname, xx } from '@/index'
|
|
2
|
-
|
|
3
|
-
describe('index', () => {
|
|
4
|
-
it('foo bar', () => {
|
|
5
|
-
expect(bar()).toBe('foo')
|
|
6
|
-
})
|
|
7
|
-
|
|
8
|
-
it('getDirname returns a directory path', () => {
|
|
9
|
-
const dirname = getDirname()
|
|
10
|
-
expect(typeof dirname).toBe('string')
|
|
11
|
-
expect(dirname.length).toBeGreaterThan(0)
|
|
12
|
-
})
|
|
13
|
-
|
|
14
|
-
it('xx enum exposes numeric indices', () => {
|
|
15
|
-
expect(xx.id).toBe(0)
|
|
16
|
-
expect(xx.dd).toBe(1)
|
|
17
|
-
})
|
|
18
|
-
})
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
import { defineConfig } from 'tsup'
|
|
2
|
-
|
|
3
|
-
export default defineConfig({
|
|
4
|
-
entry: ['src/index.ts'], // , 'src/cli.ts'],
|
|
5
|
-
shims: true,
|
|
6
|
-
format: ['cjs', 'esm'],
|
|
7
|
-
clean: true,
|
|
8
|
-
dts: true,
|
|
9
|
-
// https://github.com/egoist/tsup/pull/1056
|
|
10
|
-
// https://github.com/egoist/tsup/issues?q=cjsInterop
|
|
11
|
-
cjsInterop: true,
|
|
12
|
-
splitting: true,
|
|
13
|
-
outExtension({ format }) {
|
|
14
|
-
return {
|
|
15
|
-
js: `.${format === 'esm' ? 'mjs' : 'cjs'}`,
|
|
16
|
-
}
|
|
17
|
-
},
|
|
18
|
-
})
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
import path from 'node:path'
|
|
2
|
-
import { defineProject } from 'vitest/config'
|
|
3
|
-
|
|
4
|
-
export default defineProject({
|
|
5
|
-
test: {
|
|
6
|
-
alias: [
|
|
7
|
-
{
|
|
8
|
-
find: '@',
|
|
9
|
-
replacement: path.resolve(__dirname, './src'),
|
|
10
|
-
},
|
|
11
|
-
],
|
|
12
|
-
globals: true,
|
|
13
|
-
testTimeout: 60_000,
|
|
14
|
-
},
|
|
15
|
-
})
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
import path from 'node:path'
|
|
2
|
-
import { defineBuildConfig } from 'unbuild'
|
|
3
|
-
|
|
4
|
-
export default defineBuildConfig({
|
|
5
|
-
// entries: ['./src/index', './src/cli'],
|
|
6
|
-
rollup: {
|
|
7
|
-
// 内联,相当于 nodeResolve
|
|
8
|
-
inlineDependencies: true,
|
|
9
|
-
// cjs
|
|
10
|
-
emitCJS: true,
|
|
11
|
-
// 添加 cjs 注入
|
|
12
|
-
cjsBridge: true,
|
|
13
|
-
dts: {
|
|
14
|
-
// https://github.com/unjs/unbuild/issues/135
|
|
15
|
-
respectExternal: false,
|
|
16
|
-
},
|
|
17
|
-
},
|
|
18
|
-
alias: {
|
|
19
|
-
// 别名
|
|
20
|
-
'@': path.resolve(__dirname, './src'),
|
|
21
|
-
},
|
|
22
|
-
// dts
|
|
23
|
-
declaration: true,
|
|
24
|
-
})
|
|
@@ -1,49 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "@icebreakers/unbuild-template",
|
|
3
|
-
"type": "module",
|
|
4
|
-
"version": "0.0.0",
|
|
5
|
-
"description": "unbuild package template",
|
|
6
|
-
"author": "ice breaker <hi@sonofmagic.top>",
|
|
7
|
-
"license": "ISC",
|
|
8
|
-
"repository": {
|
|
9
|
-
"type": "git",
|
|
10
|
-
"url": "git+https://github.com/sonofmagic/monorepo-template.git",
|
|
11
|
-
"directory": "templates/unbuild"
|
|
12
|
-
},
|
|
13
|
-
"bugs": {
|
|
14
|
-
"url": "https://github.com/sonofmagic/monorepo-template/issues"
|
|
15
|
-
},
|
|
16
|
-
"keywords": [],
|
|
17
|
-
"sideEffects": false,
|
|
18
|
-
"exports": {
|
|
19
|
-
".": {
|
|
20
|
-
"types": "./dist/index.d.ts",
|
|
21
|
-
"import": {
|
|
22
|
-
"types": "./dist/index.d.mts",
|
|
23
|
-
"default": "./dist/index.mjs"
|
|
24
|
-
},
|
|
25
|
-
"require": {
|
|
26
|
-
"types": "./dist/index.d.cts",
|
|
27
|
-
"default": "./dist/index.cjs"
|
|
28
|
-
}
|
|
29
|
-
}
|
|
30
|
-
},
|
|
31
|
-
"main": "./dist/index.cjs",
|
|
32
|
-
"module": "./dist/index.mjs",
|
|
33
|
-
"types": "./dist/index.d.ts",
|
|
34
|
-
"files": [
|
|
35
|
-
"dist"
|
|
36
|
-
],
|
|
37
|
-
"scripts": {
|
|
38
|
-
"dev": "unbuild --stub",
|
|
39
|
-
"build:watch": "unbuild --watch --sourcemap",
|
|
40
|
-
"build": "unbuild",
|
|
41
|
-
"test": "vitest run",
|
|
42
|
-
"test:dev": "vitest",
|
|
43
|
-
"release": "pnpm publish",
|
|
44
|
-
"lint": "eslint .",
|
|
45
|
-
"lint:fix": "eslint . --fix",
|
|
46
|
-
"typecheck": "tsc -p tsconfig.json"
|
|
47
|
-
},
|
|
48
|
-
"publishConfig": {}
|
|
49
|
-
}
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
import { foo, format, getDirname } from '@/index'
|
|
2
|
-
|
|
3
|
-
describe('index', () => {
|
|
4
|
-
it('foo bar', () => {
|
|
5
|
-
expect(foo()).toBe('bar')
|
|
6
|
-
})
|
|
7
|
-
|
|
8
|
-
it('format uppercases alphabetical characters', () => {
|
|
9
|
-
expect(format('abc-123')).toBe('ABC-123')
|
|
10
|
-
})
|
|
11
|
-
|
|
12
|
-
it('getDirname exposes template directory path', () => {
|
|
13
|
-
const dirname = getDirname()
|
|
14
|
-
expect(typeof dirname).toBe('string')
|
|
15
|
-
expect(dirname.length).toBeGreaterThan(0)
|
|
16
|
-
expect(dirname).toContain('unbuild')
|
|
17
|
-
})
|
|
18
|
-
})
|