Open
Description
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
- Cannot use lodash on Netlify Edge Runtime (in NextJS middleware) #5525
- lodash eval/new Function() usage causing Next.js Middleware to fail #5394
Incompatible code:
- Uses of
Function(String)
: https://github.com/search?q=repo:lodash/lodash+Function('&type=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
Labels
No labels