| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
|
That's great, well done! Thank you very much for addressing the commonjs issue. I have published a final version of maxgraph-core-commonjs in order to deprecate it. The additional support for creating portable .svg files which it provided can now be found in my new package svg-inline-images. Thank you. |
| Back | FazBrowse Home | New Git URL |
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.
Uh oh!
There was an error while loading. Please reload this page.
{{editor}}'s edit
{{editor}}'s edit
Uh oh!
There was an error while loading. Please reload this page.
โก This new version improves registry consistency, removes legacy enums, supports CommonJS, and enables tree-shaking optimizations. โก
Resources
Breaking changes
Important
Several breaking changes are introduced to align internal APIs, improve tree-shaking, and reduce complexity. These changes mostly affect users customizing the graph.
Unified Registry API for Style Elements
All style-related registries now implement the same Registry interface. This ensures a consistent developer experience and makes it easier to use or extend them. ๐ ๏ธ
Note
If you were using custom style registration, you'll likely need to update your code.
Renamed / Replaced Registries
Code migration examples
Special case: EdgeStyleRegistry
In addition to method renaming, EdgeStyleRegistry.add() now takes an extra options object to categorize the style. This avoids hardcoded behavior and improves flexibility. ๐งฉ
This change supports internal refactors (see Highlights) and better extension patterns.
Element retrieval
For most users, no impact is expected. Retrieval methods are typically used in custom extensions only.
Note
EdgeMarkerRegistry still exposes its specific createMarker method unchanged. ๐ฏ
Enum Removal and Renaming
All remaining enums have been removed. They caused unnecessary complexity and werenโt actually used to list values. ๐งน
Use the corresponding string-based types instead:
Other specific changes:
constants.NODETYPE โ replaced by value object constants.NODE_TYPE
constants.FONT โ replaced by constants.FONT_STYLE_FLAG
constants.CURSOR โ values moved to:
Also, constants.DIRECTION_MASK is now read-only. ๐
Highlights
CommonJS Support for Node & Test Environments
maxGraph now ships with dual ESM and CommonJS builds. ๐
Historically, only ESM was supported, as maxGraph was mainly used in browser-based applications with bundlers. But some new use cases made CJS support necessary:
Why it's useful
Testing (e.g. with Jest): CJS is default in many test setups. Previously, you had to:
Now, maxGraph works in Jest without forcing ESM migration. โ
Now it just works. ๐
Tip
Two new examples were added to show CommonJS usage:
Tree-shaking Improvements
Tree-shaking is now much more effective thanks to multiple internal refactors. ๐งผ
Main improvement
EdgeStyle implementations are no longer hardcoded throughout the codebase. Instead, the code only relies on what is dynamically registered with configuration (see Breaking changes).
This allows bundlers to remove unused styles - big win on size! ๐ฆ
Example size comparison
Examples from maxGraph repo
Even with no changes in your app, enum removal already saves 3โ5 kB. If your app avoids most EdgeStyles, savings can go up to 17 kB. ๐
Note
See #806 for enum removal, and #809 for EdgeStyle tree-shaking.
Warning
The 3 kB drop in js-example* is from button simplification in the examples, not related to maxGraph itself (see #822).
Examples from maxgraph-integration-examples repo
All share common Graph config and use EdgeStyle.OrthConnector. โ๏ธ
What's Changed
๐ New Features
๐ Bug Fixes
๐ Documentation
โ๏ธ Refactor
๐ Chore
Full Changelog: v0.19.0...v0.20.0
This discussion was created from the release 0.20.0.