react-circular-slider icon indicating copy to clipboard operation
react-circular-slider copied to clipboard

Build Errors with Vite

Open edbella opened this issue 2 years ago • 5 comments

@fabianbru Could you give pointers on the below?

I've tried to use this package a couple of times with Vite but it doesn't work. I believe it has to do with the way the package is compiled that makes it result in a post-build error React.createElement: type is invalid -- expected a string (for built-in components) or a class/function (for composite components) but got: object.

edbella avatar Jan 06 '23 15:01 edbella

I am facing the same error, could you take a look? @fseehawer

GiorgioBertolotti avatar Feb 01 '23 09:02 GiorgioBertolotti

Hi @edbella and @GiorgioBertolotti, you are always welcome to create a PR if you encounter any issues and want to fix it yourself. I haven't run into the issue yet. I will try to reproduce it.

fseehawer avatar Feb 16 '23 14:02 fseehawer

I've run into this issue too -- seems like a common interoperability issue with CJS modules (see here for more, I've had this same problem with other packages which this solution works for as well):

Here's my current workaround (to work with TS):

export function interopDefault(value: any): {
  return value.default;
}

const CircularSlider =
  import.meta.env['MODE'] === 'development' ? CircularSliderDev : interopDefault(CircularSliderDev);

nicvickeryw avatar Jun 02 '23 02:06 nicvickeryw

On my side the problem seems now to be fixed, even without using @nicvickeryw's workaround 🙏🏼

GiorgioBertolotti avatar Jun 08 '23 13:06 GiorgioBertolotti

I'm facing almost the same issue getting Element type is invalid: expected a string (for built-in components) or a class/function (for composite components) but got: [missing argument].[missing argument] after build in vite ts react. But no issue when developing.

ParhamMoAsghari avatar Jan 28 '24 08:01 ParhamMoAsghari