Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Lodash fails to run in edge environments (Vercel edge, CloudFlare workers) #5862

Open
Thinkscape opened this issue May 7, 2024 · 0 comments

Comments

@Thinkscape
Copy link

Thinkscape commented May 7, 2024

Description

Lodash uses Function(String) which is unsupported in the v8 Edge runtimes like Cloudflare Workers. This is being picked up by transpilers, like the one in Next.js which prevents projects being built and deployed on platforms like Vercel.

Example error messages in Next.js projects

3:30:14 PM: Failed to compile.
3:30:14 PM: 
3:30:14 PM: ./node_modules/lodash/_root.js
3:30:14 PM: Dynamic Code Evaluation (e. g. 'eval', 'new Function', 'WebAssembly.compile') not allowed in Edge Runtime
3:30:14 PM: Import trace for requested module:
3:30:14 PM: ./node_modules/lodash/isBuffer.js
3:30:14 PM: ./node_modules/lodash/_arrayLikeKeys.js
3:30:14 PM: ./node_modules/lodash/keysIn.js
3:30:14 PM: ./node_modules/lodash/_getAllKeysIn.js
3:30:14 PM: ./node_modules/lodash/pickBy.js
3:30:14 PM: ./src/utils/utils.js
3:30:14 PM: ./src/middleware.js
Failed to compile.

../../node_modules/.pnpm/[email protected]/node_modules/lodash/_root.js
Dynamic Code Evaluation (e. g. 'eval', 'new Function', 'WebAssembly.compile') not allowed in Edge Runtime 
Learn More: https://nextjs.org/docs/messages/edge-dynamic-code-evaluation

Import trace for requested module:
../../node_modules/.pnpm/[email protected]/node_modules/lodash/_root.js
../../node_modules/.pnpm/[email protected]/node_modules/lodash/_cloneBuffer.js
../../node_modules/.pnpm/[email protected]/node_modules/lodash/_baseClone.js
../../node_modules/.pnpm/[email protected]/node_modules/lodash/omit.js
../../node_modules/.pnpm/[email protected]_@[email protected]/node_modules/prisma-extension-nested-operations/dist/esm/lib/utils/execution.js
../../node_modules/.pnpm/[email protected]_@[email protected]/node_modules/prisma-extension-nested-operations/dist/esm/lib/nestedOperations.js
../../node_modules/.pnpm/[email protected]_@[email protected]/node_modules/prisma-extension-nested-operations/dist/esm/index.js
../../node_modules/.pnpm/[email protected]_@[email protected]/node_modules/prisma-extension-soft-delete/dist/esm/lib/createSoftDeleteExtension.js
../../node_modules/.pnpm/[email protected]_@[email protected]/node_modules/prisma-extension-soft-delete/dist/esm/index.js
./lib/prisma.ts
./lib/auth.ts

Prior reports

Incompatible code:

Workaround

I'm patching the offending code out in my next.js projects with this: https://gist.github.com/Thinkscape/ca9a7e47e3b44a5cc92d8e552f455eb6

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

1 participant