@@ -3,6 +3,7 @@ import { join, parse, resolve } from 'node:path';
33import { fileURLToPath } from 'node:url' ;
44
55import { build , type BuildOptions } from 'rolldown' ;
6+ import { dts } from 'rolldown-plugin-dts' ;
67import { glob } from 'tinyglobby' ;
78
89import { RewriteImportsPlugin } from './build-support/rewrite-imports' ;
@@ -46,7 +47,8 @@ async function buildVite() {
4647 external === 'tinyglobby' ||
4748 external === 'fdir' ||
4849 external === 'rolldown' ) ) ||
49- ( external instanceof RegExp && external . test ( 'rolldown/' ) )
50+ external === 'yaml' ||
51+ ( external instanceof RegExp && ( external . test ( 'rolldown/' ) || external . test ( 'vite/' ) ) )
5052 ) ;
5153 } ) ;
5254 }
@@ -71,6 +73,8 @@ async function buildVite() {
7173
7274 if ( Array . isArray ( config . plugins ) ) {
7375 config . plugins = [
76+ // Add RewriteImportsPlugin to handle vite/rolldown import rewrites
77+ RewriteImportsPlugin ,
7478 {
7579 name : 'rewrite-static-paths' ,
7680 transform ( _ , id , meta ) {
@@ -112,8 +116,6 @@ async function buildVite() {
112116 }
113117 } ,
114118 } ,
115- // Add RewriteImportsPlugin to handle vite/rolldown import rewrites
116- RewriteImportsPlugin ,
117119 ...config . plugins . filter ( ( plugin ) => {
118120 return ! (
119121 typeof plugin === 'object' &&
@@ -243,7 +245,10 @@ async function bundleTsdown() {
243245
244246 // Re-build tsdown cli
245247 await build ( {
246- input : join ( tsdownSourceDir , 'dist/run.mjs' ) ,
248+ input : {
249+ run : join ( tsdownSourceDir , 'dist/run.mjs' ) ,
250+ index : join ( tsdownSourceDir , 'dist/index.mjs' ) ,
251+ } ,
247252 output : {
248253 format : 'esm' ,
249254 cleanDir : true ,
@@ -253,6 +258,23 @@ async function bundleTsdown() {
253258 external : ( id : string ) => tsdownExternal . some ( ( e ) => id . startsWith ( e ) ) ,
254259 plugins : [ RewriteImportsPlugin ] ,
255260 } ) ;
261+
262+ await build ( {
263+ input : {
264+ 'index-types' : join ( tsdownSourceDir , 'dist/index.d.mts' ) ,
265+ } ,
266+ output : {
267+ format : 'esm' ,
268+ dir : join ( projectDir , 'dist/tsdown' ) ,
269+ } ,
270+ plugins : [
271+ RewriteImportsPlugin ,
272+ dts ( {
273+ oxc : true ,
274+ dtsInput : true ,
275+ } ) ,
276+ ] ,
277+ } ) ;
256278}
257279
258280// Actually do nothing now, we will polish it in the future when `vitepress` is ready
0 commit comments