@@ -100,11 +100,24 @@ export async function stageApplication({
100100 : phase === 'dependencies'
101101 ? [ 'express' , 'pdf-lib' , '@firecrawl/pdf-inspector' ]
102102 : [ '@firecrawl/pdf-inspector' , 'pdf-lib' ] ;
103+ if ( ! names . includes ( 'onnxruntime-node' ) ) names . push ( 'onnxruntime-node' ) ;
103104 if ( test && ! names . includes ( 'pdf-lib' ) ) names . push ( 'pdf-lib' ) ;
104105 const fallback = ! hasNativeInspector ( platform , arch ) ;
105106 if ( fallback && ! names . includes ( 'pdfjs-dist' ) ) names . push ( 'pdfjs-dist' ) ;
106107 if ( fallback && ! names . includes ( '@thednp/dommatrix' ) ) names . push ( '@thednp/dommatrix' ) ;
107108 const copied = await copyDependencies ( root , stage , names , fallback ) ;
109+ // Ship only the target CPU runtime; other architectures multiply bundle size.
110+ const onnxBin = join ( stage , 'node_modules/onnxruntime-node/bin/napi-v6' ) ;
111+ const { rm : removeRuntime } = await import ( 'node:fs/promises' ) ;
112+ for ( const target of await readdir ( onnxBin ) ) {
113+ if ( target !== platform )
114+ await removeRuntime ( join ( onnxBin , target ) , { recursive : true , force : true } ) ;
115+ else
116+ for ( const targetArch of await readdir ( join ( onnxBin , target ) ) )
117+ if ( targetArch !== arch )
118+ await removeRuntime ( join ( onnxBin , target , targetArch ) , { recursive : true , force : true } ) ;
119+ }
120+
108121 const browserLicenses = [
109122 '@fluentui/web-components' ,
110123 '@fluentui/tokens' ,
@@ -168,6 +181,7 @@ export async function stageApplication({
168181 mainFields : [ 'module' , 'main' ] ,
169182 external : [
170183 'electron' ,
184+ 'onnxruntime-node' ,
171185 // Keep PDF editing outside the startup bundles so dynamic imports also
172186 // avoid parsing the library when only the Start Page is requested.
173187 'pdf-lib' ,
0 commit comments