Heading
Bold
Italic
Quote
Code
Link
Numbered list
Unordered list
Task list
Attach files
Mention
Reference
Menu
reacted with thumbs up emoji
reacted with thumbs down emoji
reacted with laugh emoji
reacted with hooray emoji
reacted with confused emoji
reacted with heart emoji
reacted with rocket emoji
reacted with eyes emoji
Uh oh!
There was an error while loading. Please reload this page.
{{title}}
Uh oh!
There was an error while loading. Please reload this page.
โก This new version introduces BaseGraph for better control over loaded features, adds new utilities to register default style elements, and significantly reduces bundle size! โก
Resources
Highlights
๐ Introducing BaseGraph
Historically, the Graph class has been the main entry point in maxGraph, just like it was in mxGraph.
It automatically loads default plugins and style elements, making it convenient for prototyping but less ideal for production use - it increases the bundle size by including features you might not even use.
With v0.18.0, you now have a better option:
This is a big step toward full tree-shaking support!
More improvements are coming soon. Stay tuned! ๐ป
Note
See issue #665 for the full roadmap on tree-shaking improvements.
๐ Usage of BaseGraph
BaseGraph also simplifies constructor usage:
Instead of many parameters (and sometimes lots of null), you now pass a single configuration object.
Example - Basic setup:
Example - Full configuration:
Compared to Graph, it's much cleaner - no need to extend classes just to customize internals!
โก Comparison: Graph Usage
When using the traditional Graph class, customization often requires class extension and overriding internal methods (createXXX) which makes the code heavier and less readable.
Example - Basic setup:
Example - Full customization:
Warning
This approach leads to less readable code and harder maintenance, especially when you don't want to override everything!
๐จ Easier Ways to Register Style Elements
Want to manually register default styles? New helper functions are available:
Use them to selectively register only what your app actually needs!
If you need all built-in elements for a category, these helpers make it super easy.
Note
"Edge Marker" factories (for arrow shapes and such) are now public too. Flexibility unlocked! ๐
๐ฆ Impact of BaseGraph on Bundle Size
Using BaseGraph with only the styles and plugins you need can drastically shrink your app's bundle size.
Tree-shaking now works better and smarter!
In our examples, switching to BaseGraph with a minimal setup gave measurable improvements, even with default bundler configs!
The "without-defaults" examples showed a decrease 105 kB!
๐ฌ Examples from the maxGraph repository
Tip
JS examples use Webpack, TS examples use Vite (Vite/Rollup does better tree-shaking!)
๐ See documentation for full example details.
๐ฌ Examples from the maxgraph-integration-examples repository
Integration projects also switched to BaseGraph, showing similar gains:
Fun fact:
Removing the optional CellEditorHandler plugin in vite drops another ~12.5 kB!
Related PRs: #214, #215
What's Changed
๐ New Features
๐ Bug Fixes
๐ Documentation
โ๏ธ Refactor
Full Changelog: v0.17.0...v0.18.0
This discussion was created from the release 0.18.0.