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

Could antd use more specific icon imports internally, rather than importing using destructuring? #21744

Closed
1 task done
tekacs opened this issue Mar 1, 2020 · 0 comments · Fixed by #21752
Closed
1 task done
Assignees
Labels

Comments

@tekacs
Copy link

tekacs commented Mar 1, 2020

  • I have searched the issues of this repository and believe that this is not a duplicate.

What problem does this feature solve?

As things stand, imports of icons inside of antd itself use destructuring to pull in icons from @ant-design/icons:

import { LoadingOutlined } from '@ant-design/icons';

Downstream users are encouraged to manually import using the form:

import Timeline from 'antd/es/timeline'

Unfortunately, if not using an advanced tree shaking implementation like Webpack, this currently results in the entire @ant-design/icons and @ant-design/icons-svg packages being pulled in, as the destructuring import of icons first pulls in @ant-design/icons/lib/index.js

This is likely also why some folks have provided solutions such as https://github.com/DavidSichau/antd-fa-icons, since tree shaking appears not to work for everyone.

What does the proposed API look like?

If the imports inside of antd were updated to follow antd's own advice, many more downstream bundlers would correctly pull in only the relevant code.

The idea would be to change the imports from this:

import { LoadingOutlined } from '@ant-design/icons';

to this:

import LoadingOutlined from '@ant-design/icons/LoadingOutlined'

Thanks very much. :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants