@@ -422,13 +422,49 @@ export function registerCodegen(ctx: typeof figma) {
422422 ...responsiveComponentsCodes ,
423423 ]
424424
425+ // For INSTANCE nodes, include the referenced component definition(s)
426+ // alongside Usage so developers see both how to use AND the implementation.
427+ const componentDefinitionResults : {
428+ title : string
429+ language : 'TYPESCRIPT' | 'BASH'
430+ code : string
431+ } [ ] = [ ]
432+ if ( node . type === 'INSTANCE' && componentsCodes . length > 0 ) {
433+ const importStatement = generateImportStatements ( componentsCodes )
434+ const combinedCode = componentsCodes
435+ . map ( ( [ , code ] ) => code )
436+ . join ( '\n\n' )
437+ const label =
438+ componentsCodes . length === 1
439+ ? componentsCodes [ 0 ] [ 0 ]
440+ : `${ node . name } - Components`
441+ componentDefinitionResults . push (
442+ {
443+ title : label ,
444+ language : 'TYPESCRIPT' ,
445+ code : importStatement + combinedCode ,
446+ } ,
447+ {
448+ title : `${ label } - CLI (Bash)` ,
449+ language : 'BASH' ,
450+ code : generateBashCLI ( componentsCodes ) ,
451+ } ,
452+ {
453+ title : `${ label } - CLI (PowerShell)` ,
454+ language : 'BASH' ,
455+ code : generatePowerShellCLI ( componentsCodes ) ,
456+ } ,
457+ )
458+ }
459+
425460 // For COMPONENT nodes, show both the single-variant code AND Usage.
426461 // For COMPONENT_SET and INSTANCE, show only Usage.
427462 // For all other types, show the main code.
428463 const showMainCode = ! isComponentType || node . type === 'COMPONENT'
429464
430465 return [
431466 ...usageResults ,
467+ ...componentDefinitionResults ,
432468 ...( showMainCode
433469 ? [
434470 {
0 commit comments