Skip to content
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

fix(world): resolve module config #3193

Merged
merged 3 commits into from
Sep 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/smooth-tigers-exist.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@latticexyz/world": patch
---

Added a config resolver to add default values for `modules` in the world config.
2 changes: 1 addition & 1 deletion packages/world/ts/config/v2/output.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ export type Module = {
* The name of the module
* @deprecated
*/
readonly name: string;
readonly name?: string;
/** Should this module be installed as a root module? */
readonly root: boolean;
/** Arguments to be passed to the module's install method */
Expand Down
4 changes: 3 additions & 1 deletion packages/world/ts/config/v2/world.ts
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,8 @@ export type resolveNamespaceMode<input> = "namespaces" extends keyof input
>;
};

type resolveModules<input> = { [key in keyof input]: mergeIfUndefined<input[key], MODULE_DEFAULTS> };

export type resolveWorld<input> = resolveNamespaceMode<input> &
Omit<resolveStore<input>, "multipleNamespaces" | "namespace" | "namespaces" | "tables"> & {
readonly tables: flattenNamespacedTables<resolveNamespaceMode<input>>;
Expand All @@ -88,7 +90,7 @@ export type resolveWorld<input> = resolveNamespaceMode<input> &
readonly excludeSystems: "excludeSystems" extends keyof input
? input["excludeSystems"]
: CONFIG_DEFAULTS["excludeSystems"];
readonly modules: "modules" extends keyof input ? input["modules"] : CONFIG_DEFAULTS["modules"];
readonly modules: "modules" extends keyof input ? resolveModules<input["modules"]> : CONFIG_DEFAULTS["modules"];
readonly codegen: show<resolveCodegen<"codegen" extends keyof input ? input["codegen"] : {}>>;
readonly deploy: show<resolveDeploy<"deploy" extends keyof input ? input["deploy"] : {}>>;
};
Expand Down
Loading