Which Cloudflare product(s) does this pertain to?
Wrangler
What version(s) of the tool(s) are you using?
3.23.0
What version of Node are you using?
21.5.0
What operating system are you using?
Mac
Describe the Bug
Using node_compat, 3rd party dependencies that use crypto’s randomInt fails to compile.
Note that randomInt was added in Node.js v14.10.0, v12.19.0. However, rollup-plugin-node-polyfills has not been updated in 5 years.
This prevented me from deploying an Elysia.js app to Cloudflare Workers.
Minimal repro:
import { Elysia } from 'elysia';
export interface Env {}
const app = new Elysia({ aot: false }).get('/', () => 'Hello Elysia');
export default {
async fetch(request: Request, env: Env, ctx: ExecutionContext): Promise<Response> {
return app.fetch(request);
},
};
Expected: wrangler dev works fine.
Please provide a link to a minimal reproduction
No response
Please provide any relevant error logs
> wrangler dev
⛅️ wrangler 3.23.0
-------------------
▲ [WARNING] Enabling Node.js compatibility mode for built-ins and globals. This is experimental and has serious tradeoffs. Please see https://github.com/ionic-team/rollup-plugin-node-polyfills/ for more details.
✘ [ERROR] No matching export in "node-modules-polyfills:crypto" for import "randomInt"
node_modules/.pnpm/elysia@0.8.9_@sinclair+typebox@0.32.12_typescript@5.3.3/node_modules/elysia/dist/ws/index.js:1:50:
1 │ ... as t}from"../error";import{randomInt as r}from"crypto";export c...
╵ ~~~~~~~~~
╭──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╮
│ [b] open a browser, [d] open Devtools, [l] turn off local mode, [c] clear console, [x] to exit │
╰──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯
✘ [ERROR] Failed to build
If you think this is a bug then please create an issue at https://github.com/cloudflare/workers-sdk/issues/new/choose
Relevant issue on Elysia.js side
Current workaround is to downgrade Elysia to 0.8.8.
Which Cloudflare product(s) does this pertain to?
Wrangler
What version(s) of the tool(s) are you using?
3.23.0
What version of Node are you using?
21.5.0
What operating system are you using?
Mac
Describe the Bug
Using
node_compat, 3rd party dependencies that usecrypto’srandomIntfails to compile.Note that
randomIntwas added in Node.js v14.10.0, v12.19.0. However, rollup-plugin-node-polyfills has not been updated in 5 years.This prevented me from deploying an Elysia.js app to Cloudflare Workers.
Minimal repro:
Expected:
wrangler devworks fine.Please provide a link to a minimal reproduction
No response
Please provide any relevant error logs
Relevant issue on Elysia.js side
Current workaround is to downgrade Elysia to 0.8.8.