diff --git a/package.json b/package.json index a0ebf0c..cc30e39 100644 --- a/package.json +++ b/package.json @@ -6,7 +6,7 @@ "type": "module", "scripts": { "dev": "tsx src/index.ts", - "build": "esbuild src/index.ts --bundle --platform=node --outfile=dist/oauth.cjs --minify && chmod +x dist/oauth.cjs", + "build": "esbuild src/index.ts --bundle --platform=node --outfile=dist/oauth.cjs '--external:*.pem' --minify && chmod +x dist/oauth.cjs", "prettify": "prettier --write ." }, "dependencies": { diff --git a/src/index.ts b/src/index.ts index 7f5c4f6..1d5e3ce 100644 --- a/src/index.ts +++ b/src/index.ts @@ -9,11 +9,11 @@ import { readFile } from 'node:fs/promises' import { fileURLToPath } from 'node:url' const loadCerts = async (): Promise => { - const isCjs = !!global.require + const isCjs = !import.meta.resolve if (isCjs) { return { - cert: await readFile(global.require.resolve('./cert.pem')), - key: await readFile(global.require.resolve('./key.pem')), + cert: await readFile(require.resolve('./cert.pem')), + key: await readFile(require.resolve('./key.pem')), } } else { return {