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

Huge bundle size introduced by this package #259

Open
Ducica opened this issue Nov 1, 2024 · 0 comments
Open

Huge bundle size introduced by this package #259

Ducica opened this issue Nov 1, 2024 · 0 comments
Labels
bug Something isn't working

Comments

@Ducica
Copy link
Contributor

Ducica commented Nov 1, 2024

I am not sure if issue is the appropriate place for this, or it should be a RFC. I figured we start here and see where it goes.

There is a problem with this library in a sense that using it in your code is very inefficient in terms of bundle size you get.

To show what I mean, I create a completely independent project. It has one entry point and the only thing it does is imports anything from react-invenio-forms. Note that the code is not even being used, just imported.
image

image

As you can see, you get 7.2 mb for importing anything from the package. As this is meant to be a reusable library that can be used in many places, this is really not ideal.

Issues:

  1. The package.json contains browser key set to cjs, and so you are always importing from cjs distribution even when using es syntax (import from).
  2. The more critical issue is that the package is bundled into one flat index.js file that just imports all the dependencies including tinymce which is humongous. Probably the package build should be changed in such way, to create more files and that you import only what you specifically need from the package (i.e. import {FieldLabel} from "react-invenio-forms/forms/FieldLabel").
  3. The library contains search related components such as
    export class GridResponsiveSidebarColumn extends React.Component {
    . This creates unhealthy dependency between search and form. The search related components should be in invenio_search_ui to keep this clean (in current implementation you get tinymce in your search endpoint).

More or less there is the same issue with react-searchkit, though in that one, the consequences are not so big, as it does not have such large depndencies as react-invenio-forms.

Please let me know what you think about all this or if you have some plans to work on this?

Thank you,

Dusan

@Ducica Ducica added the bug Something isn't working label Nov 1, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant