-
Notifications
You must be signed in to change notification settings - Fork 193
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
[WIP] local config types #1025
[WIP] local config types #1025
Conversation
fbe8d5d
to
a3ef8ce
Compare
|
thanks a lot for this exploration and detailed thoughts!
What if we create a
After our recent discussion about hooks I actually think most dependencies between plugins should be based on hooks. If plugin A expects to run after plugin B, it should hook into plugin A's |
This makes config imports roundabout/obfuscated, but most people wouldn't need to import the config and it should be fine. It's certainly better than doing it in
Hooks seem like a good solution. Resolving multiple parallel dependencies with hooks would be a pain, but I also can't think of an example here Before we commit to this, have you considered global hooks again, and do you still believe that locals are better? |
I still think local types are easier to understand for third party developers working on plugins, which I think is the most important factor. Building the foundation for local types on our end might be slightly more complex (lots of typescript black magic) but based on this exploration it seems feasible! |
replaced by #1077 |
I tried to keep a single
mudConfig
function for local types, but that seems impossible.Instead, I separate it into
defineConfig
andexpandConfig
, which is basically the approach from #750plugin definition is easier than globals
Local plugins mostly just need an
expandConfig
function.Global plugins need both a global version of an
expandConfig
function, and a module declaration with interface merging.Globals could be refactored to be more compact and have good templates, but they'll still be twice as complicated here
config definition is harder than globals
mud.config.mts
(which would be bad ux) mostly to show it all in 1 placesetupMUDV2Network
(it still remains in userland, but more hidden and unintrusive)setupMUDV2Network
because typescript doesn't support higher-kinded types Allow classes to be parametric in other parametric classes microsoft/TypeScript#1213Plugin dependencies are harder than globals
It comes down to who has the responsibility for the correct order of plugin dependencies:
plugins
config optionScripts are easy
Currently
tablegen
doesn't even change between global and local plguins.If
expandConfig
is moved out ofmud.config.mts
thentablegen
would need to wraploadConfig
withexpandConfig
, but that's itHooks are easy
Similar to https://github.com/latticexyz/mud/pull/1007/files so I don't focus on them here much.
If we want local types, this PR might be best done without hooks first, and then we add them separately