refinedev / refine

A React Framework for building internal tools, admin panels, dashboards & B2B apps with unmatched flexibility.
https://refine.dev
MIT License
25.92k stars 1.96k forks source link

[BUG] Named export 'mapValues' not found. The requested module 'lodash' is a CommonJS module #6044

Open riyaz-binit-ai opened 2 weeks ago

riyaz-binit-ai commented 2 weeks ago

Describe the bug

I'm using the nextJS frontend environment and trying to connect my Hasura backend with @refinedev/hasura. However, I've been encountering this issue from the start.

Server Error SyntaxError: Named export 'mapValues' not found. The requested module 'lodash' is a CommonJS module, which may not support all module.exports as named exports. CommonJS modules can always be imported via the default export, for example using:

import pkg from 'lodash'; const {id:l},operation:u};let{query:q,variables:o}=E.subscription({operation:u,variables:{id:{value:l,type:"uuid",required:!0},...s.variables},fields:s.fields});return{query:q,variables:o,operation:u}};import Z from"lodash-es/mapKeys.js";import m from"camelcase";var j=n=>{if(n)return Z(n,(s,l)=>m(l))};import{mapValues: ee}from"lodash";var I=n=>{if(n)return ee(n,s=>s.toUpperCase())};import S from"camelcase";import O from"graphql-tag";var se=(n,s)=>{let{idType:l,namingConvention:u="hasura-default"}=s??{},i=u==="hasura-default",q=o=>typeof l=="function"?l(o):l??"uuid";return{getOne:async({resource:o,id:p,meta:e})=>{let r=i?${(e==null?void 0:e.operation)??o}_by_pk:g(${(e==null?void 0:e.operation)??o}_by_pk),t=S(r,{pascalCase:!0}),a=(e==null?void 0:e.gqlQuery)??(e==null?void 0:e.gqlMutation);if(a){let f=a,_={id:p} = pkg;

This error happened while generating the page. Any console logs will be displayed in the terminal window. Call Stack

file:///Users/riyaz/Projects/Binit/portal/node_modules/@refinedev/hasura/dist/index.mjs (21) ### Steps To Reproduce Just create a client with @refinedev/hasura ### Expected behavior -- ### Packages - @refinedev/hasura ### Additional Context _No response_
BatuhanW commented 2 weeks ago

Hey @riyaz-binit-ai can you provide a minimal reproducible example? It's not helping if you don't provide as much as details possible, such as versions of the packages.

riyaz-binit-ai commented 2 weeks ago

Hey @BatuhanW, Thanks for your quick response. I have installed the latest version of @refinedev/hasura (v6.6.4) and created a data provider from it. When I used the data provider in my application, it caused the above issue. However, after downgrading the package to @refinedev/hasura@6.5.1, everything is now working fine without any issues. It seems that the issue is only occurring in the latest version.

BatuhanW commented 1 week ago

Hey @riyaz-binit-ai thanks for the report and details! @aliemir already raised a PR for this one. It will be release in the next release cycle.

riyaz-animeta commented 1 week ago

Great 🙌 @BatuhanW @aliemir