Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Common js error while working in remix js #947

Open
ArnabChatterjee20k opened this issue Oct 5, 2024 · 1 comment
Open

Common js error while working in remix js #947

ArnabChatterjee20k opened this issue Oct 5, 2024 · 1 comment

Comments

@ArnabChatterjee20k
Copy link

SyntaxError: Named export 'HuePicker' not found. The requested module 'react-color' is a CommonJS module, which may not support all module.exports as named exports.
What can be the work around?
I am using

import pkg from 'react-color';
const { HuePicker } = pkg;

but getting error

@tannerhallman
Copy link

I seem to have gotten around this by adding the package to ssr.optimizeDeps section in the vite.config.js

react-router 7.0.2

import path from 'path';

import tsconfigPaths from 'vite-tsconfig-paths';
import { reactRouter } from '@react-router/dev/vite';
import { defineConfig,} from 'vite';

export default defineConfig(({ mode }) => {
  return {
    plugins: [
      reactRouter(),
    ],
    ssr: {
      optimizeDeps: {
        include: [
          'lodash',
          '@mui/icons-material',
          '@mui/material/utils',
          'react-color'
        ],
      },
      noExternal: [
        /^@mui\//,
        'lodash',
        '@mui/icons-material',
        '@mui/material/utils',
        'react-dropzone',
        'react-color',
      ],
    },
  };
});

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants