@@ -69,20 +69,49 @@ export class SolcIntegration {
6969 * Find solc executable in system
7070 */
7171 private findSolc ( ) : string {
72+ // First, try to find bundled solcjs in node_modules (for extension packaging)
73+ const bundledSolcPaths = [
74+ path . join ( __dirname , '../../node_modules/.bin/solcjs' ) ,
75+ path . join ( __dirname , '../../../node_modules/.bin/solcjs' ) ,
76+ path . join ( process . cwd ( ) , 'node_modules/.bin/solcjs' ) ,
77+ ] ;
78+
79+ for ( const p of bundledSolcPaths ) {
80+ try {
81+ if ( fs . existsSync ( p ) ) {
82+ execSync ( `${ p } --version` , { stdio : 'ignore' } ) ;
83+ return p ;
84+ }
85+ } catch ( error ) {
86+ continue ;
87+ }
88+ }
89+
90+ try {
91+ // Try to find solcjs in PATH
92+ const result = execSync ( 'which solcjs' , { encoding : 'utf-8' } ) . trim ( ) ;
93+ if ( result ) {
94+ return result ;
95+ }
96+ } catch ( error ) {
97+ // Not found in PATH
98+ }
99+
72100 try {
73- // Try to find solc in PATH
101+ // Try to find native solc in PATH
74102 const result = execSync ( 'which solc' , { encoding : 'utf-8' } ) . trim ( ) ;
75103 if ( result ) {
76104 return result ;
77105 }
78106 } catch ( error ) {
79- // Not found in PATH - solc not available
107+ // Not found in PATH
80108 }
81109
82- // Common installation paths
110+ // Common installation paths for native solc
83111 const commonPaths = [
84112 '/usr/local/bin/solc' ,
85113 '/usr/bin/solc' ,
114+ 'solcjs' , // Global install
86115 'solc' , // Will work if in PATH
87116 ] ;
88117
@@ -91,12 +120,11 @@ export class SolcIntegration {
91120 execSync ( `${ p } --version` , { stdio : 'ignore' } ) ;
92121 return p ;
93122 } catch ( error ) {
94- // This path doesn't work, try next
95123 continue ;
96124 }
97125 }
98126
99- return 'solc ' ; // Default, will fail if not available
127+ return 'solcjs ' ; // Default to solcjs , will fail if not available
100128 }
101129
102130 /**
0 commit comments