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

babel-plugin-import - not work #139

Open
gromov-io opened this issue Apr 17, 2020 · 10 comments
Open

babel-plugin-import - not work #139

gromov-io opened this issue Apr 17, 2020 · 10 comments

Comments

@gromov-io
Copy link

image

@jannikbuschke
Copy link
Owner

Hi @gromov-io ,

Can you share your setup? Maybe you can compare your config with https://github.com/jannikbuschke/cra-antd-x, where babel plugin should work.

@jannikbuschke
Copy link
Owner

I just noticed that it didnt yet fully work. I think I fixed it just now. This is the config: https://github.com/jannikbuschke/cra-antd-x/blob/master/config-overrides.js

@jannikbuschke
Copy link
Owner

@gromov-io can you verify if it now works?

@franknoel
Copy link

I'm having the same issue with a .babel.rc file.

"plugins": [
    [
      "import",
      {
        "libraryName": "antd",
        "style": true
      },
      "antd"
    ],
    [
      "import",
      {
        "libraryName": "formik-antd",
        "style": true
      },
      "formik-antd"
    ],
]

@jannikbuschke
Copy link
Owner

Maybe try "style": "css" and "libraryDirectory":"es" for both imports (like here https://github.com/jannikbuschke/cra-antd-x/blob/master/config-overrides.js)

@jannikbuschke
Copy link
Owner

Also it would be nice if you can clone the boilerplate (cra-antd-x), verify and report back if it works there. Would be kindly appreciated.

@gromov-io
Copy link
Author

Hi, I apologize for the long reply. Here is my config file and it does not work.

PS this only works if the project antd component is already used somewhere

"plugins": [
      ["import",{
        "libraryName": "antd",
        "libraryDirectory": "es",
        "style": "css"
      }],
      ["import",{
        "libraryName": "formik-antd'",
        "libraryDirectory": "es",
        "style": "css"
      }, "formik-antd"],
      ["@babel/plugin-proposal-optional-chaining",{
        "loose": false
      }]
    ]

Here is an example input displayed correctly, since I already used "input" from antd in other components. And here is "inputNuber and Checkbox" without styles

image

And here is how it looks if I connect parts of "antd"
image

@jannikbuschke
Copy link
Owner

maybe remove the single ' in "libraryName": "formik-antd'",?

If that does not work, can you try if it works with config-overrids.js exactly as it is done here: https://github.com/jannikbuschke/cra-antd-x/blob/master/config-overrides.js) (not using a json confi as you are doing).

@mikedotJS
Copy link

Hey,

Any news on this one? I'm having the same problem and i tried the suggested solutions above.

Current .babelrc :

[
      "import",
      {
        "libraryName": "antd",
        "style": true
      },
      "antd"
    ],
    [
      "import",
      {
        "libraryName": "formik-antd",
        "style": true
      },
      "formik-antd"
    ]

On a Next.js app.

When i only use antd the warning is gone, it appears as soon as i use formik-antd.

I tried to import components as import Input from 'formik-antd/lib/input' but it doesn't work either.

@jannikbuschke
Copy link
Owner

maybe try with "style":"css" and "libraryDirectory":"es"

https://github.com/jannikbuschke/formik-antd#advanced-setup

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

4 participants