You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
In applications with large Jest-based test suites written in CommonJS, just adding maxGraph forces a full migration to ESM, which can be a major blocker.
➡️ Example: In bpmn-visualization, migrating from mxGraph to maxGraph required updating 3,000+ test and helper files. See PR #3098.
Another use case: headless SVG rendering using Node.js and jsdom (see #761). While Node supports ESM, some apps are still built in CommonJS — which currently prevents using maxGraph at all.
Describe the solution you'd like
Publish a dual ESM + CJS build in the npm package, including types if necessary.
This would help:
Use maxGraph in test environments like Jest (via ts-jest or pure JS)
Use maxGraph headlessly in Node.js (e.g., SVG export)
Additional context
Here are some dual-build strategies used in the community:
Is your feature request related to a problem? Please describe.
Currently (as of v0.19.0), the
maxGraphnpm package only provides ES modules.CommonJS support was removed in v0.5.0. At that time, it was only provided as a single bundle file (UMD).
But several users have reported issues when using
maxGraphin environments where CommonJS is still the default. For example:In applications with large Jest-based test suites written in CommonJS, just adding
maxGraphforces a full migration to ESM, which can be a major blocker.➡️ Example: In
bpmn-visualization, migrating frommxGraphtomaxGraphrequired updating 3,000+ test and helper files. See PR #3098.Another use case: headless SVG rendering using Node.js and jsdom (see #761). While Node supports ESM, some apps are still built in CommonJS — which currently prevents using
maxGraphat all.Describe the solution you'd like
Publish a dual ESM + CJS build in the npm package, including types if necessary.
This would help:
maxGraphin test environments like Jest (viats-jestor pure JS)maxGraphheadlessly in Node.js (e.g., SVG export)Additional context
Here are some dual-build strategies used in the community:
tsup(based on esbuild):tsup src/index.ts --format cjs,esm --dts --cleanhttps://github.com/egoist/tsup
unbuild(based on rollup):https://github.com/unjs/unbuild
tsctwice: once for ESM (output tolib/esm), once for CJS (lib/cjs). See https://medium.com/ekino-france/supporting-dual-package-for-cjs-and-esm-in-typescript-library-b5feabac1357Suggested tasks
Important
We should verify that type definitions work in both cases.
ts-jestmaxGraphwith CommonJS +jsdom(see ideas in Running maxgraph headlessly #761)