-
Notifications
You must be signed in to change notification settings - Fork 77
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
Use dynamic import for mxgraph to reduce final main bundle size #19
Conversation
Hey, folks: warmed this back up! Here's the packed size:
Here's the final bundles (under a prod, minimized build):
I can't do anything about For giggles, and in lieu of automated testing, I hoisted If we can get some of this size management stuff in place, I'd love to see this move forward, and potentially investigate bumping to the newer revs (a la #43), or even taking a crack at mxgraph2. I'd also take a stab at spinning up some way to get off the github runtime dependency (sneaky |
I like it! I am happy to merge ithis :) I might even steal your trick for some other extensions; |
Cool! On terminal, we went a slightly different way... i'll do an alternate PR with that approach. |
Uhoh, |
Thanks for the work!
@SylvainCorlay and I talked about some ways to make this extension more adoptable, and a big one is getting the end-user build burden under control... all it takes is a few big dependencies, and end users will start running into out of memory errors for production builds.
This PR uses a dynamic
import().then((mx)=>...)
for mxgraph which moves the vendored code into its own separate bundle, enabled by a tweak totsconfig.json
and some changes toeditor.ts
.While it still imports
./mxgraph/.../modulated.js
for typing, this doesn't trigger bundling intomain
, and a new promise handles some housekeeping until the extra bundle loads. The net effect is a lot less spinning moons up-front and a lot more spinner the first time you create a drawio editor, but this seems like a reasonable trade.Performance
jupyter lab build
before dynamic loading:jupyter lab build
after dynamic loading:The slightly shorter build time could be incidental, but the size difference is pretty real...
Also, since i was doing a bunch of builds, I snuck in the spdx-compatible license string because i got tired of the warnings.
The other thing to making this more adoptable (out of scope for this PR) is some strategy for removing the runtime github.com dependency. Not sure the right way to do it: one could make an
nbextension
, and pack all that stuff in there, but that feels really dirty. I am figuring we'll end up needing a predictable, runtime-addressable spot to put statics, especially for wasm and complicated existing apps like this-a-here one.Thanks again!