-
Notifications
You must be signed in to change notification settings - Fork 3
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
perf: Improve code splitting #1071
Conversation
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
3214efb
to
0bc4d8f
Compare
@ptbrowne I am going to merge, let me know if you have any thoughts on this :) |
Thanks Bartosz, LGTM. On the further notes, I am wondering why every chart is bundled when the |
Yes, that's the case – but the column chart that we import is basically this, visualization-tool/app/charts/column/chart-column.tsx Lines 95 to 217 in 91b2d00
|
I think the problem is that we have one function that renders different chart subtype based on some conditions – if it was split inside three functions, that would prevent bundling everything. I tried to split that, but still there was a root check on chart type ( visualization-tool/app/components/common-chart.tsx Lines 68 to 89 in 91b2d00
|
I see. I think it would be good to use a bundle analyser (like webpack
bundle analyser) to see if effectively this is here that we have the
biggest size. When I have a quick check at the column charts file, I see
that they do not weigh a lot. I would see bundle size being more a result
of libraries (or maybe icons) that we import when not necessary, more than
application code.
```
➜ cd app/charts/column
➜ ls
(base)
chart-column.tsx columns-grouped.tsx
columns-stacked-state.tsx columns-state.tsx overlay-columns.tsx
columns-grouped-state.tsx columns-simple.tsx columns-stacked.tsx
constants.ts rendering-utils.tsx
➜ du -sh .
(base)
80K .
➜ cat * | gzip | wc -c
(base)
9193
```
On 20 June 2023 at 10:33:46, Bartosz Prusinowski ***@***.***) wrote:
Yes, that's the case – but the column chart that we import is basically
this,
https://github.com/visualize-admin/visualization-tool/blob/91b2d00e38067535f2b9b15bb6a645621a6a54dc/app/charts/column/chart-column.tsx#L95-L217
which means that we have three charts inside one function.
—
Reply to this email directly, view it on GitHub
<#1071 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AADRVLWCX5HYGNL3JMZ3ZVDXMFN6VANCNFSM6AAAAAAZL74O74>
.
You are receiving this because you were mentioned.Message ID:
***@***.***>
|
Yup, I used |
ContentMDXProvider
in_app.tsx
, to prevent adding ~2.8MB in payload size to every page, but rather only use it where it's necessaryFurther ideas
Right now, if we want to render a simple column chart, we bundle all column chart related logic, including the grouped chart state, stacked chart state, code for rendering grouped & stacked charts, etc.
I believe that this could be avoided if we split the code in a manner that we treat these as different chart types and not include them in one function (ChartColumnsVisualization) that conditionally renders a given chart subtype. I think this would be a bigger change, as we would need to treat these chart subtypes as chart types, e.g. "column-simple", "column-grouped", "column-stacked". With this we wouldn't bundle things that are not necessary.