Closed
Description
What happened?
I'm bundling my node.js code with webpack for serverless.
With bundled @octokit/webhooks-methods
, my code doesn't run and throws an error: Exception: ReferenceError: crypto is not defined
.
What did you expect to happen?
Code generated by webpack to run.
What the problem might be
@octokit/webhooks-methods
defines these entries in package.json
:
"main": "dist-node/index.js",
"module": "dist-web/index.js",
"source": "dist-src/index.js",
"types": "dist-types/index.d.ts",
Webpack favours module
(see webpack/webpack#5756 ) because it helps with e.g. better tree shaking, but the module
entry here points to the dist-web/index.js
file which doesn't include crypto
and buffer
imports.
IMO the module
entry should be renamed to browser
.