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

dynamic module loading improves module import size? #293

Open
filoscoder opened this issue Nov 12, 2022 · 4 comments
Open

dynamic module loading improves module import size? #293

filoscoder opened this issue Nov 12, 2022 · 4 comments

Comments

@filoscoder
Copy link

We are importing Kekule like below
Screenshot 2022-11-12 at 9 34 40 PM

The size is huge, we only need IO, Editor, and ChemWidget modules.
There is any way of importing modules with improved bundle sizes?

Can you provide examples of dynamic module loading please?

@partridgejiang
Copy link
Owner

Hi @filoscoder, if only certain modules are needed, you can use the utils/jsMinifier/ to build a custom min js file including only those modules to reduce the file size. E.g.:

node utils/jsMinifier/run.js -m io,chemWidget -d my/dest/path

Then use the custom kekule.min.js (not kekule.js):

import { Kekule } from "path/kekule.min.js";

However, since the editor is the most complex widget in package and requires a lot of functions from other modules, the reduced size is quite limited in the method above (from 2.56MB to 2.15MB).

@filoscoder
Copy link
Author

Hi @filoscoder, if only certain modules are needed, you can use the utils/jsMinifier/ to build a custom min js file including only those modules to reduce the file size. E.g.:

node utils/jsMinifier/run.js -m io,chemWidget -d my/dest/path

Then use the custom kekule.min.js (not kekule.js):

import { Kekule } from "path/kekule.min.js";

However, since the editor is the most complex widget in package and requires a lot of functions from other modules, the reduced size is quite limited in the method above (from 2.56MB to 2.15MB).

I'm not following where is utils/jsMinifier, is a helper inside Kekule?
Anyways It seems pretty unnecessary to customize the build for such a tiny difference.
Thanks a lot for testing it beforehand!

@partridgejiang
Copy link
Owner

The jsMinifier util is in the source code repo: https://github.com/partridgejiang/Kekule.js/tree/master/utils/jsMinifier , :).

@filoscoder
Copy link
Author

The jsMinifier util is in the source code repo: https://github.com/partridgejiang/Kekule.js/tree/master/utils/jsMinifier , :).

niceee, thanks a lot 🤙🏼

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

No branches or pull requests

2 participants