I am using the following npm package
@google-cloud/secret-manager
This is not recommended to be used in a client-side browser environment which I was not intending to do.
Namely I am using this in the following file at a path /src/core/third-party/google/index.ts as follows
import { SecretManagerServiceClient } from '@google-cloud/secret-manager';
const PROJECT_NAME = process.env.GOOGLE_PROJECT_NAME
const getSecret = async (secretName: string): Promise<string> => {
const client = new SecretManagerServiceClient();
const name = `projects/${PROJECT_NAME}/secrets/${secretName}/versions/latest`;
const [version] = await client.accessSecretVersion({ name });
const secretValue = version.payload.data.toString();
return secretValue;
}
When I run the project, I get the following error, suggesting that the package is being used in the browser environment.
Module not found: Error: Can't resolve '**zlib**' in '.../node_modules/request'
BREAKING CHANGE: webpack < 5 used to include polyfills for node.js core modules by default.
The solution is to install the browserify-zlib but my worry is in why does Payload expose this code in the browser. What am I doing wrong?
I tried to use the dependency in both dependencies as well as in devDependencies, same issue (I rebuilt package-lock each time).