Optional automatic formatting with prettier
When you open a machine with the visual editor, it automatically formats the machine using prettier and there is no way to opt out of this behavior. I don't use prettier so it would be better to make this optional.
What kind of formatting would you like to have by default? Are you using any other formatter?
The way we have it set up now, we need to use some kind of default formatting - otherwise it'll just present as JSON.stringify(config, null, 2).
I.e. any time you have generated code, the thing that generates the code needs to make choices about how that code displays.
There are various ways to achieve the result though. A simple formatter could just work similarly to JSON.stringify (we probably can't use it directly because we might need to handle things that are not fully serializable, especially in the future) with indentation detected based on the file and the position in the file.
Yeah I don't use an auto-formatter at all (except for eslint which is pretty limited), but I see the problems here.
Perhaps what feels most problematic is that the machine is formatted before I've made any material changes via the visual editor -- so even if I just want alter the layout in the editor, I incur formatting changes that I don't want.
Moving from there, it seems that ideally the only parts that should be formatted are parts that have been introduced via the visual editor, and avoid formatting parts that haven't. I realize the complexity of that makes it very difficult to build 😅
I guess these kind of problems are what makes building this bidirectional code<->visual editing pretty difficult (I remember Dreamweaver pretty fondly though 😂)
Moving from there, it seems that ideally the only parts that should be formatted are parts that have been introduced via the visual editor, and avoid formatting parts that haven't. I realize the complexity of that makes it very difficult to build 😅
Ye - this isn't impossible but definitely more complex than the current solution. Given our small team right now and the relatively low priority of this, I wouldn't expect this to happen any time soon. A good thing though is that this is an open-source repository - so... sky's the limit 😉
The dependency on Prettier is being removed (for the most part) in this PR: https://github.com/statelyai/xstate-tools/pull/229