Skip to content

API Reference / @gtkx/codegen / resolveStore

Variable: resolveStore

const resolveStore: (projectRoot) => ResolvedStore

Defined in: codegen/dist/store/resolve-store.d.ts:35

Resolves where a project's @gtkx/gi and @gtkx/jsx stores belong, from the project root alone. The result supplies every runCodegen input except libraries and girPath, so a caller that has already resolved those can spread it straight into the call.

Both stores go in one node_modules, found by walking the project's node_modules chain upwards: the one @gtkx/react resolves from, or @gtkx/runtime's when no React is installed. That is the project's own directory when it installs those packages itself, and the workspace root when npm or yarn hoisted them there. Keeping the pair together is what lets the jsx store import the gi store, and anchoring them where the @gtkx packages sit is what lets @gtkx/react, the CLI, and the project's sources all reach the bindings. A package manager that hoists therefore gives every project sharing that node_modules one shared store.

Store versions come from the installed @gtkx/runtime and @gtkx/react, so a dependency upgrade invalidates the stores. Pass explicit gi or jsx options to runCodegen to override any of it.

Parameters

projectRoot

string

Directory holding the project's package.json, whose node_modules chain is walked.

Returns

ResolvedStore

Where each store belongs.

Throws

If @gtkx/runtime cannot be resolved from the project, or a @gtkx package that imports the bindings is installed above the node_modules the stores would go in, since it could not reach them.

Released under the MPL-2.0 License.