babel-plugin-import icon indicating copy to clipboard operation
babel-plugin-import copied to clipboard

it doesn't work for rxjs

Open baiterry opened this issue 2 years ago • 1 comments

In my React Native project, I tried to import rxjs with this plugin.

Here's my babel.config.js

[
    'import',
    {
        libraryName: "rxjs",
        camel2DashComponentName: false,
        customName: (name, file) => {
            if (['debounceTime', 'throttleTime'].includes(name)) {
                return `rxjs/internal/operators/${name}`;
            }
            return `rxjs/internal/${name}`;
        }
    }
]

But I got problem that said TypeError: _Subject2.default is not a constructor.... And ideas?

p.s. I've tried to manually change the import statement, like:

// import {debounceTime} from 'rxjs';
import {debounceTime} from 'rxjs/internal/operators/debounceTime';

And it worked. So cleanly there was something wrong when I used this plugin.

baiterry avatar Apr 06 '22 05:04 baiterry

Have you tried setting transformToDefaultImport to false?

FlorianWendelborn avatar Jun 08 '22 14:06 FlorianWendelborn