Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

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

Copy link
Copy link
Open
@Thinkscape

Description

@Thinkscape
Issue body actions

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/lodash@4.17.21/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/lodash@4.17.21/node_modules/lodash/_root.js
../../node_modules/.pnpm/lodash@4.17.21/node_modules/lodash/_cloneBuffer.js
../../node_modules/.pnpm/lodash@4.17.21/node_modules/lodash/_baseClone.js
../../node_modules/.pnpm/lodash@4.17.21/node_modules/lodash/omit.js
../../node_modules/.pnpm/prisma-extension-nested-operations@1.0.1_@prisma+client@5.5.0/node_modules/prisma-extension-nested-operations/dist/esm/lib/utils/execution.js
../../node_modules/.pnpm/prisma-extension-nested-operations@1.0.1_@prisma+client@5.5.0/node_modules/prisma-extension-nested-operations/dist/esm/lib/nestedOperations.js
../../node_modules/.pnpm/prisma-extension-nested-operations@1.0.1_@prisma+client@5.5.0/node_modules/prisma-extension-nested-operations/dist/esm/index.js
../../node_modules/.pnpm/prisma-extension-soft-delete@1.0.0_@prisma+client@5.5.0/node_modules/prisma-extension-soft-delete/dist/esm/lib/createSoftDeleteExtension.js
../../node_modules/.pnpm/prisma-extension-soft-delete@1.0.0_@prisma+client@5.5.0/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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      Morty Proxy This is a proxified and sanitized view of the page, visit original site.