Skip to content

Commit 6d97e86

Browse files
committed
feat: add tsdown template and expose it via monorepo create choices
1 parent f5a7a60 commit 6d97e86

File tree

11 files changed

+440
-3
lines changed

11 files changed

+440
-3
lines changed

.changeset/add-tsdown-template.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'@icebreakers/monorepo': patch
3+
---
4+
5+
feat: add tsdown template and expose it via monorepo create choices

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,7 @@
6565
"pkg-types": "^2.3.0",
6666
"rimraf": "^6.0.1",
6767
"stylelint": "^16.25.0",
68+
"tsdown": "^0.15.11",
6869
"tslib": "^2.8.1",
6970
"tsup": "^8.5.0",
7071
"tsx": "^4.20.6",

packages/monorepo/src/commands/create.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ import { toWorkspaceGitignorePath } from '../utils'
1313
*/
1414
export const templateMap = {
1515
'tsup': 'packages/tsup-template',
16+
'tsdown': 'packages/tsdown-template',
1617
'unbuild': 'packages/unbuild-template',
1718
'vue-lib': 'packages/vue-lib-template',
1819
'hono-server': 'apps/server',
@@ -38,6 +39,7 @@ export const defaultTemplate: CreateNewProjectType = 'unbuild'
3839
const baseChoices = [
3940
{ name: 'unbuild 打包', value: 'unbuild' },
4041
{ name: 'tsup 打包', value: 'tsup' },
42+
{ name: 'tsdown 打包', value: 'tsdown' },
4143
{ name: 'vue 组件', value: 'vue-lib' },
4244
{ name: 'vue hono 全栈', value: 'vue-hono' },
4345
{ name: 'hono 模板', value: 'hono-server' },

packages/monorepo/test/commands/create.unit.test.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,9 @@ beforeEach(async () => {
5858
describe('createNewProject unit scenarios', () => {
5959
it('getCreateChoices returns defaults when override omitted', async () => {
6060
const { getCreateChoices } = await import('@/commands/create')
61-
expect(getCreateChoices()).toHaveLength(7)
61+
const defaults = getCreateChoices()
62+
expect(defaults).toHaveLength(8)
63+
expect(defaults.some(choice => choice.value === 'tsdown')).toBe(true)
6264
const customChoices = [{ name: 'custom', value: 'custom' }]
6365
expect(getCreateChoices(customChoices)).toBe(customChoices)
6466
})
@@ -68,6 +70,7 @@ describe('createNewProject unit scenarios', () => {
6870
const merged = getTemplateMap({ custom: 'templates/custom-template' })
6971
expect(merged.custom).toBe('templates/custom-template')
7072
expect(merged.unbuild).toBe('packages/unbuild-template')
73+
expect(merged.tsdown).toBe('packages/tsdown-template')
7174
})
7275

7376
it('throws when target directory already exists', async () => {
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
{
2+
"name": "@icebreakers/tsdown-template",
3+
"type": "module",
4+
"version": "0.0.0",
5+
"description": "tsdown bundler template",
6+
"author": "ice breaker <1324318532@qq.com>",
7+
"license": "MIT",
8+
"repository": {
9+
"type": "git",
10+
"url": "git+https://github.com/sonofmagic/monorepo-template.git",
11+
"directory": "packages/tsdown-template"
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": "./dist/index.mjs",
22+
"require": "./dist/index.cjs"
23+
}
24+
},
25+
"main": "./dist/index.cjs",
26+
"module": "./dist/index.mjs",
27+
"types": "./dist/index.d.ts",
28+
"files": [
29+
"dist"
30+
],
31+
"scripts": {
32+
"dev": "tsdown dev",
33+
"build": "tsdown build",
34+
"test": "vitest run",
35+
"test:dev": "vitest",
36+
"release": "pnpm publish",
37+
"lint": "eslint .",
38+
"lint:fix": "eslint . --fix"
39+
},
40+
"publishConfig": {}
41+
}
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
export function greet(name: string) {
2+
return `hello ${name}`
3+
}
4+
5+
export const VERSION = '0.0.0'
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
import { greet, VERSION } from '@/index'
2+
3+
describe('tsdown template', () => {
4+
it('greets with provided name', () => {
5+
expect(greet('world')).toBe('hello world')
6+
})
7+
8+
it('exposes version placeholder', () => {
9+
expect(VERSION).toBe('0.0.0')
10+
})
11+
})
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
{
2+
"extends": "../../tsconfig.json",
3+
"compilerOptions": {
4+
"baseUrl": ".",
5+
"paths": {
6+
"@/*": [
7+
"src/*"
8+
]
9+
}
10+
},
11+
"include": [
12+
"src",
13+
"test"
14+
]
15+
}
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
import { defineConfig } from 'tsdown'
2+
3+
export default defineConfig({
4+
entry: ['./src/index.ts'],
5+
format: ['esm', 'cjs'],
6+
dts: true,
7+
clean: true,
8+
splitting: false,
9+
treeshake: true,
10+
target: 'node18',
11+
})
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
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+
})

0 commit comments

Comments
 (0)