The complete open source platform to run your entire marketplace. Storefront, vendor panel, admin console, and integrations in one enterprise-grade platform you own.
TypeScript b2b-marketplacecomposable-commerceecommerceenterpriseheadless-commercemarketplacemedusamedusajsmulti-vendortypescript
import type {
NavigationConfig,
WidgetConfig,
} from "./types"
import type { CustomFieldModel, CustomFieldsConfig } from "./custom-fields"
import type { LayoutConfig, LayoutPreferences } from "./layouts"
import type { RouteConfig } from "../types"
/**
* Wraps a declarative config so Vite's Fast Refresh treats the module as a
* React component boundary — mirrors Medusa's `admin-sdk` config helpers so
* editing a config with an inline component hot-reloads instead of full-page
* reloading. The `$$typeof` marker is stripped by the build-time crawl.
*/
function createConfigHelper<TConfig extends object>(config: TConfig): TConfig {
return {
...config,
$$typeof: Symbol.for("react.memo"),
} as TConfig
}
export function defineWidgetConfig(config: WidgetConfig): WidgetConfig {
return createConfigHelper(config)
}
export function defineNavigationConfig<TGroup extends string = never>(
config: NavigationConfig<TGroup>
): NavigationConfig<TGroup> {
return createConfigHelper(config)
}
export function defineCustomFieldsConfig<TModel extends CustomFieldModel>(
config: CustomFieldsConfig<TModel>
): CustomFieldsConfig<TModel> {
return createConfigHelper(config)
}
export function defineRouteConfig(config: RouteConfig): RouteConfig {
return createConfigHelper(config)
}
export function defineLayoutConfig(config: LayoutConfig): LayoutConfig {
return createConfigHelper(config)
}
export function defineLayoutPreferences(
config: LayoutPreferences
): LayoutPreferences {
return config
}