abhijithvijayan / web-extension-starter

🖥🔋Web Extension starter to build "Write Once Run on Any Browser" extension
MIT License
1.97k stars 169 forks source link

Can not import RadixUI components? #101

Closed nemanjam closed 7 months ago

nemanjam commented 7 months ago

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 commented 7 months ago

I found the solution.

https://github.com/radix-ui/primitives/issues/2192#issuecomment-1580186800

// 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',
      },