sverweij / state-machine-cat

write beautiful state charts :scream_cat:
https://state-machine-cat.js.org
MIT License
793 stars 45 forks source link

Publish UMD format to npm #140

Closed icio closed 3 years ago

icio commented 3 years ago

Context

I have some data that describes the transition of some entities' state over time and I've written a script to turn that into an state-machine-cat JSON blob so I can review that's happening. My initial setup included only an index.html, index.js and style.css.

I had hoped that I would be able load smcat from a

{ "states": [ { "type": "regular", "name": "Order(pending)", "color": "#586ada" }, { "type": "regular", "name": "Order(fulfilled)", "color": "#0f823c" } ], "transitions": [ { "from": "Order(pending)", "to": "Order(fulfilled)" } ] }
```

Supplying a thing on state-machine-cat.js.org that provides the statemachine cat api in a global shouldn't be too hard, so holler if the above doesn't fit your need.

I will only load a script from a third-party if I can specify an integrity tag, hence my preference for the versioned npm/unpkg.org route.

sverweij commented 3 years ago

Hi @icio thanks for that sample code. Some of that might leak into the 'inpage' script in the near future :-)

I will only load a script from a third-party if I can specify an integrity tag, hence my preference for the versioned npm/unpkg.org route.

That makes sense, the current URL could grow breaking changes over time. And you can't be diligent enough with loading 3rd party scripts anyway. I guess that #143 wouldn't be of much use then either, unless it'd grow the possibility to be a mini unpkg.

On publishing an UMD/ dist to npm

Drawback of publishing bundled code to npm is that it increases the package size for the regular library. For some packages that doesn't matter a lot, but some of state-machine-cat's dependencies are really big and pulling them in twice (in node_modules and in a dist folder) will be noticeable.

For another diagramming library I wrote long ago (mscgenjs) I went the nine yards made a separate distribution - even though that one is almost dependency less (https://mscgen.js.org/embed.html - also available on unpkg: https://unpkg.com/mscgenjs-inpage@4.0.0/dist/mscgen-inpage.js).

github-actions[bot] commented 3 years ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs.