@@ -80,8 +80,15 @@ function copyNativeDependency(
8080 dependency : string ,
8181 destinationRoot : string ,
8282) : void {
83- const source = path . resolve ( "node_modules" , dependency ) ;
83+ const source = path . resolve ( "../../ node_modules" , dependency ) ;
8484 if ( ! existsSync ( source ) ) {
85+ // Fallback to local node_modules
86+ const localSource = path . resolve ( "node_modules" , dependency ) ;
87+ if ( existsSync ( localSource ) ) {
88+ copySync ( dependency , destinationRoot , localSource ) ;
89+ return ;
90+ }
91+
8592 console . warn (
8693 `[forge] Native dependency "${ dependency } " not found, skipping copy` ,
8794 ) ;
@@ -102,6 +109,21 @@ function copyNativeDependency(
102109 ) ;
103110}
104111
112+ function copySync ( dependency : string , destinationRoot : string , source : string ) {
113+ const nodeModulesDir = path . join ( destinationRoot , "node_modules" ) ;
114+ mkdirSync ( nodeModulesDir , { recursive : true } ) ;
115+
116+ const destination = path . join ( nodeModulesDir , dependency ) ;
117+ rmSync ( destination , { recursive : true , force : true } ) ;
118+ cpSync ( source , destination , { recursive : true , dereference : true } ) ;
119+ console . log (
120+ `[forge] Copied native dependency "${ dependency } " into ${ path . relative (
121+ process . cwd ( ) ,
122+ destination ,
123+ ) } `,
124+ ) ;
125+ }
126+
105127const config : ForgeConfig = {
106128 packagerConfig : {
107129 asar : {
0 commit comments