Uniforms: You are using a whole package of antd, please use...

Created on 3 Mar 2017  路  8Comments  路  Source: vazco/uniforms

I base on [email protected].
After I update to "antd": "^2.7.4", "uniforms-antd": "^1.13.1", I get error

You are using a whole package of antd,
please use....

My package

// babelrc
{
  "plugins": [
    [
      "import",
      {
        "libraryName": "antd",
        "style": "css"
      }
    ],
    "transform-class-properties"
  ]
}

Please help me.

question

Most helpful comment

So it mean that we must be need import ... from 'antd/lib/... for all such as

import Layout from 'antd/lib/layout';
import Menu from 'antd/lib/menu';
import Breadcrumb from 'antd/lib/breadcrumb';
import Icon from 'antd/lib/icon';
....

All 8 comments

This is what worked for me.
Firstly ensure that you have babel-plugin-import installed. In .babelrc I only have:
{ "plugins": [ ["import", {"libraryName": "antd"}] ] }
Then when you do imports, always use (for example Icon):
import Icon from 'antd/lib/icon;
To only import the component you are using. This is all that I can think of now. Let me know if this helps.

Thanks for your reply. This is my package:

{
  "name": "ant-design",
  "private": true,
  "scripts": {
    "start": "meteor run"
  },
  "dependencies": {
    "antd": "^2.7.4",
    "babel-plugin-import": "^1.1.1",
    "babel-runtime": "^6.23.0",
    "classnames": "^2.2.5",
    "flexboxgrid": "^6.3.1",
    "graphql": "^0.9.1",
    "indexof": "0.0.1",
    "jquery": "^3.1.1",
    "jquery-validation": "^1.16.0",
    "meteor-node-stubs": "~0.2.3",
    "moment": "^2.17.1",
    "react": "^15.4.2",
    "react-addons-pure-render-mixin": "^15.4.2",
    "react-dimensions": "^1.3.0",
    "react-dom": "^15.4.2",
    "react-flexbox-grid": "^0.10.2",
    "react-mounter": "^1.2.0",
    "react-sizeme": "^2.2.0",
    "simpl-schema": "^0.2.2",
    "uniforms": "^1.13.1",
    "uniforms-antd": "^1.13.1"
  },
  "devDependencies": {
    "babel-plugin-import": "^1.1.0",
    "babel-plugin-transform-class-properties": "^6.23.0",
    "babel-polyfill": "^6.23.0"
  }
}
---
{
  "plugins": [
    [
      "import",
      {
        "libraryName": "antd",
        "style": true
      }
    ],
    "transform-class-properties"
  ]
}

and then I tied to add @import '{}/node_modules/antd/dist/antd.less'; to /client

So it mean that we must be need import ... from 'antd/lib/... for all such as

import Layout from 'antd/lib/layout';
import Menu from 'antd/lib/menu';
import Breadcrumb from 'antd/lib/breadcrumb';
import Icon from 'antd/lib/icon';
....

I do not have any plugins key in my package.json and have the:
{ "plugins": [ ["import", {"libraryName": "antd"}] ] }
In the .babelrc file in the root of my project folder.

In my style.less file I have:
@import '{}/node_modules/antd/dist/antd.less'; @primary-color: #434d52; @border-radius-base: 2px;
To overwrite less variables.
and yes for all import ... from 'antd/lib/... imports.

Sorry for plugins key is in .babelrc (not in package.json), I will try soon.
So we can not use import { LocaleProvider, Layout, Menu, Icon, Breadcrumb} from 'antd';

Now it work fine, Very thanks.
Request you to create all of component such as Date Range, Tree Select....!

In my project, if I have one of:
import { Menu, Icon } from 'antd';
instead of:
import Menu from 'antd/lib/menu'; import Icon from 'antd/lib/icon';
I get the warning that you refer to. If I import the defaults like in the second one, the warning goes away. What exactly the reason is I don't know.

Some of those components you should build as a custom component and render though uniforms. Currently uniforms-antd has the base set of components as all the other uniforms themes, I don't think that will change.
Maybe in the future we can have a standard to publish extra custom components separately? ( @radekmie ) but I not sure how that would work. But that should not be discussed in this issue.

Glad it worked.

As you can see in the sources, none of uniforms-antd components is importing antd - every import is a direct one, for example antd/lib/icon.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

serkandurusoy picture serkandurusoy  路  5Comments

tab00 picture tab00  路  8Comments

arrygoo picture arrygoo  路  3Comments

cesarve77 picture cesarve77  路  4Comments

rafahoro picture rafahoro  路  3Comments