Open simonkberg opened 1 year ago
Can i Work on this?
when i use this:
import _ from 'lodash'; _.chain(data) .filter((e) => e.type === "foo") .uniqBy((e) => e.id) .reverse() .value()
then it is not giving the error and running perfectly
Or if we import chain without curly braces it also works:
import chain from 'lodash'
I have this same problem when using import { chain } from "lodash"
. Same if I do import chain from "lodash/chain"
:
TypeError: lodash_chain__WEBPACK_IMPORTED_MODULE_11___default(...)(...).reduce is not a function
I migrated from Next 11 -> 14, and removed babel.config.js
in the process, which was this:
module.exports = {
presets: ["next/babel"],
plugins: [],
}
If restore babel.config.js
, I don't have this problem. If I import _ from "lodash"
and use _.chain
, I don't have this problem.
I just upgraded next js to the latest version 14.2.3 and the error is still occurring, are there any other workarounds to this?
Verify canary release
Provide environment information
Which area(s) of Next.js are affected? (leave empty if unsure)
No response
Link to the code that reproduces this issue or a replay of the bug
https://codesandbox.io/p/sandbox/green-wind-524j6n?file=%2Fpages%2Findex.tsx
To Reproduce
See codesandbox, running
yarn dev
with the simple example usinglodash/chain
will fail at runtime. The same code runs fine in v13.4.7There's also currently no way to override the configuration in userland: https://github.com/vercel/next.js/blob/4f75c7993815dac50a6db3e078c51e6ae8d5bbdc/packages/next/src/server/config.ts#L692
Describe the Bug
The compiled code fails with the error:
Expected Behavior
The code should work (like in v13.4.7). I also think you should be able to override the default
modularizeImports
configuration in the user configuration, as new versions of libraries could also break this configuration, which would require a new Next.js release to fix.Which browser are you using? (if relevant)
N/A
How are you deploying your application? (if relevant)
N/A
NEXT-1401