[keyserver] Add conditional handling for import.meta in tests and update Babel configuration
Summary:
The file index.js was modified to conditionally handle the require function, based on whether the code is running in a testing environment or not. This is because Jest, our testing framework, does not fully support ES modules or import.meta as of our current setup. Therefore, for the testing environment, we fall back to the traditional Node.js require function to load our modules.
In the non-testing environment, we rely on import.meta.url and dynamic imports using the createRequire function. This approach is more flexible and aligns with the future-proof ES module standard.
In addition, I've updated the babel.config.cjs file to include the babel-plugin-transform-import-meta plugin. This plugin replaces the import.meta object with { url: __filename } only in the Jest testing environment. The Babel configuration allows Jest to understand import.meta.url in our code by transpiling it to something Jest knows (__filename).
Test Plan: No Jest errors in the following diff, the rust-node-addon APIs work as expected
Reviewers: ashoat
Reviewed By: ashoat
Subscribers: tomek
Differential Revision: https://phab.comm.dev/D8406