GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — Refactor Perimeter and EdgeStyle to support tree shaking · Issue #759 · maxGraph/maxGraph

Refactor Perimeter and EdgeStyle to support tree shaking #759

New issue
Copy link
New issue
Copy link
Closed
Enhancement
#791
Closed
Refactor Perimeter and EdgeStyle to support tree shaking#759
Enhancement
#791
Copy link
Assignees
tbouffard
Labels
enhancementNew feature or request
Milestone
0.19.0

Description

@tbouffard
tbouffard
opened on Apr 11, 2025
Issue body actions

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:

  • EdgeStyle is a class with static properties.
  • Perimeter is a value object (before v0.7.0, it was also a class with static methods, like EdgeStyle).

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 EdgeStyle and Perimeter into a namespace.
    • 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-class rule 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.

Activity

  1. tbouffard
    added
    enhancementNew feature or request
    on Apr 11, 2025
  2. tbouffard
    added the
    Enhancement
    issue type on Apr 11, 2025
  3. tbouffard
    added a parent issue on Apr 11, 2025
    • Strategies for Further Tree-Shaking Improvements #665
  4. tbouffard
    self-assigned this
    on Apr 28, 2025
  5. tbouffard
    added this to the 0.19.0 milestone on Apr 28, 2025
  6. tbouffard
    closed this as completedin #791on Apr 30, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

  • @tbouffard
    tbouffard

Labels

enhancementNew feature or request

Type

Enhancement

Projects

No projects

    Milestone

    • 0.19.0

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

    You are visitor 01402775 — GeezerVison does not store the pages you look up.
    Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.