@@ -36,6 +36,12 @@ const PROPERTY_RENAMES: Record<string, string> = {
3636 cjsInterop : 'cjsDefault' ,
3737}
3838
39+ // Properties to move under `deps` namespace: oldName -> newNameUnderDeps
40+ const DEPS_NAMESPACE_RENAMES : Record < string , string > = {
41+ external : 'neverBundle' ,
42+ noExternal : 'alwaysBundle' ,
43+ }
44+
3945/**
4046 * Transform tsup config code to tsdown config code.
4147 * This function applies all migration rules and returns the transformed code
@@ -194,7 +200,20 @@ export function transformTsupConfig(
194200 edits . push ( node . replace ( "nodeProtocol: 'strip'" ) )
195201 }
196202
197- // 7. Transform tsup/TSUP identifiers
203+ // 7. Move properties into deps namespace
204+ const depsProperties : { name : string ; value : string } [ ] = [ ]
205+ for ( const [ oldName , newName ] of Object . entries ( DEPS_NAMESPACE_RENAMES ) ) {
206+ const pair = findPropertyPair ( oldName )
207+ if ( pair ) {
208+ const valueNode = pair . field ( 'value' )
209+ if ( valueNode ) {
210+ depsProperties . push ( { name : newName , value : valueNode . text ( ) } )
211+ }
212+ edits . push ( pair . replace ( '' ) )
213+ }
214+ }
215+
216+ // 8. Transform tsup/TSUP identifiers
198217 const tsupIdentifiers = root . findAll ( {
199218 rule : {
200219 kind : 'identifier' ,
@@ -287,6 +306,13 @@ export function transformTsupConfig(
287306
288307 const missingDefaults : string [ ] = [ ]
289308 if ( configObjectNode ) {
309+ if ( depsProperties . length > 0 ) {
310+ const depsEntries = depsProperties
311+ . map ( ( p ) => `${ p . name } : ${ p . value } ` )
312+ . join ( ',\n ' )
313+ missingDefaults . push ( `deps: {\n ${ depsEntries } ,\n }` )
314+ }
315+
290316 if ( ! hasOption ( 'format' ) ) missingDefaults . push ( "format: 'cjs'" )
291317 if ( ! hasOption ( 'clean' ) ) missingDefaults . push ( 'clean: false' )
292318 if ( ! hasOption ( 'dts' ) ) missingDefaults . push ( 'dts: false' )
0 commit comments