umijs / babel-plugin-import

Modularly import plugin for babel.
3.16k stars 404 forks source link

Not working with create-react-native-app #131

Open laukaichung opened 7 years ago

laukaichung commented 7 years ago

I have started a new project with create-react-native-app. Change the .babelrc to this:

 {
  "presets": ["babel-preset-expo"],
  "env": {
    "development": {
      "plugins": [
        "transform-react-jsx-source",
      ]
    }
  },
  "plugins": [
    ["import", { "libraryName": "antd-mobile" }]
  ]
}
import { Button } from 'antd-mobile';

export class Screen extends React.Component<any,{}>{
   render(){
     return(
            <View>
                <Button>Something</Button>
            </View>
        )
   }
}

I'm still getting this error:

Note: must use https://github.com/ant-design/babel-plugin-import .
For more information, please see https://github.com/ant-design/ant-design-mobile/issues/602
r20 commented 7 years ago

I have the same problem but with create-react-app and antd (not mobile).

laukaichung commented 7 years ago

@r20 , I wonder if it's because create-react-app ignores the changes in .babelrc. I'm still waiting for some sort of alternative to changing the .babelrc file.

r20 commented 7 years ago

@stonecold123 , I haven't tried it yet but see http://stackoverflow.com/questions/44034773/how-do-i-use-babelrc-to-get-babel-plugin-import-working-for-antd. I haven't run eject, so this is something I'll try.

laukaichung commented 7 years ago

@r20, someone on the CRNA forum says you shouldn't need to eject to use the framework with different babel settings. I think there's a problem with the plugin itself. The antd team also says they are going to make an expo example https://github.com/ant-design/ant-design-mobile/issues/1333 , so I'd wait before resort to eject.