We cannot connect to anything using the driver when it's bundled because it will fail with:
Because it appears the compiled driver cannot find the package.json file here: https://github.com/mongodb/node-mongodb-native/blob/4f9d4ceafdcca01d49e6eeb286a9c27ddf485969/src/utils.ts#L953-L955.
For mongosh, we use parcel, for which __dirname is not accessible.
A related problem also happens when we try to use the driver with the VSCode extension, in which we get
because for webpack __dirname is accessible, but you cannot use read file sync and expect the file to be included in the bundle.
Would it be possible to find a solution that doesn't require getting the version using a file read? A straightforward solution would be in a prebuild step, a version.ts file could be generated that would be usable by bundlers like webpack or parcel. An alternative is using