-
Notifications
You must be signed in to change notification settings - Fork 7.1k
Closed
Labels
issue bankruptcyClosing the issue/PR to start freshClosing the issue/PR to start fresh
Description
Next.js middleware runs on a strict runtime, which does not allow eval or new Function(evalString):
The following JavaScript language features are disabled, and will not work:
eval: Evaluates JavaScript code represented as a string
new Function(evalString): Creates a new function with the code provided as an argument
Can Lodash still run in this environment? For example trim imports _root.js which uses this type of logic for a global object reference:
/** Used as a reference to the global object. */
var root = freeGlobal || freeSelf || Function('return this')();This results in the following Next.js error during build:
Failed to compile.
../../../node_modules/lodash/_root.js
Dynamic Code Evaluation (e. g. 'eval', 'new Function') not allowed in Middleware pages/_middleware
Import trace for requested module:
../../../node_modules/lodash/_Symbol.js
../../../node_modules/lodash/_baseToString.js
../../../node_modules/lodash/trim.js
./src/pages/_middleware.tsx
In regards to issue #3328, it seems like this behavior is avoidable. Is this still the case?
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
issue bankruptcyClosing the issue/PR to start freshClosing the issue/PR to start fresh