Skip to content

Commit d488efd

Browse files
authored
chore: use tsdown (vitejs#20065)
1 parent 1bde4d2 commit d488efd

File tree

9 files changed

+244
-1102
lines changed

9 files changed

+244
-1102
lines changed

packages/create-vite/index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
#!/usr/bin/env node
22

3-
import './dist/index.mjs'
3+
import './dist/index.js'

packages/create-vite/package.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,8 @@
1414
"dist"
1515
],
1616
"scripts": {
17-
"dev": "unbuild --stub",
18-
"build": "unbuild",
17+
"dev": "tsdown --watch",
18+
"build": "tsdown",
1919
"typecheck": "tsc --noEmit",
2020
"prepublishOnly": "npm run build"
2121
},
@@ -37,6 +37,6 @@
3737
"cross-spawn": "^7.0.6",
3838
"mri": "^1.2.0",
3939
"picocolors": "^1.1.1",
40-
"unbuild": "^3.5.0"
40+
"tsdown": "^0.11.12"
4141
}
4242
}

packages/create-vite/tsconfig.json

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,17 @@
11
{
2-
"include": ["build.config.ts", "src", "__tests__"],
2+
"include": ["tsdown.config.ts", "src", "__tests__"],
33
"compilerOptions": {
44
"outDir": "dist",
55
"target": "ES2023",
66
"module": "Preserve",
77
"moduleResolution": "bundler",
8+
"allowImportingTsExtensions": true,
89
"strict": true,
910
"skipLibCheck": true,
1011
"declaration": false,
1112
"sourceMap": false,
1213
"noUnusedLocals": true,
13-
"esModuleInterop": true
14+
"esModuleInterop": true,
15+
"noEmit": true
1416
}
1517
}

packages/create-vite/build.config.ts renamed to packages/create-vite/tsdown.config.ts

Lines changed: 19 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -1,38 +1,27 @@
11
import path from 'node:path'
22
import url from 'node:url'
3-
import { defineBuildConfig } from 'unbuild'
4-
import licensePlugin from '../vite/rollupLicensePlugin'
3+
import { defineConfig } from 'tsdown'
4+
import licensePlugin from '../vite/rollupLicensePlugin.ts'
55

66
const __dirname = path.dirname(url.fileURLToPath(import.meta.url))
77

8-
export default defineBuildConfig({
9-
entries: ['src/index'],
10-
clean: true,
11-
rollup: {
12-
inlineDependencies: true,
13-
esbuild: {
14-
target: 'node20',
15-
minify: true,
16-
},
17-
},
18-
hooks: {
19-
'rollup:options'(_ctx, options) {
20-
options.plugins = [
21-
options.plugins,
22-
licensePlugin(
23-
path.resolve(__dirname, './LICENSE'),
24-
'create-vite license',
25-
'create-vite',
26-
'# License of the files in the directories starting with "template-" in create-vite\n' +
27-
'The files in the directories starting with "template-" in create-vite and files\n' +
28-
'generated from those files are licensed under the CC0 1.0 Universal license:\n\n' +
29-
cc0LicenseText +
30-
'\n\n',
31-
),
32-
]
33-
},
34-
},
35-
})
8+
export default defineConfig(() => ({
9+
entry: ['src/index.ts'],
10+
target: 'node20',
11+
minify: true,
12+
plugins: [
13+
licensePlugin(
14+
path.resolve(__dirname, './LICENSE'),
15+
'create-vite license',
16+
'create-vite',
17+
'# License of the files in the directories starting with "template-" in create-vite\n' +
18+
'The files in the directories starting with "template-" in create-vite and files\n' +
19+
'generated from those files are licensed under the CC0 1.0 Universal license:\n\n' +
20+
cc0LicenseText +
21+
'\n\n',
22+
),
23+
],
24+
}))
3625

3726
const cc0LicenseText = `
3827
CC0 1.0 Universal

packages/plugin-legacy/build.config.ts

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

packages/plugin-legacy/package.json

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,17 +14,17 @@
1414
"@vitejs/plugin-legacy"
1515
],
1616
"main": "./dist/index.cjs",
17-
"module": "./dist/index.mjs",
17+
"module": "./dist/index.js",
1818
"types": "./dist/index.d.ts",
1919
"exports": {
2020
".": {
21-
"import": "./dist/index.mjs",
21+
"import": "./dist/index.js",
2222
"require": "./dist/index.cjs"
2323
}
2424
},
2525
"scripts": {
26-
"dev": "unbuild --stub",
27-
"build": "unbuild && pnpm run patch-cjs",
26+
"dev": "tsdown --watch",
27+
"build": "tsdown && pnpm run patch-cjs",
2828
"patch-cjs": "tsx ../../scripts/patchCJS.ts",
2929
"prepublishOnly": "npm run build"
3030
},
@@ -58,7 +58,7 @@
5858
"devDependencies": {
5959
"acorn": "^8.14.1",
6060
"picocolors": "^1.1.1",
61-
"unbuild": "3.4.2",
61+
"tsdown": "^0.11.12",
6262
"vite": "workspace:*"
6363
}
6464
}

packages/plugin-legacy/tsconfig.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
2-
"include": ["build.config.ts", "src"],
2+
"include": ["tsdown.config.ts", "src"],
33
"exclude": ["**/*.spec.ts"],
44
"compilerOptions": {
55
"outDir": "dist",
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
import { defineConfig } from 'tsdown'
2+
3+
export default defineConfig({
4+
entry: ['src/index.ts'],
5+
format: ['esm', 'cjs'],
6+
target: 'node20',
7+
tsconfig: false, // disable tsconfig `paths` when bundling
8+
outputOptions(opts, format) {
9+
if (format === 'cjs') {
10+
opts.exports = 'named'
11+
}
12+
return opts
13+
},
14+
})

0 commit comments

Comments
 (0)