@icebreakers/monorepo-templates 0.0.0

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.
Files changed (201) hide show
  1. package/README.md +9 -0
  2. package/assets/.changeset/config.json +16 -0
  3. package/assets/.changeset/create-icebreaker-interactive.md +5 -0
  4. package/assets/.changeset/monorepo-templates-package.md +5 -0
  5. package/assets/.changeset/skills-sync-resources.md +5 -0
  6. package/assets/.dockerignore +44 -0
  7. package/assets/.editorconfig +12 -0
  8. package/assets/.gitattributes +218 -0
  9. package/assets/.github/FUNDING.yml +4 -0
  10. package/assets/.github/ISSUE_TEMPLATE/bug_report.yml +71 -0
  11. package/assets/.github/ISSUE_TEMPLATE/config.yml +17 -0
  12. package/assets/.github/workflows/ci.yml +62 -0
  13. package/assets/.github/workflows/release.yml +57 -0
  14. package/assets/.husky/commit-msg +4 -0
  15. package/assets/.husky/pre-commit +4 -0
  16. package/assets/.vscode/extensions.json +6 -0
  17. package/assets/.vscode/settings.json +172 -0
  18. package/assets/CODE_OF_CONDUCT.md +128 -0
  19. package/assets/CONTRIBUTING.md +3 -0
  20. package/assets/Dockerfile +27 -0
  21. package/assets/LICENSE +21 -0
  22. package/assets/SECURITY.md +21 -0
  23. package/assets/commitlint.config.ts +3 -0
  24. package/assets/eslint.config.js +7 -0
  25. package/assets/gitignore +38 -0
  26. package/assets/lint-staged.config.js +11 -0
  27. package/assets/monorepo.config.ts +22 -0
  28. package/assets/netlify.toml +14 -0
  29. package/assets/package.json +88 -0
  30. package/assets/pnpm-workspace.yaml +11 -0
  31. package/assets/renovate.json +28 -0
  32. package/assets/stylelint.config.js +3 -0
  33. package/assets/tsconfig.json +51 -0
  34. package/assets/turbo.json +74 -0
  35. package/assets/vitest.config.ts +123 -0
  36. package/assets-data.mjs +45 -0
  37. package/dist/index.d.mts +37 -0
  38. package/dist/index.mjs +287 -0
  39. package/package.json +51 -0
  40. package/skeleton/.editorconfig +12 -0
  41. package/skeleton/LICENSE +21 -0
  42. package/skeleton/commitlint.config.ts +3 -0
  43. package/skeleton/eslint.config.js +7 -0
  44. package/skeleton/gitignore +38 -0
  45. package/skeleton/lint-staged.config.js +11 -0
  46. package/skeleton/package.json +88 -0
  47. package/skeleton/pnpm-workspace.yaml +11 -0
  48. package/skeleton/renovate.json +28 -0
  49. package/skeleton/stylelint.config.js +3 -0
  50. package/skeleton/tsconfig.json +51 -0
  51. package/skeleton/turbo.json +74 -0
  52. package/skeleton/vitest.config.ts +123 -0
  53. package/template-data.mjs +10 -0
  54. package/templates/cli/bin/index.js +2 -0
  55. package/templates/cli/dev/index.ts +2 -0
  56. package/templates/cli/gitignore +2 -0
  57. package/templates/cli/package.json +35 -0
  58. package/templates/cli/src/cli.ts +4 -0
  59. package/templates/cli/src/index.ts +15 -0
  60. package/templates/cli/tsconfig.json +7 -0
  61. package/templates/cli/tsup.config.ts +13 -0
  62. package/templates/client/eslint.config.js +12 -0
  63. package/templates/client/gitignore +28 -0
  64. package/templates/client/index.html +13 -0
  65. package/templates/client/package.json +52 -0
  66. package/templates/client/public/vite.svg +1 -0
  67. package/templates/client/src/App.vue +11 -0
  68. package/templates/client/src/main.ts +16 -0
  69. package/templates/client/src/pages/index.vue +357 -0
  70. package/templates/client/src/query-keys.ts +4 -0
  71. package/templates/client/src/router/index.ts +13 -0
  72. package/templates/client/src/stores/i18n.ts +24 -0
  73. package/templates/client/src/stores/index.ts +15 -0
  74. package/templates/client/src/style.css +1 -0
  75. package/templates/client/src/trpc/index.ts +10 -0
  76. package/templates/client/src/vite-env.d.ts +2 -0
  77. package/templates/client/tsconfig.app.json +28 -0
  78. package/templates/client/tsconfig.json +8 -0
  79. package/templates/client/tsconfig.node.json +25 -0
  80. package/templates/client/tsconfig.worker.json +11 -0
  81. package/templates/client/vite.config.ts +57 -0
  82. package/templates/client/worker/app.ts +24 -0
  83. package/templates/client/worker/config.ts +1 -0
  84. package/templates/client/worker/fetch-entry.ts +5 -0
  85. package/templates/client/worker/node-entry.ts +13 -0
  86. package/templates/client/worker/trpc-router.ts +24 -0
  87. package/templates/client/wrangler.jsonc +24 -0
  88. package/templates/server/gitignore +2 -0
  89. package/templates/server/package.json +60 -0
  90. package/templates/server/src/app.ts +191 -0
  91. package/templates/server/src/config.ts +1 -0
  92. package/templates/server/src/fetch-entry.ts +5 -0
  93. package/templates/server/src/node-entry.ts +13 -0
  94. package/templates/server/test/index.test.ts +14 -0
  95. package/templates/server/tsconfig.json +24 -0
  96. package/templates/server/tsup.config.ts +13 -0
  97. package/templates/server/vitest.config.ts +15 -0
  98. package/templates/server/wrangler.jsonc +18 -0
  99. package/templates/tsdown/package.json +47 -0
  100. package/templates/tsdown/src/index.ts +5 -0
  101. package/templates/tsdown/test/index.test.ts +11 -0
  102. package/templates/tsdown/tsconfig.json +15 -0
  103. package/templates/tsdown/tsdown.config.ts +9 -0
  104. package/templates/tsdown/vitest.config.ts +15 -0
  105. package/templates/tsup/build.config.ts +24 -0
  106. package/templates/tsup/package.json +48 -0
  107. package/templates/tsup/src/index.ts +12 -0
  108. package/templates/tsup/test/index.test.ts +18 -0
  109. package/templates/tsup/tsconfig.json +15 -0
  110. package/templates/tsup/tsup.config.ts +18 -0
  111. package/templates/tsup/vitest.config.ts +15 -0
  112. package/templates/unbuild/build.config.ts +24 -0
  113. package/templates/unbuild/package.json +48 -0
  114. package/templates/unbuild/src/index.ts +9 -0
  115. package/templates/unbuild/src/utils.ts +3 -0
  116. package/templates/unbuild/test/index.test.ts +18 -0
  117. package/templates/unbuild/tsconfig.json +15 -0
  118. package/templates/unbuild/vitest.config.ts +15 -0
  119. package/templates/vitepress/.vitepress/config.ts +93 -0
  120. package/templates/vitepress/.vitepress/theme/index.ts +4 -0
  121. package/templates/vitepress/.vitepress/theme/tailwind.css +1 -0
  122. package/templates/vitepress/gitignore +1 -0
  123. package/templates/vitepress/index.md +127 -0
  124. package/templates/vitepress/monorepo/index.md +46 -0
  125. package/templates/vitepress/monorepo/manage.md +129 -0
  126. package/templates/vitepress/monorepo/publish.md +142 -0
  127. package/templates/vitepress/package.json +39 -0
  128. package/templates/vitepress/public/logo.jpg +0 -0
  129. package/templates/vitepress/thinking.md +88 -0
  130. package/templates/vitepress/tools/changeset.md +87 -0
  131. package/templates/vitepress/tools/husky.md +108 -0
  132. package/templates/vitepress/tools/lint-staged.md +79 -0
  133. package/templates/vitepress/tools/pnpm.md +101 -0
  134. package/templates/vitepress/tools/renovate.md +91 -0
  135. package/templates/vitepress/tools/turborepo.md +149 -0
  136. package/templates/vitepress/why/assets/npm-dt.svg +15 -0
  137. package/templates/vitepress/why/assets/npm-ts.svg +19 -0
  138. package/templates/vitepress/why/examples/0.npm-basic-package/index.js +10 -0
  139. package/templates/vitepress/why/examples/0.npm-basic-package/package.json +11 -0
  140. package/templates/vitepress/why/examples/1.npm-basic-package/index.cjs +12 -0
  141. package/templates/vitepress/why/examples/1.npm-basic-package/index.d.ts +1 -0
  142. package/templates/vitepress/why/examples/1.npm-basic-package/index.js +8 -0
  143. package/templates/vitepress/why/examples/1.npm-basic-package/package.json +19 -0
  144. package/templates/vitepress/why/examples/2.npm-basic-package/README.md +1 -0
  145. package/templates/vitepress/why/examples/2.npm-basic-package/package-lock.json +30 -0
  146. package/templates/vitepress/why/examples/2.npm-basic-package/package.json +35 -0
  147. package/templates/vitepress/why/examples/2.npm-basic-package/rename-ext.js +24 -0
  148. package/templates/vitepress/why/examples/2.npm-basic-package/src/index.ts +8 -0
  149. package/templates/vitepress/why/examples/2.npm-basic-package/tsconfig.cjs.json +8 -0
  150. package/templates/vitepress/why/examples/2.npm-basic-package/tsconfig.esm.json +7 -0
  151. package/templates/vitepress/why/examples/2.npm-basic-package/tsconfig.json +18 -0
  152. package/templates/vitepress/why/examples/3.npm-basic-package/README.md +1 -0
  153. package/templates/vitepress/why/examples/3.npm-basic-package/build.config.ts +24 -0
  154. package/templates/vitepress/why/examples/3.npm-basic-package/package-lock.json +3661 -0
  155. package/templates/vitepress/why/examples/3.npm-basic-package/package.json +32 -0
  156. package/templates/vitepress/why/examples/3.npm-basic-package/src/index.ts +8 -0
  157. package/templates/vitepress/why/examples/3.npm-basic-package/tsconfig.json +16 -0
  158. package/templates/vitepress/why/examples/3.npm-basic-package/tsup.config.ts +16 -0
  159. package/templates/vitepress/why/examples/usage-cjs/cjs.cjs +4 -0
  160. package/templates/vitepress/why/examples/usage-cjs/esm.mjs +4 -0
  161. package/templates/vitepress/why/examples/usage-cjs/index.js +12 -0
  162. package/templates/vitepress/why/examples/usage-cjs/package-lock.json +42 -0
  163. package/templates/vitepress/why/examples/usage-cjs/package.json +20 -0
  164. package/templates/vitepress/why/examples/usage-esm/cjs.cjs +4 -0
  165. package/templates/vitepress/why/examples/usage-esm/createRequire.js +7 -0
  166. package/templates/vitepress/why/examples/usage-esm/esm.mjs +4 -0
  167. package/templates/vitepress/why/examples/usage-esm/index.js +8 -0
  168. package/templates/vitepress/why/examples/usage-esm/package-lock.json +42 -0
  169. package/templates/vitepress/why/examples/usage-esm/package.json +21 -0
  170. package/templates/vitepress/why/how-to-reuse-js-code.md +250 -0
  171. package/templates/vitepress/why/index.md +1 -0
  172. package/templates/vitepress/why/js-cjs-mjs.md +99 -0
  173. package/templates/vitepress/why/js-keywords.md +132 -0
  174. package/templates/vitepress/why/modern/bundlers.md +79 -0
  175. package/templates/vitepress/why/modern/dts.md +93 -0
  176. package/templates/vitepress/why/modern/esm-vs-cjs.md +84 -0
  177. package/templates/vitepress/why/modern/index.md +55 -0
  178. package/templates/vitepress/why/modern/package-entry-points.md +128 -0
  179. package/templates/vitepress/why/modern/typescript.md +155 -0
  180. package/templates/vitepress/why/publish-basic-npm-package.md +146 -0
  181. package/templates/vitepress/why/what-is-npm-package.md +162 -0
  182. package/templates/vue-lib/eslint.config.js +12 -0
  183. package/templates/vue-lib/gitignore +1 -0
  184. package/templates/vue-lib/index.html +13 -0
  185. package/templates/vue-lib/lib/HelloWorld.vue +21 -0
  186. package/templates/vue-lib/lib/index.ts +3 -0
  187. package/templates/vue-lib/package.json +61 -0
  188. package/templates/vue-lib/src/App.vue +9 -0
  189. package/templates/vue-lib/src/main.ts +8 -0
  190. package/templates/vue-lib/src/pages/index.vue +7 -0
  191. package/templates/vue-lib/src/router/index.ts +11 -0
  192. package/templates/vue-lib/src/style.css +1 -0
  193. package/templates/vue-lib/src/vite-env.d.ts +2 -0
  194. package/templates/vue-lib/test/index.test.ts +13 -0
  195. package/templates/vue-lib/tsconfig.app.json +30 -0
  196. package/templates/vue-lib/tsconfig.json +14 -0
  197. package/templates/vue-lib/tsconfig.node.json +25 -0
  198. package/templates/vue-lib/tsconfig.test.json +40 -0
  199. package/templates/vue-lib/vite.config.ts +54 -0
  200. package/templates/vue-lib/vite.shared.config.ts +13 -0
  201. package/templates/vue-lib/vitest.config.ts +13 -0
@@ -0,0 +1,149 @@
1
+ # Turborepo
2
+
3
+ ## 1. 什么是 Turborepo?
4
+
5
+ **Turborepo** 是由 **Vercel** 推出的一个 **高性能 JavaScript/TypeScript monorepo 构建系统**。
6
+
7
+ 它的定位类似于 **NX / Bazel**,但更轻量、更贴合前端生态。
8
+ 主要解决 **monorepo(多包/多项目仓库)** 下的构建、缓存和任务调度问题。
9
+
10
+ 👉 通俗说:
11
+ 在一个仓库里有多个应用和包,**Turborepo 可以帮你高效管理它们的依赖、构建、测试和发布**。
12
+
13
+ ## 2. Turborepo 有什么用?
14
+
15
+ ### 🚀 性能优化
16
+
17
+ - **增量构建**:只重新构建改动过的包,而不是全量重建。
18
+ - **智能缓存**:构建结果会缓存,本地和 CI/CD 环境可以共享(比如用远程缓存)。
19
+ - **任务并行化**:最大化利用 CPU 核心,减少构建时间。
20
+
21
+ ### 📦 Monorepo 管理
22
+
23
+ - 可以在一个仓库中维护多个项目(比如 `templates/` 下是模板,`packages/` 下是共享组件或工具)。
24
+ - 内置工作区(workspace)支持,自动管理依赖关系。
25
+
26
+ ### 🛠 灵活的任务编排
27
+
28
+ - 你可以定义 `build`、`test`、`lint` 等任务,Turborepo 会根据依赖关系和缓存情况决定执行策略。
29
+
30
+ ### 🌍 和 Vercel 深度集成
31
+
32
+ - 在 Vercel 平台上可以直接利用远程缓存,加速 CI/CD。
33
+
34
+ ## 3. Turborepo 怎么用?
35
+
36
+ ### 安装
37
+
38
+ 全局安装(可选):
39
+
40
+ ```bash
41
+ npm install turbo --global
42
+ ```
43
+
44
+ 在项目中初始化:
45
+
46
+ ```bash
47
+ npx create-turbo@latest
48
+ ```
49
+
50
+ 这会生成一个 monorepo 结构,比如:
51
+
52
+ ```
53
+ .
54
+ ├── apps
55
+ │ ├── web # 前端应用
56
+ │ └── docs # 文档应用
57
+ └── packages
58
+ ├── ui # UI 组件库
59
+ └── config # 配置共享包
60
+ ```
61
+
62
+ ### 配置 `turbo.json`
63
+
64
+ 核心配置文件,放在仓库根目录:
65
+
66
+ ```json
67
+ {
68
+ "$schema": "https://turbo.build/schema.json",
69
+ "pipeline": {
70
+ "build": {
71
+ "dependsOn": ["^build"],
72
+ "outputs": ["dist/**", ".next/**"]
73
+ },
74
+ "lint": {},
75
+ "test": {
76
+ "dependsOn": ["build"]
77
+ }
78
+ }
79
+ }
80
+ ```
81
+
82
+ 解释:
83
+
84
+ - `build` 任务依赖于上游包的 `build`。
85
+ - 缓存 `dist/**` 或 `.next/**` 输出目录。
86
+ - `test` 依赖于 `build`。
87
+
88
+ ### 运行命令
89
+
90
+ 在根目录执行:
91
+
92
+ ```bash
93
+ turbo run build
94
+ ```
95
+
96
+ 👉 Turborepo 会:
97
+
98
+ - 找到所有定义了 `build` 脚本的项目。
99
+ - 根据依赖关系决定执行顺序。
100
+ - 如果缓存可用,直接跳过执行,秒完成。
101
+
102
+ 同理:
103
+
104
+ ```bash
105
+ turbo run lint
106
+ turbo run test
107
+ ```
108
+
109
+ ### 远程缓存(可选)
110
+
111
+ 如果团队协作或 CI/CD,需要共享缓存:
112
+
113
+ ```bash
114
+ npx turbo login
115
+ npx turbo link
116
+ ```
117
+
118
+ 这样不同开发者、CI 都可以复用缓存,进一步加速。
119
+
120
+ ## 4. 总结
121
+
122
+ - **Turborepo = 高性能 monorepo 构建工具**。
123
+ - **核心优势**:缓存、增量构建、并行执行、依赖感知。
124
+ - **适用场景**:
125
+ - 大型 monorepo(多个应用 + 包)。
126
+ - 需要快速构建和测试的团队。
127
+ - 想用 Vercel 部署的项目。
128
+
129
+ 好的 👍,我来帮你把 **Turborepo、Lerna、Nx** 三个常见 **Monorepo 管理工具**做一个对比表。
130
+
131
+ ## Turborepo vs Lerna vs Nx
132
+
133
+ | 特性 / 工具 | **Turborepo** | **Lerna** | **Nx** |
134
+ | ----------------- | ---------------------------------------- | ------------------------------------------- | ----------------------------------------------- |
135
+ | **定位** | 高性能构建系统,专注缓存、并行和增量构建 | 最早的 JS monorepo 工具,专注版本管理和发布 | 企业级开发平台,集成构建、测试、代码生成等功能 |
136
+ | **核心优势** | ⚡ 高速缓存(本地 & 远程)、并行任务执行 | 📦 包版本管理(独立/统一模式)、发布到 npm | 🛠 丰富的插件生态、代码生成器、强大的依赖图分析 |
137
+ | **依赖管理** | 基于 pnpm/yarn/npm workspaces | 基于 npm/yarn workspaces | 内置强依赖图(project graph)管理 |
138
+ | **构建/缓存机制** | ✅ 智能缓存 & 增量构建 | ❌ 无缓存机制 | ✅ 强大缓存 & 增量构建(类似 Bazel) |
139
+ | **任务编排** | pipeline 模式(`turbo.json`) | 简单顺序执行 | 高度可配置任务调度器(依赖感知) |
140
+ | **语言支持** | 主要是 JS/TS 生态 | 主要是 JS/TS 生态 | 多语言支持(JS/TS/Go/Rust/Python 等) |
141
+ | **学习成本** | ⭐⭐ 低(配置简洁,前端友好) | ⭐⭐ 低(老牌工具,功能单一) | ⭐⭐⭐ 高(功能多,配置复杂) |
142
+ | **社区活跃度** | 🚀 高(Vercel 维护,发展迅速) | ⚠️ 中等(已过巅峰,更多用于发布流程) | 🚀 高(企业应用广泛,社区和插件丰富) |
143
+ | **适合场景** | 前端/全栈项目,追求构建速度 & CI/CD 效率 | 多包库发布(如 npm 包集合项目) | 大型企业级 monorepo,跨语言/跨团队复杂项目 |
144
+
145
+ ## 对比总结
146
+
147
+ - **Turborepo**:主打 **快**,缓存和增量构建体验非常好,适合前端/全栈团队。
148
+ - **Lerna**:更像是 **版本管理/发包工具**,现在多和 pnpm/Yarn Workspaces 搭配,用于管理 npm 包版本和发布。
149
+ - **Nx**:功能最全,适合大型团队,有可视化依赖图、代码生成、跨语言支持,但学习曲线较陡。
@@ -0,0 +1,15 @@
1
+ <?xml version="1.0" encoding="utf-8"?>
2
+ <!-- Generator: Adobe Illustrator 23.1.1, SVG Export Plug-In . SVG Version: 6.00 Build 0) -->
3
+ <svg version="1.1" id="Layer_1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px"
4
+ viewBox="0 0 256 256" style="enable-background:new 0 0 256 256;" xml:space="preserve">
5
+ <style type="text/css">
6
+ .st0{fill:#3178C6;}
7
+ .st1{fill:#FFFFFF;}
8
+ </style>
9
+ <rect class="st0" width="256" height="256"/>
10
+ <rect x="6" y="6" class="st1" width="244" height="244"/>
11
+ <path class="st0" d="M41.8,111.5c8.6-1.6,19.9-2.5,31.8-2.5c19.7,0,32.6,4.2,42.6,13c10.8,9.4,17.6,24.5,17.6,46
12
+ c0,23.4-7.3,39.5-17.3,49.5c-11,10.7-27.6,15.8-48,15.8c-12.2,0-20.8-0.9-26.7-1.8V111.5z M65.4,211.2c2,0.5,5.2,0.5,8.2,0.5
13
+ c21.3,0.2,35.2-13.6,35.2-42.7c0.2-25.4-12.5-38.8-32.7-38.8c-5.2,0-8.6,0.5-10.6,1.1V211.2z"/>
14
+ <path class="st0" d="M169.4,134.7h-32.2v-22.8h92.3v22.8h-32.8V232h-27.3V134.7z"/>
15
+ </svg>
@@ -0,0 +1,19 @@
1
+ <?xml version="1.0" encoding="utf-8"?>
2
+ <!-- Generator: Adobe Illustrator 23.1.1, SVG Export Plug-In . SVG Version: 6.00 Build 0) -->
3
+ <svg version="1.1" id="Layer_1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px"
4
+ viewBox="0 0 256 256" style="enable-background:new 0 0 256 256;" xml:space="preserve">
5
+ <style type="text/css">
6
+ .st0{fill:#3178C6;}
7
+ .st1{fill-rule:evenodd;clip-rule:evenodd;fill:#FFFFFF;}
8
+ </style>
9
+ <rect class="st0" width="256" height="256"/>
10
+ <path class="st1" d="M150.5,200.5v27.6c4.5,2.3,9.8,4,15.9,5.2s12.6,1.7,19.4,1.7c6.6,0,12.9-0.6,18.9-1.9s11.2-3.4,15.7-6.3
11
+ c4.5-2.9,8-6.7,10.7-11.4c2.6-4.7,3.9-10.5,3.9-17.4c0-5-0.7-9.4-2.2-13.2s-3.7-7.1-6.5-10.1c-2.8-2.9-6.2-5.6-10.1-7.9
12
+ c-3.9-2.3-8.4-4.5-13.3-6.6c-3.6-1.5-6.9-2.9-9.8-4.4c-2.9-1.4-5.3-2.8-7.3-4.3c-2-1.5-3.6-3-4.7-4.7s-1.6-3.5-1.6-5.6
13
+ c0-1.9,0.5-3.6,1.5-5.1s2.4-2.8,4.1-3.9c1.8-1.1,4-1.9,6.6-2.5c2.6-0.6,5.5-0.9,8.6-0.9c2.3,0,4.7,0.2,7.3,0.5
14
+ c2.6,0.3,5.1,0.9,7.7,1.6c2.6,0.7,5.1,1.6,7.6,2.7c2.4,1.1,4.7,2.4,6.8,3.8v-25.8c-4.2-1.6-8.8-2.8-13.8-3.6s-10.7-1.2-17.1-1.2
15
+ c-6.6,0-12.8,0.7-18.7,2.1c-5.9,1.4-11,3.6-15.5,6.6c-4.5,3-8,6.8-10.6,11.4c-2.6,4.6-3.9,10.2-3.9,16.6c0,8.2,2.4,15.2,7.1,21.1
16
+ c4.8,5.8,12,10.7,21.6,14.8c3.8,1.6,7.3,3.1,10.6,4.6c3.3,1.5,6.1,3,8.5,4.7s4.3,3.4,5.7,5.3s2.1,4.1,2.1,6.5c0,1.8-0.4,3.4-1.3,5
17
+ c-0.9,1.5-2.2,2.8-3.9,4s-3.9,2-6.6,2.6s-5.7,0.9-9.2,0.9c-6,0-11.9-1.1-17.8-3.2C161,207.8,155.5,204.7,150.5,200.5L150.5,200.5z
18
+ M104.5,131.7H140V109H41v22.7h35.3V233h28.1V131.7z"/>
19
+ </svg>
@@ -0,0 +1,10 @@
1
+ /* eslint-disable no-console */
2
+ console.log(`load ${__filename}`)
3
+
4
+ function sayHello() {
5
+ console.log('hello world')
6
+ }
7
+
8
+ module.exports = {
9
+ sayHello,
10
+ }
@@ -0,0 +1,11 @@
1
+ {
2
+ "name": "icebreaker-npm-basic-package",
3
+ "version": "1.0.0",
4
+ "description": "",
5
+ "author": "",
6
+ "license": "ISC",
7
+ "main": "index.js",
8
+ "scripts": {
9
+ "start": "node ."
10
+ }
11
+ }
@@ -0,0 +1,12 @@
1
+ /* eslint-disable no-console */
2
+ console.log(`cjs load ${__filename}`)
3
+
4
+ function sayHello() {
5
+ const message = 'hello world cjs'
6
+ console.log(message)
7
+ return message
8
+ }
9
+
10
+ module.exports = {
11
+ sayHello,
12
+ }
@@ -0,0 +1 @@
1
+ export const sayHello: () => string
@@ -0,0 +1,8 @@
1
+ /* eslint-disable no-console */
2
+ console.log(`esm load ${import.meta.filename}`)
3
+
4
+ export function sayHello() {
5
+ const message = 'hello world esm'
6
+ console.log(message)
7
+ return message
8
+ }
@@ -0,0 +1,19 @@
1
+ {
2
+ "name": "icebreaker-npm-basic-package-multiple-exports",
3
+ "type": "module",
4
+ "version": "0.0.0",
5
+ "description": "",
6
+ "author": "",
7
+ "license": "ISC",
8
+ "exports": {
9
+ ".": {
10
+ "types": "./index.d.ts",
11
+ "import": "./index.js",
12
+ "require": "./index.cjs"
13
+ }
14
+ },
15
+ "scripts": {
16
+ "start:cjs": "node ./index.cjs",
17
+ "start:esm": "node ./index.js"
18
+ }
19
+ }
@@ -0,0 +1 @@
1
+ https://monorepo.icebreaker.top/
@@ -0,0 +1,30 @@
1
+ {
2
+ "name": "icebreaker-npm-basic-package",
3
+ "version": "1.0.2",
4
+ "lockfileVersion": 3,
5
+ "requires": true,
6
+ "packages": {
7
+ "": {
8
+ "name": "icebreaker-npm-basic-package",
9
+ "version": "1.0.2",
10
+ "license": "ISC",
11
+ "devDependencies": {
12
+ "typescript": "^5.8.3"
13
+ }
14
+ },
15
+ "node_modules/typescript": {
16
+ "version": "5.8.3",
17
+ "resolved": "https://registry.npmjs.org/typescript/-/typescript-5.8.3.tgz",
18
+ "integrity": "sha512-p1diW6TqL9L07nNxvRMM7hMMw4c5XOo/1ibL4aAIGmSAt9slTE1Xgw5KWuof2uTOvCg9BY7ZRi+GaF+7sfgPeQ==",
19
+ "dev": true,
20
+ "license": "Apache-2.0",
21
+ "bin": {
22
+ "tsc": "bin/tsc",
23
+ "tsserver": "bin/tsserver"
24
+ },
25
+ "engines": {
26
+ "node": ">=14.17"
27
+ }
28
+ }
29
+ }
30
+ }
@@ -0,0 +1,35 @@
1
+ {
2
+ "name": "icebreaker-npm-basic-package",
3
+ "type": "module",
4
+ "version": "1.0.5",
5
+ "description": "",
6
+ "author": "",
7
+ "license": "ISC",
8
+ "exports": {
9
+ ".": {
10
+ "import": {
11
+ "types": "./dist/esm/index.d.ts",
12
+ "default": "./dist/esm/index.js"
13
+ },
14
+ "require": {
15
+ "types": "./dist/cjs/index.d.ts",
16
+ "default": "./dist/cjs/index.cjs"
17
+ }
18
+ }
19
+ },
20
+ "files": [
21
+ "dist"
22
+ ],
23
+ "scripts": {
24
+ "build:cjs": "tsc --project tsconfig.cjs.json && node rename-ext.js dist/cjs .js .cjs && node rename-ext.js dist/cjs .js.map .cjs.map",
25
+ "build:esm": "tsc --project tsconfig.esm.json",
26
+ "build": "npm run build:cjs && npm run build:esm",
27
+ "_debug:cjs": "node dist/cjs/index.js",
28
+ "debug:esm": "node dist/esm/index.js",
29
+ "debug": "tsx src/index.ts"
30
+ },
31
+ "devDependencies": {
32
+ "tsx": "^4.19.4",
33
+ "typescript": "^5.8.3"
34
+ }
35
+ }
@@ -0,0 +1,24 @@
1
+ // rename-ext.js
2
+ import fs from 'node:fs'
3
+ import path from 'node:path'
4
+ import process from 'node:process'
5
+
6
+ const [dir, fromExt, toExt] = process.argv.slice(2)
7
+
8
+ function renameFilesRecursively(currentPath) {
9
+ const entries = fs.readdirSync(currentPath, { withFileTypes: true })
10
+
11
+ for (const entry of entries) {
12
+ const fullPath = path.join(currentPath, entry.name)
13
+
14
+ if (entry.isDirectory()) {
15
+ renameFilesRecursively(fullPath)
16
+ }
17
+ else if (entry.isFile() && entry.name.endsWith(fromExt)) {
18
+ const newPath = fullPath.slice(0, -fromExt.length) + toExt
19
+ fs.renameSync(fullPath, newPath)
20
+ }
21
+ }
22
+ }
23
+
24
+ renameFilesRecursively(dir)
@@ -0,0 +1,8 @@
1
+ /* eslint-disable no-console */
2
+ export function sayHello() {
3
+ const message = 'hello world typescript'
4
+ console.log(message)
5
+ return message
6
+ }
7
+
8
+ console.log(`load package icebreaker-npm-basic-package`)
@@ -0,0 +1,8 @@
1
+ {
2
+ "extends": "./tsconfig.json",
3
+ "compilerOptions": {
4
+ "module": "commonjs",
5
+ "moduleResolution": "node10",
6
+ "outDir": "./dist/cjs"
7
+ }
8
+ }
@@ -0,0 +1,7 @@
1
+ {
2
+ "extends": "./tsconfig.json",
3
+ "compilerOptions": {
4
+ "module": "ESNext",
5
+ "outDir": "./dist/esm"
6
+ }
7
+ }
@@ -0,0 +1,18 @@
1
+ {
2
+ "compilerOptions": {
3
+ "target": "ES2020",
4
+ "rootDir": "./src",
5
+ "module": "ESNext",
6
+ "moduleResolution": "bundler",
7
+ "resolveJsonModule": true,
8
+ "strict": true,
9
+ "declaration": true,
10
+ "declarationMap": true,
11
+ "outDir": "./dist", // 具体格式的 tsconfig 会覆盖
12
+ "sourceMap": true,
13
+ "esModuleInterop": true,
14
+ "forceConsistentCasingInFileNames": true,
15
+ "skipLibCheck": true
16
+ },
17
+ "include": ["src"]
18
+ }
@@ -0,0 +1 @@
1
+ https://monorepo.icebreaker.top/
@@ -0,0 +1,24 @@
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
+ })