forked from jgraph/mxgraph
-
Notifications
You must be signed in to change notification settings - Fork 199
Description
Is your feature request related to a problem? Please describe
It's currently not possible to import only a subset of the available Perimeter and EdgeStyle functions into a consuming application.
This results in larger bundle sizes, as all implementations are pulled in automatically.
Why? Because:
EdgeStyleis a class with static properties.Perimeteris a value object (before v0.7.0, it was also a class with static methods, likeEdgeStyle).
As soon as you import one, you get the whole thing.
Notice that having a class with only static properties are generally considered as a bad practice:
- https://github.com/sindresorhus/eslint-plugin-unicorn/blob/v58.0.0/docs/rules/no-static-only-class.md
- https://www.typescriptlang.org/docs/handbook/2/classes.html#why-no-static-classes
Describe the solution you'd like
We’d like to make these utilities tree-shakable.
Proposal:
- Refactor
EdgeStyleandPerimeterinto anamespace.- This should allow tree shaking to work.
- No impact for most consumers.
- Might affect users who extended these objects (which is not recommended anyway).
Bonus tasks:
- Move the JSDoc from the source code to the official documentation site.
- Optionally: enable the ESLint
unicorn/no-static-only-classrule to avoid to reintroduce class with only static properties.
Describe alternatives you've considered
- Keeping the current implementation, but the size impact can be significant in consumer apps.
- Splitting each function into its own file, but this would increase boilerplate and isn't as ergonomic.
Additional context
This refactoring would:
- Help reduce the bundle size of apps using
maxGraph. - Improve overall modularity and modern compatibility (e.g., ESM, tree shaking).
- Be consistent with ongoing efforts to optimize for modern JS tooling.
Metadata
Metadata
Assignees
Labels
enhancementNew feature or requestNew feature or request