maxGraph/packages/ts-example
Thomas Bouffard f9b2d7d19a
refactor!: move codecs to dedicated files and reduce side effects (#289)
Previously, codec classes were defined and registered in the same file
as the class they targeted. This prevented efficient tree-shaking: as
soon as the target class was imported (e.g. `StyleSheet`), the
corresponding codec was also imported (`StyleSheetCodec`). As a result,
a large amount of codec code (and dependent code) was present in
applications incorporating maxGraph, even if they didn't use the codec
function. As there are currently many problems with the codec function
that make it almost unusable, this was a great waste.

Codecs are no longer registered by default, which reduces side effects
and coupling.
It also greatly improves tree-shaking.
For example, in the `ts-example` application included in this repository
which doesn't use the "codec" feature, the size of the minified
`maxGraph` chunk goes from `568.58 kB` to `467.90 kB`, which corresponds
to a size reduction of `17.7%`!


BREAKING CHANGE: Codecs supplied by `maxGraph` are no longer registered
by default. They MUST be registered before performing an `encode` or
`decode`. You can use one of the following functions to register codecs:
  - `registerAllCodecs`
  - `registerCoreCodecs`
  - `registerEditorCodecs`
2023-12-13 17:39:40 +01:00
..
src refactor: simplify the code of `ts-example` (#255) 2023-11-16 11:53:47 +01:00
README.md ts-example: restore the rounded shape in the custom rectangle 2022-09-24 11:16:26 +02:00
favicon.svg chore: improve the configuration to build the npm package (#87) 2022-07-05 08:08:25 +02:00
index.html chore: improve the configuration to build the npm package (#87) 2022-07-05 08:08:25 +02:00
package.json chore(deps-dev): bump vite from 4.4.11 to 4.4.12 (#281) 2023-12-06 03:47:56 +00:00
tsconfig.json chore(tsconfig): add base tsconfig.json 2022-10-23 10:33:45 +03:00
vite.config.js refactor!: move codecs to dedicated files and reduce side effects (#289) 2023-12-13 17:39:40 +01:00

README.md

TypeScript project using the maxGraph npm package

Initialized from https://github.com/vitejs/vite/tree/v2.9.8/packages/create-vite/template-vanilla-ts

Setup

Initialize all packages

From the repository root, run npm install.

Build maxgraph@core

From the packages/core directory, run npm run generate-esm.

Run

Run npm run dev and go to http://localhost:5173/

If you want to bundle the application, run npm run build and then run npm run preview to access to a preview of the bundle application.