-
Notifications
You must be signed in to change notification settings - Fork 199
Restructure into a monorepo. #21
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
- Add Storybook to packages. - Remove circular dependencies.
|
I've added Prettier and its config, but haven't run it. It felt like we didn't have much discussion about code-styling. It'd be nice to gather opinions about it. |
|
I actually was using Prettier via https://github.com/ijsto/eslint-config. I don't know what the best style for mxGraph is either, I figured the defaults looked pretty good even though it's not the styles I'd normally use and that they're pretty close to what I've seen in many JS projects like mapbox-gl etc. Should we add a hook so that it auto-cleans up to that style on commit? I notice you've started converting some classes to functions too in mxEvents/mxUtils - looks much cleaner. I kept meaning to do it but to be honest knew the automatic typed-mxgraph documentation/types transfer scripts I was writing would depend on the code being in a class style convention. That's basically all done now, that script can be thrown away as far as I'm concerned and it's good to see them in there at last 😃 |
|
I see you've commented out some lines like It's not ideal having these as "on-demand" loaders, but the reason for these kinds of lines being after the classes was because of circular imports with the XML encode/decode serializers (formerly in the They used to be in the codecs themselves, but if importing the codecs with all of those encoders/decoders effectively tree-shaking isn't possible because the serializers depend on the original class and vice-versa. There should be a better solution for this, so would be interested if anyone knows of one. I might ask this as an issue together with a note to check the xml serialization/deserialization example works and re-enable it when it does because at last check it went in an endless recursive loop. |
I haven't yet tried, but if each codec gets registered into mxCodecRegistry wrapped in a function to be executed later, we might be able to dodge this circular dependency problem. Other than codecs, mxUtils is importing too many classes and that created circular dependencies, so I splitted them a bit and also deleted some functions like eval, alert and so on. I'm writing this outside based on my memory, so the names might be wrong ;) |
mcyph
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good to me. There was a previous eslint/Prettier config and need to check how they both interact, and there are some issues which need to be later worked out with the serializers, but can work these out after merging.
Based on @mcyph 's work, I restructured the code into a monorepo and added Storybook for the examples.
There are 3 packages.
Currently, only two html examples are converted to stories(HelloWorld and Grid), but I think it'll still show what it's capable of.
Since this change affects so many files, I decided not to wait until every examples are converted.
Also, there were lots of circular dependencies going on, so I divided mxUtils into multiple files and shuffled things around. Some of them are temporarily fixes that may need to be modified later.
The instruction for setting up is in Readme.md.
Thanks!