You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@superset.apache.org by "kgabryje (via GitHub)" <gi...@apache.org> on 2024/07/31 13:39:51 UTC
[PR] perf: Antd icons tree shaking [superset]
kgabryje opened a new pull request, #29787:
URL: https://github.com/apache/superset/pull/29787
### SUMMARY
Previously we were importing the whole @ant-design/icons library, which contained over 800 icons. We only use 40 of those.
Implementing tree-shakable import allowed to shrink the chunk size by over 5MB.
### BEFORE/AFTER SCREENSHOTS OR ANIMATED GIF
Before:
<img width="1710" alt="Screenshot 2024-07-31 at 15 32 27" src="https://github.com/user-attachments/assets/c97e9b59-d080-4fbd-aada-eccedc4e014a">
After:
<img width="1710" alt="Screenshot 2024-07-31 at 15 34 58" src="https://github.com/user-attachments/assets/7e7fc7ff-f448-4740-a822-6c18f53663db">
### TESTING INSTRUCTIONS
Everything should work like before
### ADDITIONAL INFORMATION
<!--- Check any relevant boxes with "x" -->
<!--- HINT: Include "Fixes #nnn" if you are fixing an existing issue -->
- [ ] Has associated issue:
- [ ] Required feature flags:
- [ ] Changes UI
- [ ] Includes DB Migration (follow approval process in [SIP-59](https://github.com/apache/superset/issues/13351))
- [ ] Migration is atomic, supports rollback & is backwards-compatible
- [ ] Confirm DB migration upgrade and downgrade tested
- [ ] Runtime estimates and downtime expectations provided
- [ ] Introduces new feature or API
- [ ] Removes existing feature or API
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org
Re: [PR] perf: Antd icons tree shaking [superset]
Posted by "michael-s-molina (via GitHub)" <gi...@apache.org>.
michael-s-molina commented on PR #29787:
URL: https://github.com/apache/superset/pull/29787#issuecomment-2261008635
Agree with @kgabryje 👍🏼
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org
Re: [PR] perf: Antd icons tree shaking [superset]
Posted by "kgabryje (via GitHub)" <gi...@apache.org>.
kgabryje commented on code in PR #29787:
URL: https://github.com/apache/superset/pull/29787#discussion_r1700125221
##########
superset-frontend/src/components/Icons/AntdEnhanced.tsx:
##########
@@ -17,10 +17,94 @@
* under the License.
*/
-import * as AntdIcons from '@ant-design/icons/lib/icons';
+import {
Review Comment:
oh nice! never used it myself
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org
Re: [PR] perf: Antd icons tree shaking [superset]
Posted by "kgabryje (via GitHub)" <gi...@apache.org>.
kgabryje merged PR #29787:
URL: https://github.com/apache/superset/pull/29787
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org
Re: [PR] perf: Antd icons tree shaking [superset]
Posted by "kgabryje (via GitHub)" <gi...@apache.org>.
kgabryje commented on PR #29787:
URL: https://github.com/apache/superset/pull/29787#issuecomment-2260916473
> While I understand the need for this, the idea here was that you could use any Antd icon without having to specify it again. Not sure if there is a way around that to keep that functionality available.
Yes I know that the component is now going to be harder to use, but I don't see any other way to fix the problem. Due to the dynamic nature of defining icons, webpack had no way of guessing which icons are actually used, so we ended up with a huge chunk containing every icon in antd.
We don't add new icons that often, so I think it won't be a big overhead to add a new icon to the import list once in a while. It's "lesser evil" compared to the performance decrease that we suffer from it
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org
Re: [PR] perf: Antd icons tree shaking [superset]
Posted by "mistercrunch (via GitHub)" <gi...@apache.org>.
mistercrunch commented on code in PR #29787:
URL: https://github.com/apache/superset/pull/29787#discussion_r1698958701
##########
superset-frontend/src/components/Icons/AntdEnhanced.tsx:
##########
@@ -17,10 +17,94 @@
* under the License.
*/
-import * as AntdIcons from '@ant-design/icons/lib/icons';
+import {
+ AlignCenterOutlined,
+ AlignLeftOutlined,
+ AlignRightOutlined,
+ ApartmentOutlined,
+ BarChartOutlined,
+ BookOutlined,
+ CalendarOutlined,
+ CheckOutlined,
+ CheckSquareOutlined,
+ CloseOutlined,
+ ConsoleSqlOutlined,
+ CopyOutlined,
+ DatabaseOutlined,
+ DeleteFilled,
+ DownOutlined,
+ EditOutlined,
+ ExclamationCircleOutlined,
+ EyeOutlined,
+ EyeInvisibleOutlined,
+ FallOutlined,
+ FileImageOutlined,
+ FileOutlined,
+ FireOutlined,
+ FullscreenExitOutlined,
+ FullscreenOutlined,
+ FundProjectionScreenOutlined,
+ InfoCircleOutlined,
+ InsertRowBelowOutlined,
+ MonitorOutlined,
+ PlusCircleOutlined,
+ PlusOutlined,
+ ReloadOutlined,
+ RightOutlined,
+ SaveOutlined,
+ SearchOutlined,
+ SettingOutlined,
+ StopOutlined,
+ TagsOutlined,
+ UpOutlined,
+ UserOutlined,
+} from '@ant-design/icons';
import { StyledIcon } from './Icon';
import IconType from './IconType';
+const AntdIcons = {
Review Comment:
I looked for ways to keep things DRY here and not have to repeat icon names twice, but didn't find any way. Too bad ECMAScript doesn't support something like `import {a, b, c} as container from ....`
##########
superset-frontend/src/components/Icons/AntdEnhanced.tsx:
##########
@@ -17,10 +17,94 @@
* under the License.
*/
-import * as AntdIcons from '@ant-design/icons/lib/icons';
+import {
Review Comment:
would be good to add a comment
```
// Targeted import (as opposed to `import * as antdIcons`) is important here for proper tree-shaking
```
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org
Re: [PR] perf: Antd icons tree shaking [superset]
Posted by "mistercrunch (via GitHub)" <gi...@apache.org>.
mistercrunch commented on code in PR #29787:
URL: https://github.com/apache/superset/pull/29787#discussion_r1699226880
##########
superset-frontend/src/components/Icons/AntdEnhanced.tsx:
##########
@@ -17,10 +17,94 @@
* under the License.
*/
-import * as AntdIcons from '@ant-design/icons/lib/icons';
+import {
Review Comment:
ok I added a commit with the comment - first time using that GH feature...
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org
Re: [PR] perf: Antd icons tree shaking [superset]
Posted by "geido (via GitHub)" <gi...@apache.org>.
geido commented on PR #29787:
URL: https://github.com/apache/superset/pull/29787#issuecomment-2260908180
While I understand the need for this, the idea here was that you could use any Antd icon without having to specify it again. Not sure if there is a way around that to keep that functionality available.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org
Re: [PR] perf: Antd icons tree shaking [superset]
Posted by "rusackas (via GitHub)" <gi...@apache.org>.
rusackas commented on code in PR #29787:
URL: https://github.com/apache/superset/pull/29787#discussion_r1699228392
##########
superset-frontend/src/components/Icons/AntdEnhanced.tsx:
##########
@@ -17,10 +17,94 @@
* under the License.
*/
-import * as AntdIcons from '@ant-design/icons/lib/icons';
+import {
Review Comment:
> first time using that GH feature...
I'm in love with it... also great for fixing little linting issues on PRs and such.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org