@@ -110,6 +110,43 @@ async function main() {
110110 console . warn ( `[${ name } ] sqlite source not found at: ${ sqliteSource } ` )
111111 }
112112
113+ // Copy bindings package (required by sqlite3)
114+ // Find bindings package dynamically to avoid hardcoding version
115+ let bindingsSource = null
116+ try {
117+ const require = createRequire ( import . meta. url )
118+ const bindingsModulePath = require . resolve ( "bindings/package.json" )
119+ bindingsSource = path . dirname ( bindingsModulePath )
120+ } catch ( err ) {
121+ // Fallback: try to find it in pnpm structure by searching for bindings directories
122+ const pnpmDir = path . join ( srcDir , "../node_modules/.pnpm" )
123+ if ( fs . existsSync ( pnpmDir ) ) {
124+ const entries = fs . readdirSync ( pnpmDir )
125+ for ( const entry of entries ) {
126+ if ( entry . startsWith ( "bindings@" ) ) {
127+ const bindingsPath = path . join ( pnpmDir , entry , "node_modules/bindings" )
128+ if ( fs . existsSync ( bindingsPath ) ) {
129+ bindingsSource = bindingsPath
130+ break
131+ }
132+ }
133+ }
134+ }
135+ }
136+
137+ const bindingsDest = path . join ( distDir , "node_modules/bindings" )
138+
139+ if ( bindingsSource && fs . existsSync ( bindingsSource ) ) {
140+ try {
141+ fs . cpSync ( bindingsSource , bindingsDest , { recursive : true } )
142+ console . log ( `[${ name } ] Copied bindings package to dist/node_modules/bindings` )
143+ } catch ( err ) {
144+ console . error ( `[${ name } ] Failed to copy bindings package:` , err )
145+ }
146+ } else {
147+ console . warn ( `[${ name } ] bindings source not found` )
148+ }
149+
113150 // Copy JSDOM xhr-sync-worker.js to fix runtime resolution
114151 const jsdomWorkerDest = path . join ( distDir , "xhr-sync-worker.js" )
115152
0 commit comments