DocSpring / craco-antd

A craco plugin to use Ant Design with create-react-app
MIT License
234 stars 49 forks source link

Cannot find module 'babel-plugin-import' #4

Closed unzico closed 5 years ago

unzico commented 5 years ago

Hi,

first of all, thanks for your work. Using CRA 2.x with Antd is super easy now. However, trying to start an app using the approach described in the installation guide will throw an immediate error, stating:

Cannot find module babel-plugin-import from '...'

This is easily resolved by installing babel-plugin-import manually. Looking at the readme, I assume that's not the indended way of installing craco-antd, as it states:

craco-antd includes:

  • Less (provided by craco-less)
  • babel-plugin-import to only import the required CSS, instead of everything
  • A nicer way to customize the theme. Save your modified variables in antd.customize.json

I would therefore recommend shipping craco-antd with babel-plugin-import (no clue, how to do that. Simply install the plugin as a dev dependency (?)) or advising users to install the plugin manually.

Reproduction: https://github.com/unzico/craco-antd-plugin-missing git clone https://github.com/unzico/craco-antd-plugin-missing cd craco-antd-plugin-missing yarn yarn start

Thank you, have a nice weekend.

ndbroadbent commented 5 years ago

Whoops, sorry about that! You're totally right, babel-import-plugin should be a dependency. I've added that and released 1.5.0.

Sorry again, I should have really tested on a fresh create-react-app project, but my app already had babel-plugin-import in the package.json so I didn't notice this issue. Please let me know if you run into any other problems!

unzico commented 5 years ago

Works perfectly now. Thank you for your quick response :+1:

farhanaslam5151 commented 5 years ago

Whoops, sorry about that! You're totally right, babel-import-plugin should be a dependency. I've added that and released 1.5.0.

Sorry again, I should have really tested on a fresh create-react-app project, but my app already had babel-plugin-import in the package.json so I didn't notice this issue. Please let me know if you run into any other problems!

can you please explain with exact steps how to fix this issue.