Skip to content

Commit 1848fa9

Browse files
authored
build: use tsdown + isolated declarations (#1095)
1 parent 0826403 commit 1848fa9

26 files changed

+1098
-794
lines changed

.devcontainer/devcontainer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
]
1515
}
1616
},
17-
"postStartCommand": "corepack enable && pnpm install && pnpm build --stub",
17+
"postStartCommand": "corepack enable && pnpm install",
1818
"mounts": [
1919
"type=volume,target=${containerWorkspaceFolder}/node_modules",
2020
"type=volume,target=${containerWorkspaceFolder}/dist"

README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,14 +12,14 @@ All commands are listed on https://nuxt.com/docs/api/commands.
1212
# Install dependencies
1313
pnpm i
1414

15-
# Generate type stubs
16-
pnpm dev:prepare
15+
# Build project and start watcher
16+
pnpm dev
1717

1818
# Go to the playground directory
1919
cd playground
2020

2121
# And run any commands
22-
pnpm nuxi <command>
22+
pnpm nuxt <command>
2323
```
2424

2525
## License

package.json

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,15 +7,14 @@
77
"license": "MIT",
88
"repository": "nuxt/cli",
99
"scripts": {
10-
"dev:prepare": "pnpm -r dev:prepare",
1110
"build": "pnpm -r build",
12-
"build:stub": "pnpm -r dev:prepare",
11+
"dev": "pnpm -r build --watch",
1312
"lint": "eslint .",
1413
"lint:fix": "eslint --fix .",
1514
"nuxi": "node ./packages/nuxi/bin/nuxi.mjs",
1615
"nuxt": "node ./packages/nuxt-cli/bin/nuxi.mjs",
17-
"nuxi-bun": "bun --bun ./packages/nuxi/bin/nuxi.mjs",
18-
"prepack": "pnpm -r build",
16+
"nuxi-bun": "bun --bun ./packages/nuxt-cli/bin/nuxi.mjs",
17+
"postinstall": "pnpm build",
1918
"test:types": "tsc --noEmit",
2019
"test:knip": "knip",
2120
"test:dist": "pnpm -r test:dist",

packages/create-nuxt/build.config.ts

Lines changed: 0 additions & 42 deletions
This file was deleted.

packages/create-nuxt/package.json

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,9 +25,8 @@
2525
"node": "^16.10.0 || >=18.0.0"
2626
},
2727
"scripts": {
28-
"dev:prepare": "unbuild --stub",
29-
"build": "unbuild",
30-
"prepack": "unbuild"
28+
"build": "tsdown",
29+
"prepack": "tsdown"
3130
},
3231
"dependencies": {
3332
"citty": "^0.1.6"
@@ -36,8 +35,8 @@
3635
"@types/node": "^22.18.12",
3736
"rollup": "^4.52.5",
3837
"rollup-plugin-visualizer": "^6.0.5",
38+
"tsdown": "^0.15.9",
3939
"typescript": "^5.9.3",
40-
"unbuild": "^3.6.1",
4140
"unplugin-purge-polyfills": "^0.1.0"
4241
}
4342
}

packages/create-nuxt/src/main.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import type { CommandDef } from 'citty'
12
import { defineCommand } from 'citty'
23
import { provider } from 'std-env'
34

@@ -7,7 +8,7 @@ import { checkEngines } from '../../nuxi/src/utils/engines'
78
import { logger } from '../../nuxi/src/utils/logger'
89
import { description, name, version } from '../package.json'
910

10-
export const main = defineCommand({
11+
const _main = defineCommand({
1112
meta: {
1213
name,
1314
version,
@@ -25,3 +26,5 @@ export const main = defineCommand({
2526
await init.run?.(ctx)
2627
},
2728
})
29+
30+
export const main = _main as CommandDef<any>

packages/create-nuxt/src/run.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,13 +19,13 @@ globalThis.__nuxt_cli__ = globalThis.__nuxt_cli__ || {
1919
),
2020
}
2121

22-
export const runMain = () => _runMain(main)
22+
export const runMain = (): Promise<void> => _runMain(main)
2323

2424
export async function runCommand(
2525
name: 'init',
2626
argv: string[] = process.argv.slice(2),
2727
data: { overrides?: Record<string, any> } = {},
28-
) {
28+
): Promise<{ result: unknown }> {
2929
return await _runCommand(init, {
3030
rawArgs: argv,
3131
data: {
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
import type { UserConfig } from 'tsdown'
2+
import process from 'node:process'
3+
import { visualizer } from 'rollup-plugin-visualizer'
4+
import { defineConfig } from 'tsdown'
5+
import { purgePolyfills } from 'unplugin-purge-polyfills'
6+
7+
const isAnalysingSize = process.env.BUNDLE_SIZE === 'true'
8+
9+
export default defineConfig({
10+
entry: ['src/index.ts'],
11+
fixedExtension: true,
12+
dts: !isAnalysingSize && {
13+
oxc: true,
14+
},
15+
failOnWarn: !isAnalysingSize,
16+
plugins: [
17+
purgePolyfills.rolldown({ logLevel: 'verbose' }),
18+
...(isAnalysingSize ? [visualizer({ template: 'raw-data' })] : []),
19+
],
20+
}) satisfies UserConfig as UserConfig

packages/nuxi/build.config.ts

Lines changed: 0 additions & 45 deletions
This file was deleted.

packages/nuxi/package.json

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -28,15 +28,8 @@
2828
"node": "^16.10.0 || >=18.0.0"
2929
},
3030
"scripts": {
31-
"dev:prepare": "unbuild --stub",
32-
"build": "unbuild",
33-
"build:stub": "unbuild --stub",
34-
"dev": "node ./bin/nuxi.mjs dev ./playground",
35-
"dev:bun": "bun --bun ./bin/nuxi.mjs dev ./playground",
36-
"nuxi": "node ./bin/nuxi.mjs",
37-
"nuxi-bun": "bun --bun ./bin/nuxi.mjs",
38-
"prepack": "unbuild",
39-
"test:dist": "node ./bin/nuxi.mjs info ./playground"
31+
"build": "tsdown",
32+
"prepack": "tsdown"
4033
},
4134
"devDependencies": {
4235
"@nuxt/kit": "^4.1.3",
@@ -72,9 +65,9 @@
7265
"srvx": "^0.8.16",
7366
"std-env": "^3.10.0",
7467
"tinyexec": "^1.0.1",
68+
"tsdown": "^0.15.9",
7569
"typescript": "^5.9.3",
7670
"ufo": "^1.6.1",
77-
"unbuild": "^3.6.1",
7871
"undici": "^7.16.0",
7972
"unplugin-purge-polyfills": "^0.1.0",
8073
"vitest": "^3.2.4",

0 commit comments

Comments
 (0)