From 1f24978894725dca13c2adfee384e12f53f05c26 Mon Sep 17 00:00:00 2001 From: alvarius Date: Wed, 18 Sep 2024 20:18:49 +0100 Subject: [PATCH] fix(world): resolve module config (#3193) --- .changeset/smooth-tigers-exist.md | 5 +++++ packages/world/ts/config/v2/output.ts | 2 +- packages/world/ts/config/v2/world.ts | 4 +++- 3 files changed, 9 insertions(+), 2 deletions(-) create mode 100644 .changeset/smooth-tigers-exist.md diff --git a/.changeset/smooth-tigers-exist.md b/.changeset/smooth-tigers-exist.md new file mode 100644 index 0000000000..42fc2d0171 --- /dev/null +++ b/.changeset/smooth-tigers-exist.md @@ -0,0 +1,5 @@ +--- +"@latticexyz/world": patch +--- + +Added a config resolver to add default values for `modules` in the world config. diff --git a/packages/world/ts/config/v2/output.ts b/packages/world/ts/config/v2/output.ts index 77e5ec2af1..102872d6ef 100644 --- a/packages/world/ts/config/v2/output.ts +++ b/packages/world/ts/config/v2/output.ts @@ -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 */ diff --git a/packages/world/ts/config/v2/world.ts b/packages/world/ts/config/v2/world.ts index 92743fd2d5..424fab8400 100644 --- a/packages/world/ts/config/v2/world.ts +++ b/packages/world/ts/config/v2/world.ts @@ -74,6 +74,8 @@ export type resolveNamespaceMode = "namespaces" extends keyof input >; }; +type resolveModules = { [key in keyof input]: mergeIfUndefined }; + export type resolveWorld = resolveNamespaceMode & Omit, "multipleNamespaces" | "namespace" | "namespaces" | "tables"> & { readonly tables: flattenNamespacedTables>; @@ -88,7 +90,7 @@ export type resolveWorld = resolveNamespaceMode & 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 : CONFIG_DEFAULTS["modules"]; readonly codegen: show>; readonly deploy: show>; };