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

Can not import RadixUI components? #101

Closed
nemanjam opened this issue Nov 20, 2023 · 1 comment
Closed

Can not import RadixUI components? #101

nemanjam opened this issue Nov 20, 2023 · 1 comment

Comments

@nemanjam
Copy link

nemanjam commented Nov 20, 2023

With this import:

import * as Slider from '@radix-ui/react-slider';

I get this:

ERROR in ./node_modules/@radix-ui/react-slot/dist/index.mjs 12:26-41
Can't import the named export 'Children' from non EcmaScript module (only default export is available)

ERROR in ./node_modules/@radix-ui/react-slot/dist/index.mjs 21:20-35
Can't import the named export 'Children' from non EcmaScript module (only default export is available)

ERROR in ./node_modules/@radix-ui/react-slot/dist/index.mjs 21:66-81
Can't import the named export 'Children' from non EcmaScript module (only default export is available)

ERROR in ./node_modules/@radix-ui/react-slot/dist/index.mjs 42:11-26
Can't import the named export 'Children' from non EcmaScript module (only default export is available)

...

In webpack.config.js I have tried this, but no success:

  module: {
       // ...
      {
        test: /\.(mjs)|(js|ts)x?$/,
@nemanjam
Copy link
Author

I found the solution.

radix-ui/primitives#2192 (comment)

// webpack.config.js
      {
        test: /\.(js|ts)x?$/,
        loader: 'babel-loader',
        exclude: /node_modules/,
      },
      // add it like this
      {
        test: /\.mjs/,
        include: /node_modules/,
        type: 'javascript/auto',
      },

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

1 participant