Open penberg opened 1 year ago
Looking at the docs, it seems that putting a dependency into optionalDependencies
only makes npm install
not fail if the dependency fails to install; it does not provide a way for users to choose whether or not to install the dependency. It also does not provide the package with a way to check whether the dependency is installed (other than using dynamic imports and catching the resulting errors).
What we could do is to provide two packages, Web-only (WebSocket + HTTP) and full (WebSocket + HTTP + better-sqlite3), instead of multiple imports from a single package. However, that would be more awkward to use and to develop.
However, I'm not an expert in the JavaScript ecosystem, so perhaps Jökull Sólberg might have some tips how to accomplish this better? :)
Just chiming in here, perhaps the best cleanest way to handle this scenario is to use optional peerDependencies ? Following this discussions it might work https://github.com/npm/feedback/discussions/225
As an optional peer deps, the package manager should not auto-install them. Which is desired in production environments where web or http will be used. Users who need it locally can add better-sqlite3 to their own package.json dev dependencies.
It would be really helpful to provide web only packaging, because as of now the deployment fails on Cloudflare workers a netlify edge functions.
For now I've forked this repo and deleted local support https://github.com/jansuchomel/libsql-client-ts for using in Cloudflare workers..
Jökull Sólberg asks the following: