Skip to content

refactor: export mxGraph objects directly instead of via mxgraph namespace#3491

Merged
tbouffard merged 3 commits intomasterfrom
refactor/simplify_mxgraph_object_exports
Mar 18, 2026
Merged

refactor: export mxGraph objects directly instead of via mxgraph namespace#3491
tbouffard merged 3 commits intomasterfrom
refactor/simplify_mxgraph_object_exports

Conversation

@tbouffard
Copy link
Copy Markdown
Member

Destructure mxGraph objects from the mxgraph factory export so internal
code imports them directly (e.g. mxGraph, mxConstants) rather than
accessing them through mxgraph.mxGraph, mxgraph.mxConstants.

This enables tree-shaking since bundlers can track individual named
imports, improves readability by removing the repetitive mxgraph.
prefix, and makes imports explicit about which mxGraph objects each
module actually depends on.

mxGraph is exported separately with an explicit typeof annotation to
work around api-extractor losing constructor type information during
.d.ts rollup, which caused TS2507 in downstream type checks.

…space

Destructure mxGraph objects from the mxgraph factory export so internal
code imports them directly (e.g. `mxGraph`, `mxConstants`) rather than
accessing them through `mxgraph.mxGraph`, `mxgraph.mxConstants`.

This enables tree-shaking since bundlers can track individual named
imports, improves readability by removing the repetitive `mxgraph.`
prefix, and makes imports explicit about which mxGraph objects each
module actually depends on.

mxGraph is exported separately with an explicit `typeof` annotation to
work around api-extractor losing constructor type information during
.d.ts rollup, which caused TS2507 in downstream type checks.
@tbouffard tbouffard added the refactoring Code refactoring label Mar 17, 2026
@github-actions
Copy link
Copy Markdown

github-actions bot commented Mar 17, 2026

♻️ PR Preview 22e2ff4 has been successfully destroyed since this PR has been closed.

🤖 By surge-preview

@github-actions
Copy link
Copy Markdown

github-actions bot commented Mar 17, 2026

♻️ PR Preview 22e2ff4 has been successfully destroyed since this PR has been closed.

🤖 By surge-preview

Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR refactors mxGraph usage so modules import mxGraph objects as direct named exports from the initializer (e.g. mxConstants, mxRhombus) instead of accessing them via the mxgraph.* namespace, aiming to improve readability and tree-shaking and to address api-extractor constructor typing issues.

Changes:

  • Updated multiple mxGraph-related modules to extend/use mxGraph classes via direct imports (mxEllipse, mxRhombus, mxConnector, mxText, mxCellOverlay, etc.).
  • Reworked src/component/mxgraph/initializer.ts to export a set of destructured mxGraph objects plus a separately exported mxGraph with an explicit constructor type annotation.
  • Adjusted tests and dev tooling code to use the new named exports.

Reviewed changes

Copilot reviewed 11 out of 11 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
test/integration/mxGraph.model.bpmn.elements.test.ts Uses mxGeometry via direct import instead of mxgraph.mxGeometry.
src/component/mxgraph/shape/gateway-shapes.ts Extends mxRhombus via direct import.
src/component/mxgraph/shape/event-shapes.ts Extends mxEllipse via direct import.
src/component/mxgraph/shape/edges.ts Extends mxConnector via direct import.
src/component/mxgraph/overlay/shapes.ts Extends mxText via direct import.
src/component/mxgraph/overlay/custom-overlay.ts Extends mxCellOverlay via direct import.
src/component/mxgraph/initializer.ts Adds destructured exports and exports mxGraph separately with explicit typing.
src/component/mxgraph/config/register-style-definitions.ts Uses mxMarker directly instead of mxgraph.mxMarker.
src/component/mxgraph/BpmnGraph.ts Extends mxGraph and mxGraphView via direct imports; resolves type/value name conflicts.
src/component/mxgraph/BpmnCellRenderer.ts Extends mxCellRenderer and uses mxDictionary/mxImageShape via direct imports.
dev/ts/component/SvgExporter.ts Uses mxImageExport via direct import instead of mxgraph.mxImageExport.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@sonarqubecloud
Copy link
Copy Markdown

@tbouffard tbouffard marked this pull request as ready for review March 18, 2026 14:44
@tbouffard tbouffard merged commit 993603b into master Mar 18, 2026
24 checks passed
@tbouffard tbouffard deleted the refactor/simplify_mxgraph_object_exports branch March 18, 2026 14:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

refactoring Code refactoring

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants