Skip to content

The complete open source platform to run your entire marketplace. Storefront, vendor panel, admin console, and integrations in one enterprise-grade platform you own.

666 B
Raw Blame
import { emitLayers, spreadLayers } from "./layers"
import type { BuiltMercurConfig } from "./types"

/**
 * Custom-field configs carry runtime values (zod validation, render
 * components, default-value resolvers), so the emitted module re-exports the
 * default-exported config objects in layer order; the runtime
 * `ExtensionRegistry` keys them so a later config replaces an earlier one.
 */
export function generateCustomFields(config: BuiltMercurConfig): string {
    const { header, names } = emitLayers(config, ["customFieldsModule"])

    return `${header}

export default {
    configs: [
${spreadLayers(names, "customFieldsModule", "configs")}
    ]
}`
}