Shared Libraries
What to reuse from erxes-api-shared, erxes-ui, and ui-modules instead of reimplementing. This guide follows version 3.1.7 (03acdf712c).
For owning-service patterns, see Backend Plugins and Frontend Plugins.
Backend: erxes-api-shared
Location: backend/erxes-api-shared/src/.
utils/:service-discovery.ts(gateway registration),start-plugin.ts(service bootstrap),redis.ts,mongo/,apollo/(resolver wrappers, cursor/offset params),trpc/,logs/,agent-tools/,mq-worker.ts.core-modules/: reusable domain contracts forautomations,segments,logs,notifications,properties,permissions,import-export,templates,forms,apps.core-types/: shared TypeScript types such as main context and permission configs.common-modules/payment/: shared payment worker helpers.
Backend services consume the compiled entry points of this library. After changing it, rebuild before starting consumers:
pnpm nx build erxes-api-shared
Never import another service's implementation. Communicate through published GraphQL, tRPC, HTTP, event, or federation contracts.
Frontend: erxes-ui and ui-modules
frontend/libs/erxes-ui/src/: generic design-system primitives —components,hooks,lib,utils,modules/{board,record-table,filter,inputs,layout,display},state,types. Import aserxes-ui.frontend/libs/ui-modules/src/: business-domain UI —modules/{contacts,products,sales,segments,tags,automations,activity-logs,...},states,hooks. Import asui-modules.
Both are Module Federation shared singletons. Import via their package names; do not deep-import internal paths, copy their source into a plugin, or build a competing UI system. Use erxes-ui for primitives and ui-modules for domain composition.