WiseLibs / better-sqlite3

The fastest and simplest library for SQLite3 in Node.js.
MIT License
5.26k stars 391 forks source link

Delete sqlite3 source files after compiling #1094

Closed UnaiUribarri-TomTom closed 9 months ago

UnaiUribarri-TomTom commented 9 months ago

better-sqlite3 is the larger dependency for my otherwise slim Node.js app because it does not delete C source code for sqlite3 after compiling it. Sqlite3 C source codes represent 9.1 MiB out of 11.3 MiB (or 81%) in node_modules/better-sqlite3 folder.

I have made some tests and it seems that everything works even when folder node_modules/better-sqlite3/src is removed.

Why are these sources kept there? Would you accept a PR removing that folder after compiling them?

neoxpert commented 9 months ago

I don't think adding this as a general feature would make sense. The sources may be required depending on a projects build setup, e.g. when updating Node or Electron and a recompilation would be necessary or when custom extensions are added or a custom build options shall be used. In these cases the source code would have to be downloaded again and again if it was removed after each install / build.

If the sources should be removed within your Node.js app, the best option would be to add a postinstall script to your package.json that handles the removal of the unwanted files. If you are shipping your app with all dependencies, you could adjust the packaging step to remove all not required files.